class SlackTrello::Commands::Retro

Attributes

slack_post_response[R]
webhook_url[R]

Public Class Methods

new(slack_post_args, webhook_url) click to toggle source
# File lib/slack_trello/commands/retro.rb, line 8
def initialize(slack_post_args, webhook_url)
  @slack_post_response = OpenStruct.new(slack_post_args)
  @webhook_url = webhook_url
end

Public Instance Methods

run() click to toggle source
# File lib/slack_trello/commands/retro.rb, line 13
def run
  return help_message unless valid_text_format?
  return help_message unless num_args == 1
  return list_not_found_message unless trello_card_creator.trello_list

  trello_card
  speaker.speak success_message
  "You should see a notification with a link. If not, the card might not have been created."
end

Private Instance Methods

card_title() click to toggle source
# File lib/slack_trello/commands/retro.rb, line 50
def card_title
  "#{text_message} -- #{slack_post_response.user_name}"
end
example_command() click to toggle source
# File lib/slack_trello/commands/retro.rb, line 25
def example_command
  "/retro (#{list_names.first}) blah blah blah"
end
list_names() click to toggle source
# File lib/slack_trello/commands/retro.rb, line 54
def list_names
  board = SlackTrello::TrelloHelpers::Lookup.board(trello_board_name)
  board.lists.map do |list|
    list.name.parameterize.underscore
  end
end
trello_board_name() click to toggle source
# File lib/slack_trello/commands/retro.rb, line 42
def trello_board_name
  "#{slack_post_response.channel_name.titleize} Retro"
end
trello_card() click to toggle source
# File lib/slack_trello/commands/retro.rb, line 38
def trello_card
  @card ||= trello_card_creator.first_or_create
end
trello_card_creator() click to toggle source
# File lib/slack_trello/commands/retro.rb, line 29
def trello_card_creator
  args = {
    board_name: trello_board_name,
    list_name: trello_list_name,
    card_name: card_title
  }
  @trello_card_creator ||= SlackTrello::TrelloHelpers::CreateCard.new(args)
end
trello_list_name() click to toggle source
# File lib/slack_trello/commands/retro.rb, line 46
def trello_list_name
  args[0]
end