Sha256: edbc979669f5ab5c662f6536b3f1d8c1ca1ef14b631def5584cb99b2fe2e8c37

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

Contents

require_relative 'log_line'
require 'git'

class LogLines
  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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pair_see-0.1.0 lib/pair_see/log_lines.rb