Skip to content

Instantly share code, notes, and snippets.

@gabrieljoelc
Last active September 14, 2017 18:46
Show Gist options
  • Save gabrieljoelc/fd49e596d68922adf1b0bbb884e702f0 to your computer and use it in GitHub Desktop.
Save gabrieljoelc/fd49e596d68922adf1b0bbb884e702f0 to your computer and use it in GitHub Desktop.
Standup service that is extendible on input and output (i.e. GitHub, Jira, and Trello for input with Slack and Email for output)
class InputProvider
def pull; end
end
class ManualInputProvider
def pull; end
end
class OutputProvider
def push; end
end
class SlackOutputProvider
# see https://github.com/slack-ruby/slack-ruby-client
require 'slack-ruby-client'
attr_reader :channel
def initialize(channel)
@channel = channel
end
def push(standup)
client.chat_postMessage(channel: channel, attachments: attachments)
end
# see https://api.slack.com/docs/messages/builder?msg=%7B%22attachments%22%3A%5B%7B%22fallback%22%3A%22Required%20plain-text%20summary%20of%20the%20attachment.%22%2C%22color%22%3A%22%2336a64f%22%2C%22pretext%22%3A%22Optional%20text%20that%20appears%20above%20the%20attachment%20block%22%2C%22author_name%22%3A%22Bobby%20Tables%22%2C%22author_link%22%3A%22http%3A%2F%2Fflickr.com%2Fbobby%2F%22%2C%22author_icon%22%3A%22http%3A%2F%2Fflickr.com%2Ficons%2Fbobby.jpg%22%2C%22title%22%3A%22Slack%20API%20Documentation%22%2C%22title_link%22%3A%22https%3A%2F%2Fapi.slack.com%2F%22%2C%22text%22%3A%22Optional%20text%20that%20appears%20within%20the%20attachment%22%2C%22fields%22%3A%5B%7B%22title%22%3A%22Priority%22%2C%22value%22%3A%22High%22%2C%22short%22%3Afalse%7D%5D%2C%22image_url%22%3A%22http%3A%2F%2Fmy-website.com%2Fpath%2Fto%2Fimage.jpg%22%2C%22thumb_url%22%3A%22http%3A%2F%2Fexample.com%2Fpath%2Fto%2Fthumb.png%22%2C%22footer%22%3A%22Slack%20API%22%2C%22footer_icon%22%3A%22https%3A%2F%2Fplatform.slack-edge.com%2Fimg%2Fdefault_application_icon.png%22%2C%22ts%22%3A123456789%7D%5D%7D
AttachmentMapper = Struct.new(standup) do
def attachments
attachments = []
attachments << { title: 'Yesterday', text: standup.to_bullet_s }
attachments << { title: 'Today', text: standup.to_bullet_s }
attachments << { title: 'Blockers', text: standup.to_bullet_s }
attachments
end
end
end
class Standup
attr_reader :yesterday, :today, :blockers
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment