lib/burndown_chart.rb in trollolo-0.0.14 vs lib/burndown_chart.rb in trollolo-0.1.0

- old
+ new

@@ -178,23 +178,24 @@ end end last_sprint end - def load_last_sprint(burndown_dir) - self.sprint = last_sprint(burndown_dir) + # It loads the sprint for the given number or the last one if it is nil + def load_sprint(burndown_dir, number = nil) + self.sprint = number || last_sprint(burndown_dir) burndown_data_path = File.join(burndown_dir, burndown_data_filename) begin read_data burndown_data_path rescue Errno::ENOENT raise TrolloloError.new( "'#{burndown_data_path}' not found" ) end return burndown_data_path end def update(options) - burndown_data_path = load_last_sprint(options['output'] || Dir.pwd) + burndown_data_path = load_sprint(options['output'] || Dir.pwd, options[:sprint_number]) burndown_data = BurndownData.new(@settings) burndown_data.board_id = board_id burndown_data.fetch @@ -211,16 +212,20 @@ end if options[:plot_to_board] trello = TrelloWrapper.new(@settings) board = trello.board(board_id) - trello.add_attachment(board.burndown_card_id, "burndown-#{sprint.to_s.rjust(2, '0')}.png") + name = options['output'] ? options['output'] : '.' + name += "/burndown-#{sprint.to_s.rjust(2, '0')}.png" + card_id = board.burndown_card_id + trello.add_attachment(card_id, name) + trello.make_cover(card_id, name) end end def create_next_sprint(burndown_dir, options = {}) - load_last_sprint(burndown_dir) - self.sprint = self.sprint + 1 + load_sprint(burndown_dir) + self.sprint = options[:sprint_number] || (self.sprint + 1) @data["meta"]["total_days"] = options[:total_days] if options[:total_days] @data["meta"]["weekend_lines"] = options[:weekend_lines] unless options[:weekend_lines].blank? @data["days"] = [] write_data File.join(burndown_dir, burndown_data_filename) end