Sha256: 71d823a3c92cb1684fb44c5ef141b20a765b8a7effb481e9f57cb8cdeb57e6eb

Contents?: true

Size: 1020 Bytes

Versions: 2

Compression:

Stored size: 1020 Bytes

Contents

module PairSee
  class LogLines
    require_relative 'log_line'
    require 'git'

    include Enumerable

    def initialize(git_home, date_string)
      @lines = _lines_from(git_home, date_string)
    end

    def _lines_from(git_home, date_string)
      g = Git.open(git_home)
      g.log.since(date_string).map do |l|
        LogLine.new("#{l.date} #{l.message}")
      end
    end

    def each(&block)
      lines.each &block
    end

    def last
      lines.last
    end

    def active?(dev)
      any? do |log_line|
        log_line.authored_by?(dev)
      end
    end

    def commits_for_pair(person1, person2)
      select { |log_line| log_line.authored_by?(person1, person2) }
    end

    def commits_not_by_known_pair(devs)
      reject { |log_line| log_line.not_by_pair? devs }
    end

    def solo_commits(devs, dev)
      select do |log_line|
        log_line.authored_by?(dev) && (devs - [dev]).none? { |d| log_line.authored_by?(d) }
      end
    end

    private

    attr_reader :lines
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pair_see-0.1.2 lib/pair_see/log_lines.rb
pair_see-0.1.1 lib/pair_see/log_lines.rb