lib/scrum_board.rb in trollolo-0.0.10 vs lib/scrum_board.rb in trollolo-0.0.11

- old
+ new

@@ -11,17 +11,15 @@ def columns @columns ||= @board_data["lists"].map{|x| Column.new(@board_data, x["id"])} end def done_column - begin - done_columns = columns.select{|c| c.name =~ @settings.done_column_name_regex } - if done_columns.empty? - raise DoneColumnNotFoundError, "can't find done column by name regex #{@settings.done_column_name_regex}" - else - done_columns.max_by{|c| c.name.match(@settings.done_column_name_regex).captures.first.to_i } - end + done_columns = columns.select{|c| c.name =~ @settings.done_column_name_regex } + if done_columns.empty? + raise DoneColumnNotFoundError, "can't find done column by name regex #{@settings.done_column_name_regex}" + else + done_columns.max_by{|c| c.name.match(@settings.done_column_name_regex).captures.first.to_i } end end def accepted_column accepted_columns = columns.select{|c| c.name =~ @settings.accepted_column_name_regex } @@ -39,11 +37,11 @@ def open_columns columns.select{ |col| @settings.not_done_columns.include?(col.name) } end def open_cards - open_columns.map{|col| col.committed_cards}.flatten + open_columns.map(&:committed_cards).flatten end def committed_cards open_cards + done_cards end @@ -76,11 +74,11 @@ def extra_done_story_points extra_done_cards.map(&:story_points).sum end def extra_open_cards - open_columns.map{|col| col.cards.select{|c| c.extra?}}.flatten + open_columns.map{|col| col.cards.select(&:extra?) }.flatten end def extra_open_story_points extra_open_cards.map(&:story_points).sum end @@ -105,11 +103,11 @@ def unplanned_done_story_points unplanned_done_cards.map(&:story_points).sum end def unplanned_open_cards - open_columns.map{|col| col.cards.select{|c| c.unplanned?}}.flatten + open_columns.map{|col| col.cards.select(&:unplanned?) }.flatten end def unplanned_open_story_points unplanned_open_cards.map(&:story_points).sum end @@ -134,21 +132,16 @@ def scrum_cards open_columns.map(&:fast_lane_cards).flatten(1) + done_column.cards + accepted_column.cards end def meta_cards - scrum_cards.select{|c| c.meta_card? } + scrum_cards.select(&:meta_card?) end def id @board_data["id"] end def cards - return @cards if @cards - @cards = [] - columns.each do |column| - @cards += column.cards - end - @cards + @cards ||= columns.map(&:cards).flatten end end