lib/pair_see/seer.rb in pair_see-0.1.2 vs lib/pair_see/seer.rb in pair_see-0.1.3

- old
+ new

@@ -3,50 +3,43 @@ 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' attr_reader :log_lines, :devs, :dev_pairs, :card_prefix + @@maximum_commits_to_parse = 9999 def initialize(options) - @log_lines = _lines_from(options[:repo_location], options[:after_date]) - @devs = _active(options[:names]) + @log_lines = _lines_from(options[:repo_location], options[:after_date]) + @sub_seer = CardsPerPerson.new(@log_lines, options) + @active_devs = ActiveDevs.new(@log_lines, options).devs + @devs = @sub_seer.devs @card_prefix = options[:card_prefix] @dev_pairs = devs.combination(2) end - def _active(devs) - devs.select do |dev| - _is_active?(dev) - end - end +# seer.commits_not_by_known_pair +# seer.all_most_recent_commits +# seer.recommended_pairings +# seer.pretty_card_data +# seer.cards_per_person +# seer.all_commits - def _lines_from(repo, after_date) - LogLines.new(repo, after_date) - 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 + @sub_seer.cards_per_person 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(@card_prefix) - end.compact + def _lines_from(git_home, date_string) + g = Git.open(git_home) + lines = g.log(@@maximum_commits_to_parse).since(date_string).map do |l| + LogLine.new("#{l.date} #{l.message}") + end + LogLines.new(lines) end def pretty_card_data card_data(card_prefix).map do |card| "#{card.card_name} - - - commits: #{card.number_of_commits} - - - duration: #{card.duration} days " unless card.nil? @@ -76,21 +69,13 @@ config = YAML.load_file(config_file) config['card_prefix'] end def active_devs(config_file) - config = YAML.load_file(config_file) - devs_in_config = config['names'].split(' ') - devs_in_config.select do |dev| - _is_active?(dev) - end + @active_devs end - def _is_active?(dev) - log_lines.active? dev - end - def pair_commits dev_pairs.map do |person1, person2| Combo.new(commits_for_pair(person1, person2).count, person1, person2) end end @@ -140,7 +125,7 @@ most_recent_commit_date(person1, person2).nil? end.map do |person1, person2| "#{person1}, #{person2}" end end -end + end end