class Contributor::Calc::Commit
Constants
- COMMAND
Attributes
result[R]
Public Class Methods
new()
click to toggle source
# File lib/contributor/calc/commit.rb, line 8 def initialize @result = Hash.new { |h, k| h[k] = 0 } end
Public Instance Methods
run()
click to toggle source
# File lib/contributor/calc/commit.rb, line 12 def run authors = Contributor.configuration.authors execute_command.each do |name, count| author = authors.find { |author| author.alias_names.include?(name) } raise "Missing author configuration #{name}" unless author @result[author] += count end end
Private Instance Methods
execute_command()
click to toggle source
# File lib/contributor/calc/commit.rb, line 24 def execute_command terms = Contributor.configuration.terms command = sprintf( COMMAND, beginning_at: terms['beginning_at'].to_s, end_at: terms['end_at'].to_s ) list = `#{command}`.split("\n") list.each_with_object({}) do |line, memo| if /^\s*(?<count>\d+)\s*(?<name>.*)\s*$/ =~ line memo[name] = count.to_i end end end