Class: TimeTrello::TrelloDriver
- Inherits:
-
Object
- Object
- TimeTrello::TrelloDriver
- Defined in:
- lib/time_trello/trello_driver.rb
Overview
Public: Driver responsible to convert data gathered from Trello to an internal representation.
Instance Attribute Summary collapse
-
#board_id ⇒ Object
Returns the value of attribute board_id.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
-
#activities ⇒ Object
Public: Getter.
-
#board ⇒ Object
Public: Getter.
-
#initialize(board_id, prefix) ⇒ TrelloDriver
constructor
A new instance of TrelloDriver.
-
#members ⇒ Object
Public: Getter.
-
#parser ⇒ Object
Public: Getter.
-
#reset_cache ⇒ Object
Public: Resets the driver caches.
Constructor Details
#initialize(board_id, prefix) ⇒ TrelloDriver
Returns a new instance of TrelloDriver.
23 24 25 26 27 28 29 30 |
# File 'lib/time_trello/trello_driver.rb', line 23 def initialize(board_id, prefix) @board_id = board_id @prefix = prefix @activities = nil @board = nil @members = nil @parser = nil end |
Instance Attribute Details
#board_id ⇒ Object
Returns the value of attribute board_id.
20 21 22 |
# File 'lib/time_trello/trello_driver.rb', line 20 def board_id @board_id end |
#prefix ⇒ Object
Returns the value of attribute prefix.
21 22 23 |
# File 'lib/time_trello/trello_driver.rb', line 21 def prefix @prefix end |
Instance Method Details
#activities ⇒ Object
Public: Getter. Gets all activities for a given board.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/time_trello/trello_driver.rb', line 76 def activities return @activities if !@activities.nil? && @activities.length > 0 @activities = [] self.board.cards.each do |card| card.actions.each do |action| member = self.members.select { |member| member.id == action.member_creator_id }.first action_record = {action: action, member: member} activity = self.parser.parse(action_record) @activities.push(activity) unless activity.nil? end end @activities end |
#board ⇒ Object
Public: Getter. Gets a board, based on a board id.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/time_trello/trello_driver.rb', line 40 def board retried = false begin @board = Trello::Board.find(@board_id) if @board.nil? rescue if !retried retried = true retry else raise "Failed to connect to Trello API" end end @board end |
#members ⇒ Object
Public: Getter. Gets all members subscribed to the board under analysis
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/time_trello/trello_driver.rb', line 58 def members retried = false begin @members = self.board.members if @members.nil? rescue if !retried retried = true retry else raise "Failed to connect to Trello API" end end @members end |
#parser ⇒ Object
Public: Getter. Returns a record parser instance
33 34 35 36 37 |
# File 'lib/time_trello/trello_driver.rb', line 33 def parser @parser = Parser.new(@prefix) if @parser.nil? @parser end |
#reset_cache ⇒ Object
Public: Resets the driver caches
93 94 95 96 97 |
# File 'lib/time_trello/trello_driver.rb', line 93 def reset_cache @activities = nil @board = nil @members = nil end |