Class: TrelloChangelog
- Inherits:
-
Object
- Object
- TrelloChangelog
- Defined in:
- lib/trello-changelog.rb,
lib/trello-changelog/config.rb,
lib/trello-changelog/tickets.rb,
lib/trello-changelog/printers.rb
Instance Method Summary collapse
- #archived_done_tickets ⇒ Object
- #archived_tickets ⇒ Object
- #archived_tickets_count ⇒ Object
- #board ⇒ Object
- #build_labels ⇒ Object
- #build_output ⇒ Object
- #build_summary ⇒ Object
- #build_unlabeled ⇒ Object
- #done_list ⇒ Object
- #done_tickets ⇒ Object
- #done_tickets_count ⇒ Object
-
#initialize(options) ⇒ TrelloChangelog
constructor
A new instance of TrelloChangelog.
- #new_tickets ⇒ Object
- #new_tickets_count ⇒ Object
- #print ⇒ Object
Constructor Details
#initialize(options) ⇒ TrelloChangelog
Returns a new instance of TrelloChangelog.
8 9 10 11 12 13 14 |
# File 'lib/trello-changelog.rb', line 8 def initialize() @options = .with_indifferent_access load_config_file configure_trello start_date(@options[:start_date]) end |
Instance Method Details
#archived_done_tickets ⇒ Object
24 25 26 |
# File 'lib/trello-changelog/tickets.rb', line 24 def archived_done_tickets @archived_done_tickets ||= board.cards( { filter: :all } ).select { |card| card.creation_date >= start_date }.select { |card| card.list_id == done_list.id }.select { |card| card.closed == true } end |
#archived_tickets ⇒ Object
20 21 22 |
# File 'lib/trello-changelog/tickets.rb', line 20 def archived_tickets @archived_tickets ||= board.cards( { filter: :all } ).select { |card| card.creation_date >= start_date }.select { |card| card.closed == true } - archived_done_tickets end |
#archived_tickets_count ⇒ Object
36 37 38 |
# File 'lib/trello-changelog/tickets.rb', line 36 def archived_tickets_count archived_tickets.count end |
#board ⇒ Object
4 5 6 |
# File 'lib/trello-changelog/tickets.rb', line 4 def board @board ||= Trello::Board.find(@config[:board]) end |
#build_labels ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/trello-changelog/printers.rb', line 27 def build_labels for label_name in @config[:labels] do tickets_label_name = done_tickets.select { |ticket| ticket.labels.select { |label| label.name == label_name}.count > 0 } @output << "\n## #{label_name}:\n\n" tickets_label_name.each do |ticket| @output << " * [#{ticket.name}](#{ticket.url})\n" end @output << 'n.a.' if tickets_label_name.count == 0 end end |
#build_output ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/trello-changelog/printers.rb', line 8 def build_output @output = "" build_summary build_labels build_unlabeled @output end |
#build_summary ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/trello-changelog/printers.rb', line 17 def build_summary @output << "# Start date: #{start_date}\n\n" @output << "Created Trello items since #{start_date}: #{new_tickets_count}\n\n" @output << "Finished Trello items since #{start_date}: #{done_tickets_count}\n\n" @output << "Archived Trello items since #{start_date}: #{archived_tickets_count}\n\n" @output << "Summary: #{new_tickets_count} tickets in, #{done_tickets_count + archived_tickets_count} tickets out\n\n" end |
#build_unlabeled ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/trello-changelog/printers.rb', line 38 def build_unlabeled # We only list the cards that have none of the configured labels @unlabeled_done_tickets = done_tickets.select { |ticket| (ticket.labels.map(&:name) & @config[:labels]).empty? } @output << "\n## Other\n\n" @unlabeled_done_tickets.each do |ticket| @output << " * [#{ticket.name}](#{ticket.url})\n" end end |
#done_list ⇒ Object
8 9 10 |
# File 'lib/trello-changelog/tickets.rb', line 8 def done_list @done_list ||= board.lists.select { |list| list.name == @config[:done_list_name] }.last end |
#done_tickets ⇒ Object
16 17 18 |
# File 'lib/trello-changelog/tickets.rb', line 16 def done_tickets @done_tickets ||= board.cards.select { |card| card.list_id == done_list.id } end |
#done_tickets_count ⇒ Object
32 33 34 |
# File 'lib/trello-changelog/tickets.rb', line 32 def done_tickets_count done_tickets.count end |
#new_tickets ⇒ Object
12 13 14 |
# File 'lib/trello-changelog/tickets.rb', line 12 def new_tickets @new_tickets ||= board.cards.select { |card| card.creation_date >= start_date} end |
#new_tickets_count ⇒ Object
28 29 30 |
# File 'lib/trello-changelog/tickets.rb', line 28 def new_tickets_count new_tickets.count end |
#print ⇒ Object
4 5 6 |
# File 'lib/trello-changelog/printers.rb', line 4 def print puts build_output end |