lib/burndown_chart.rb in trollolo-0.0.5 vs lib/burndown_chart.rb in trollolo-0.0.6

- old
+ new

@@ -18,11 +18,10 @@ attr_accessor :data def initialize(settings) @settings = settings - @burndown_data = BurndownData.new settings @data = { "meta" => { "board_id" => nil, "sprint" => 1, @@ -72,11 +71,11 @@ days.any? { |entry| entry["date"] == date.to_s } end def add_data(burndown_data) new_entry = burndown_data.to_hash - if entry_exists?(burndown_data.date_time.to_date) + if entry_exists?(burndown_data.date_time.to_date) && days.length > 1 replace_entry(burndown_data.date_time.to_date, new_entry) else days.push(new_entry) end end @@ -166,13 +165,18 @@ return burndown_data_path end def update(options) burndown_data_path = load_last_sprint(options['output'] || Dir.pwd) - @burndown_data.board_id = board_id - @burndown_data.fetch - add_data(@burndown_data) - write_data burndown_data_path + + burndown_data = BurndownData.new(@settings) + burndown_data.board_id = board_id + burndown_data.fetch + + add_data(burndown_data) + + write_data(burndown_data_path) + if options[:plot] BurndownChart.plot(self.sprint, options) end end