Class: TrelloScrum::TrelloInterface
- Inherits:
-
Object
- Object
- TrelloScrum::TrelloInterface
- Defined in:
- lib/trello_interface.rb
Instance Attribute Summary collapse
-
#board_id ⇒ Object
Returns the value of attribute board_id.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #get_cards(list_name = nil, options = {}) ⇒ Object
- #get_lists(list_name, options = {}) ⇒ Object
-
#initialize(board_id, developer_public_key, member_token, options = {}) ⇒ TrelloInterface
constructor
A new instance of TrelloInterface.
Constructor Details
#initialize(board_id, developer_public_key, member_token, options = {}) ⇒ TrelloInterface
Returns a new instance of TrelloInterface.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/trello_interface.rb', line 7 def initialize(board_id, developer_public_key, member_token, = {}) Trello.configure do |c| c.developer_public_key = developer_public_key c.member_token = member_token end self.board_id = board_id self. = end |
Instance Attribute Details
#board_id ⇒ Object
Returns the value of attribute board_id.
5 6 7 |
# File 'lib/trello_interface.rb', line 5 def board_id @board_id end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/trello_interface.rb', line 5 def @options end |
Instance Method Details
#get_cards(list_name = nil, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trello_interface.rb', line 19 def get_cards(list_name = nil, = {}) log "Getting cards from list #{list_name} of board #{board_id}" lists = get_lists(list_name, ) lists.map do |list| cards = list.cards.sort!{|a, b| a.pos <=> b.pos } log "List '#{list.name}' contains #{cards.size} cards" filtered_cards = cards.find_all do |card| keep = true keep = false if [:"only-estimated"] && !(card.name =~ /^\(\d+/) keep = false if [:"filter-title"] && !(card.name =~ Regexp.new([:"filter-title"])) keep end filtered_cards.map! do |card| class << card attr_accessor :scrum_points, :scrum_client, :scrum_title end points,client,title = parse_card_title(card.name) card.scrum_points = points card.scrum_client = client card.scrum_title = title card end { list: list, cards: filtered_cards } end end |
#get_lists(list_name, options = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/trello_interface.rb', line 54 def get_lists(list_name, = {}) board = Trello::Board.find(board_id) lists = board.lists filter: ([:"include-archived-lists"] ? :all : :open) if list_name && !list_name.empty? lists = lists.find_all{|l| l.name == list_name } end lists.sort!{|a, b| a.pos <=> b.pos } log "Found lists: #{lists.map(&:name).inspect}" lists end |