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

- old
+ new

@@ -32,20 +32,23 @@ @open + @done end end attr_accessor :story_points, :tasks, :extra_story_points, :extra_tasks, + :unplanned_story_points, :unplanned_tasks, :board_id, :fast_lane_cards, :date_time attr_reader :meta def initialize(settings) - @settings = settings - @story_points = Result.new - @tasks = Result.new - @extra_story_points = Result.new - @extra_tasks = Result.new - @fast_lane_cards = Result.new + @settings = settings + @story_points = Result.new + @tasks = Result.new + @extra_story_points = Result.new + @extra_tasks = Result.new + @unplanned_story_points = Result.new + @unplanned_tasks = Result.new + @fast_lane_cards = Result.new end def to_hash base = { "date" => date_time.to_date.to_s, @@ -64,17 +67,26 @@ "tasks_extra" => { "done" => extra_tasks.done } } if fast_lane_cards.total > 0 - base.merge("fast_lane" => { - "total" => fast_lane_cards.total, - "open" => fast_lane_cards.open - }) - else - base + base["fast_lane"] = { + "total" => fast_lane_cards.total, + "open" => fast_lane_cards.open + } end + if unplanned_story_points.total > 0 + base["unplanned_story_points"] = { + "total" => unplanned_story_points.total, + "open" => unplanned_story_points.open + } + base["unplanned_tasks"] = { + "total" => unplanned_tasks.total, + "open" => unplanned_tasks.open + } + end + base end def trello @trello ||= TrelloWrapper.new(@settings) end @@ -82,30 +94,36 @@ def board trello.board(@board_id) end def fetch - get_meta + @meta = get_meta @story_points.done = board.done_story_points @story_points.open = board.open_story_points @tasks.open = board.tasks - board.closed_tasks @tasks.done = board.closed_tasks @extra_story_points.done = board.extra_done_story_points @extra_story_points.open = board.extra_open_story_points @extra_tasks.done = board.extra_closed_tasks @extra_tasks.open = board.extra_tasks - board.extra_closed_tasks + @unplanned_story_points.done = board.unplanned_done_story_points + @unplanned_story_points.open = board.unplanned_open_story_points + @unplanned_tasks.done = board.unplanned_closed_tasks + @unplanned_tasks.open = board.unplanned_tasks - board.unplanned_closed_tasks @fast_lane_cards.done = board.done_fast_lane_cards_count @fast_lane_cards.open = board.open_fast_lane_cards_count @date_time = DateTime.now end private def get_meta meta_cards = board.meta_cards - return unless meta_cards.any? + return nil unless meta_cards.any? current_sprint_meta_card = meta_cards.max_by(&:sprint_number) - @meta = Card.parse_yaml_from_description(current_sprint_meta_card.desc) - @meta['sprint'] = current_sprint_meta_card.sprint_number + meta = Card.parse_yaml_from_description(current_sprint_meta_card.desc) + return nil unless meta + meta['sprint'] = current_sprint_meta_card.sprint_number + meta end end