Class: Codeowners::Guess

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

Instance Method Summary collapse

Constructor Details

#initialize(owners, contributors, storage, base_directory, out) ⇒ Guess

Returns a new instance of Guess.



5
6
7
8
9
10
11
# File 'lib/codeowners/guess.rb', line 5

def initialize(owners, contributors, storage, base_directory, out)
  @owners = owners
  @contributors = contributors
  @storage = storage
  @base_directory = ::File.expand_path(base_directory)
  @out = out
end

Instance Method Details

#call(file, debug) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/codeowners/guess.rb', line 13

def call(file, debug)
  result = {}

  Dir.chdir(base_directory) do
    Dir.glob(file).sort.each do |f|
      *teams, codeowners = list_code_owners(f, debug)
      *teams, codeowners = guess_code_owners(f, debug) unless codeowners
      teams ||= []

      result[f] = { teams: teams, codeowners: codeowners }
    end
  end

  result
end