Class: CodeOwnership::Private::OwnershipMappers::TeamYmlOwnership

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

Constant Summary collapse

@@map_files_to_owners =

rubocop:disable Style/ClassVars

{}

Instance Method Summary collapse

Methods included from Mapper

all, included, to_glob_cache

Instance Method Details

#bust_caches!Object



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

def bust_caches!
  @@map_files_to_owners = {} # rubocop:disable Style/ClassVars
end

#descriptionObject



58
59
60
# File 'lib/code_ownership/private/ownership_mappers/team_yml_ownership.rb', line 58

def description
  'Team YML ownership'
end

#globs_to_owner(files) ⇒ Object



39
40
41
42
43
# File 'lib/code_ownership/private/ownership_mappers/team_yml_ownership.rb', line 39

def globs_to_owner(files)
  CodeTeams.all.each_with_object({}) do |team, map|
    map[team.config_yml] = team
  end
end

#map_file_to_owner(file) ⇒ Object



31
32
33
# File 'lib/code_ownership/private/ownership_mappers/team_yml_ownership.rb', line 31

def map_file_to_owner(file)
  map_files_to_owners([file])[file]
end

#map_files_to_owners(files) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/code_ownership/private/ownership_mappers/team_yml_ownership.rb', line 19

def map_files_to_owners(files)
  return @@map_files_to_owners if @@map_files_to_owners&.keys && @@map_files_to_owners.keys.count.positive?

  @@map_files_to_owners = CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
    map[team.config_yml] = team
  end
end

#update_cache(cache, files) ⇒ Object



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

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