class BBFlow::Trello
Public Class Methods
cards()
click to toggle source
# File lib/bb_flow/trello.rb, line 8 def cards puts 'Fetching Trello cards...' lists.flat_map { |list| list.cards.target }.select { |card| card.member_ids.include?(member.id) } end
done_list()
click to toggle source
# File lib/bb_flow/trello.rb, line 19 def done_list trello::List.find(done_list_id) end
format_card(card)
click to toggle source
@param [Trello::Card] card
@return [Array<String>]
# File lib/bb_flow/trello.rb, line 26 def format_card(card) prefix, _, title = card.name.rpartition(/(?<=\])\s*/) # At last closing square bracket. _score, _, tags = prefix.rpartition(/(?<=\))\s*/) # After last parentheses. [tags, title, card.short_url] end
labels()
click to toggle source
# File lib/bb_flow/trello.rb, line 14 def labels cards.flat_map { |card| card.labels.target }.map(&:name).map(&:downcase) end
Private Class Methods
board()
click to toggle source
# File lib/bb_flow/trello.rb, line 36 def board trello::Board.find(board_id) end
board_id()
click to toggle source
# File lib/bb_flow/trello.rb, line 72 def board_id Printer.select_item(trello::Board.all, 'Which Trello board do you work with?', formatter: ->(board) { [board.name, board.url] }).id end
done_list_id()
click to toggle source
# File lib/bb_flow/trello.rb, line 82 def done_list_id Printer.select_item(board.lists, 'Where should I move finished cards?').id end
key()
click to toggle source
# File lib/bb_flow/trello.rb, line 61 def key Printer.ask('Go to https://trello.com/app-key and paste Key: ') end
list_ids()
click to toggle source
# File lib/bb_flow/trello.rb, line 77 def list_ids Printer.select_items(board.lists, 'Which lists contain not finished - „in progress“ - cards?').map(&:id) end
lists()
click to toggle source
# File lib/bb_flow/trello.rb, line 41 def lists list_ids.map { |list| trello::List.find(list) } end
member()
click to toggle source
# File lib/bb_flow/trello.rb, line 46 def member trello::Member.find('me') end
member_token()
click to toggle source
# File lib/bb_flow/trello.rb, line 66 def member_token authorization_url = "http://trello.com/1/authorize?key=#{key}&response_type=token&expiration=never&scope=read,write" Printer.ask("Go to #{authorization_url}, click 'Allow', and paste Token") end
trello()
click to toggle source
# File lib/bb_flow/trello.rb, line 51 def trello ::Trello.configure do |config| config.developer_public_key = key config.member_token = member_token end ::Trello end