Sha256: a72e09cb25ae83261b68d8717c2b9b12c68723079dfac3fff01693cb8795c467

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module PairSee
  class CardsPerPerson
    attr_reader :devs

    def initialize(log_lines, card_prefix, people)
      @log_lines = log_lines
      @card_prefix = card_prefix
      @devs = _active(people)
    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.sort do |a, b|
        a[1].size <=> b[1].size
      end.map do |dev, cards|
        "#{dev}: [#{cards.size} cards] #{cards.sort.join(', ')}"
      end
    end

    def _cards_dev_worked_on(log_lines, person)
      log_lines.select do |log_line|
        log_line.authored_by?(person)
      end.map do |log_line|
        log_line.card_number(@card_prefix)
      end.compact
    end

    def _active(people)
      people.select do |person|
        @log_lines.active? person
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pair_see-0.1.5 lib/pair_see/cards_per_person.rb