lib/pair_see/seer.rb in pair_see-0.1.5 vs lib/pair_see/seer.rb in pair_see-0.1.6

- old
+ new

@@ -1,128 +1,52 @@ module PairSee class Seer - require 'yamler' - require_relative 'combo' - require_relative 'date_combo' - require_relative 'log_lines' - require_relative 'card' - require_relative 'cards_per_person' - require_relative 'active_devs' + require_relative 'too_much_stuff' - attr_reader :log_lines, :devs, :dev_pairs, :card_prefixes - @@maximum_commits_to_parse = 9999 + attr_reader :seer def initialize(options) - @log_lines = _lines_from(options[:repo_locations], options[:after_date]) - @sub_seer = CardsPerPerson.new(@log_lines, options[:card_prefix], options[:names]) - @active_devs = ActiveDevs.new(@log_lines, options).devs - @devs = @sub_seer.devs - @card_prefixes = options[:card_prefix] - @dev_pairs = devs.combination(2) + @repo_locations = options[:repo_locations] + @after_date = options[:after_date] + @card_prefix = options[:card_prefix] + @names = options[:names] + @seer = PairSee::TooMuchStuff.new(options) + @log_lines = LogLineParse.new(@repo_locations, @after_date).log_lines end - def cards_per_person - @sub_seer.cards_per_person + def commits_not_by_known_pair + seer.commits_not_by_known_person end - def _lines_from(roots, date_string) - lines = [] - roots.each {|root| - g = Git.open(root) - lines << g.log(@@maximum_commits_to_parse).since(date_string).map do |l| - LogLine.new("#{l.date} #{l.message}") - end - } - LogLines.new(lines.flatten) + def all_most_recent_commits + seer.all_most_recent_commits end - def pretty_card_data - card_data(card_prefixes).map do |card| - card.pretty unless card.nil? - end + def recommended_pairings + seer.recommended_pairings end - def card_data(card_prefixes) - card_prefixes.map do |card_prefix| - card_numbers(card_prefix).map do |card_name| - commits = commits_on_card(card_name) - Card.new(card_name, commits.count, commits.first.date, commits.last.date) - end - end.flatten.sort_by(&:duration).reverse + def pretty_card_data + seer.pretty_card_data end - def commits_on_card(card_name) - log_lines.select {|line| line.contains_card_name?(card_name)} + def pretty_card_data_by_commits + seer.pretty_card_data_by_commits end - def card_numbers(card_prefix) - log_lines.select do |line| - line.contains_card?(card_prefix) - end.map do |line| - line.card_name([card_prefix]) - end.uniq.compact - end - - def get_card_prefix(config_file) - config = YAML.load_file(config_file) - config['card_prefix'] - end - - def active_devs(config_file) - @active_devs - end - - def pair_commits - dev_pairs.map do |person1, person2| - Combo.new(commits_for_pair(person1, person2).count, person1, person2) - end - end - - def solo_commits - devs.map do |dev| - Combo.new(log_lines.solo_commits(devs, dev).count, dev) - end - end - def all_commits - (pair_commits + solo_commits).sort_by(&:count).reject(&:empty?).map(&:to_s) + seer.all_commits end - def commits_for_pair(person1, person2) - log_lines.commits_for_pair person1, person2 + def cards_per_person + CardsPerPerson.new(@log_lines, @card_prefix, @names).cards_per_person end - def commits_not_by_known_pair - log_lines.commits_not_by_known_pair devs + def knowledge_debt + KnowledgeDebt.new(@log_lines, @card_prefix, @names).knowledge_debt end - def most_recent_commit_date(person1, person2) - recent_commit = commits_for_pair(person1, person2).sort_by(&:date).first - recent_commit ? recent_commit.date : nil - end - - def all_most_recent_commits - dev_pairs.map do |person1, person2| - DateCombo.new(most_recent_commit_date(person1, person2), person1, person2) - end.sort.reverse.map &:to_s - end - - def recommended_pairings - should_pair = unpaired_in_range - should_pair.empty? ? [least_recent_pair] : should_pair - end - - def least_recent_pair - devs.select do |person| - person.names.any? {|name| log_lines.last.line.match(name)} - end.map(&:display_name).join(', ') - end - - def unpaired_in_range - dev_pairs.select do |person1, person2| - most_recent_commit_date(person1, person2).nil? - end.map do |person1, person2| - "#{person1}, #{person2}" - end + def pair_recency + PairRecency.new(@log_lines, @card_prefix, @names).pair_recency end end end