Module: CodeTeams
- Extended by:
- T::Sig
- Defined in:
- lib/code_teams/plugin.rb,
lib/code_teams.rb,
lib/code_teams/utils.rb,
lib/code_teams/plugins/identity.rb
Overview
Defined Under Namespace
Modules: Plugins, Utils
Classes: IncorrectPublicApiUsageError, Plugin, Team, TeamNotFoundError
Constant Summary
collapse
- UNKNOWN_TEAM_STRING =
'Unknown Team'
Class Method Summary
collapse
Class Method Details
.all ⇒ Object
22
23
24
|
# File 'lib/code_teams.rb', line 22
def self.all
@all ||= T.let(for_directory('config/teams'), T.nilable(T::Array[Team]))
end
|
.bust_caches! ⇒ Object
67
68
69
70
71
72
|
# File 'lib/code_teams.rb', line 67
def self.bust_caches!
@plugins_registered = false
Plugin.bust_caches!
@all = nil
@index_by_name = nil
end
|
.find(name) ⇒ Object
27
28
29
30
|
# File 'lib/code_teams.rb', line 27
def self.find(name)
@index_by_name ||= T.let(all.to_h { |t| [t.name, t] }, T.nilable(T::Hash[String, CodeTeams::Team]))
@index_by_name[name]
end
|
.find!(name) ⇒ Object
33
34
35
|
# File 'lib/code_teams.rb', line 33
def self.find!(name)
find(name) || raise(TeamNotFoundError, "No team found with name: #{name}")
end
|
.for_directory(dir) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/code_teams.rb', line 38
def self.for_directory(dir)
unless @plugins_registered
Team.register_plugins
@plugins_registered = true
end
Pathname.new(dir).glob('**/*.yml').map do |path|
Team.from_yml(path.to_s)
rescue Psych::SyntaxError
raise IncorrectPublicApiUsageError, "The YML in #{path} has a syntax error!"
end
end
|
.tag_value_for(string) ⇒ Object
59
60
61
|
# File 'lib/code_teams.rb', line 59
def self.tag_value_for(string)
string.tr('&', ' ').gsub(/\s+/, '_').downcase
end
|
.validation_errors(teams) ⇒ Object
52
53
54
55
56
|
# File 'lib/code_teams.rb', line 52
def self.validation_errors(teams)
Plugin.all_plugins.flat_map do |plugin|
plugin.validation_errors(teams)
end
end
|