Class: CodeTeams::Plugin

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/code_teams/plugin.rb

Overview

Plugins allow a client to add validation on custom keys in the team YML. For now, only a single plugin is allowed to manage validation on a top-level key. In the future we can think of allowing plugins to be gracefully merged with each other.

Direct Known Subclasses

CodeTeams::Plugins::Identity

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(team) ⇒ Plugin

Returns a new instance of Plugin.



14
15
16
# File 'lib/code_teams/plugin.rb', line 14

def initialize(team)
  @team = team
end

Class Method Details

.all_pluginsObject



24
25
26
27
28
# File 'lib/code_teams/plugin.rb', line 24

def self.all_plugins
  @all_plugins ||= T.let(@all_plugins, T.nilable(T::Array[T.class_of(Plugin)]))
  @all_plugins ||= []
  @all_plugins
end

.bust_caches!Object



65
66
67
# File 'lib/code_teams/plugin.rb', line 65

def self.bust_caches!
  all_plugins.each(&:clear_team_registry!)
end

.clear_team_registry!Object



70
71
72
# File 'lib/code_teams/plugin.rb', line 70

def self.clear_team_registry!
  @registry = nil
end

.for(team) ⇒ Object



36
37
38
# File 'lib/code_teams/plugin.rb', line 36

def self.for(team)
  register_team(team)
end

.inherited(base) ⇒ Object

rubocop:disable Lint/MissingSuper



19
20
21
# File 'lib/code_teams/plugin.rb', line 19

def self.inherited(base) # rubocop:disable Lint/MissingSuper
  all_plugins << T.cast(base, T.class_of(Plugin))
end

.missing_key_error_message(team, key) ⇒ Object



41
42
43
# File 'lib/code_teams/plugin.rb', line 41

def self.missing_key_error_message(team, key)
  "#{team.name} is missing required key `#{key}`"
end

.validation_errors(teams) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



31
32
33
# File 'lib/code_teams/plugin.rb', line 31

def self.validation_errors(teams) # rubocop:disable Lint/UnusedMethodArgument
  []
end