Class: Codeowners::ListContributors

Inherits:
Object
  • Object
show all
Defined in:
lib/codeowners/list_contributors.rb

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(base_directory, git: Git.new(base_directory)) ⇒ ListContributors

Returns a new instance of ListContributors.



30
31
32
# File 'lib/codeowners/list_contributors.rb', line 30

def initialize(base_directory, git: Git.new(base_directory))
  @git = git
end

Instance Method Details

#call(file, debug = false) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/codeowners/list_contributors.rb', line 34

def call(file, debug = false)
  contributors = @git.contributors(file, debug)
  return Result.new if contributors.empty?

  contributors = contributors.each.lazy.sort_by { |c| -c.insertions }

  Result.new(file, contributors)
end