Sha256: a2d3045ba3667351e7885ea26e5c3be1c91a1e2078147795ad65b76cf5f32aca

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module PairSee
  class CardsPerPerson
    attr_reader :devs

    def initialize(log_lines, options)
      @log_lines = log_lines
      @options = options
      @devs = _active(options[:names])
    end

    def cards_per_person
      @devs.map do |dev|
        {dev => _cards_dev_worked_on(@log_lines, dev)}
      end.inject({}) do |result, element|
        result.merge(element)
      end.map do |dev_name, cards_worked|
        {dev_name => cards_worked.uniq}
      end.inject({}) do |result, element|
        result.merge(element)
      end.map do |dev, cards|
        "#{dev}: [#{cards.size} cards] #{cards.sort.join(', ')}"
      end
    end

    def _cards_dev_worked_on(log_lines, dev)
      log_lines.select do |log_line|
        log_line.authored_by?(dev)
      end.map do |log_line|
        log_line.card_number(@options[:card_prefix])
      end.compact
    end

    def _active(devs)
      devs.select do |dev|
        _is_active?(dev)
      end
    end

    def _is_active?(dev)
      @log_lines.active? dev
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pair_see-0.1.4 lib/pair_see/cards_per_person.rb
pair_see-0.1.3 lib/pair_see/cards_per_person.rb