Class: CodeOwnership::Private::OwnershipMappers::PackageOwnership

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Mapper
Defined in:
lib/code_ownership/private/ownership_mappers/package_ownership.rb

Instance Method Summary collapse

Methods included from Mapper

all, included, to_glob_cache

Instance Method Details

#bust_caches!Object



69
# File 'lib/code_ownership/private/ownership_mappers/package_ownership.rb', line 69

def bust_caches!; end

#descriptionObject



46
47
48
# File 'lib/code_ownership/private/ownership_mappers/package_ownership.rb', line 46

def description
  'Owner metadata key in package.yml'
end

#globs_to_owner(files) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/code_ownership/private/ownership_mappers/package_ownership.rb', line 36

def globs_to_owner(files)
  Packs.all.each_with_object({}) do |package, res|
    owner = owner_for_package(package)
    next if owner.nil?

    res[package.relative_path.join('**/**').to_s] = owner
  end
end

#map_file_to_owner(file) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/code_ownership/private/ownership_mappers/package_ownership.rb', line 16

def map_file_to_owner(file)
  package = Packs.for_file(file)

  return nil if package.nil?

  owner_for_package(package)
end

#owner_for_package(package) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/code_ownership/private/ownership_mappers/package_ownership.rb', line 58

def owner_for_package(package)
  raw_owner_value = package.raw_hash['owner'] || package.['owner']
  return nil if !raw_owner_value

  Private.find_team!(
    raw_owner_value,
    package.yml.to_s
  )
end

#update_cache(cache, files) ⇒ Object



53
54
55
# File 'lib/code_ownership/private/ownership_mappers/package_ownership.rb', line 53

def update_cache(cache, files)
  globs_to_owner(files)
end