Class: RubocopDirector::GitLogStats
- Inherits:
-
Object
- Object
- RubocopDirector::GitLogStats
- Defined in:
- lib/rubocop_director/git_log_stats.rb
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(since) ⇒ GitLogStats
constructor
A new instance of GitLogStats.
Constructor Details
#initialize(since) ⇒ GitLogStats
Returns a new instance of GitLogStats.
11 12 13 |
# File 'lib/rubocop_director/git_log_stats.rb', line 11 def initialize(since) @since = since end |
Instance Method Details
#fetch ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rubocop_director/git_log_stats.rb', line 15 def fetch stdout, stderr = Open3.capture3("git log --since=\"#{@since}\" --pretty=format: --name-only | sort | uniq -c | sort -rg") return Failure("Failed to fetch git stats: #{stderr}") if stderr.length > 0 stats = stdout.split("\n")[1..].each_with_object({}) do |line, acc| number, path = line.split acc[path] = number.to_i end Success(stats) end |