Class: CodeTeams::Team

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_yml:, raw_hash:) ⇒ Team

Returns a new instance of Team.



119
120
121
122
# File 'lib/code_teams.rb', line 119

def initialize(config_yml:, raw_hash:)
  @config_yml = config_yml
  @raw_hash = raw_hash
end

Instance Attribute Details

#config_ymlObject (readonly)

Returns the value of attribute config_yml.



111
112
113
# File 'lib/code_teams.rb', line 111

def config_yml
  @config_yml
end

#raw_hashObject (readonly)

Returns the value of attribute raw_hash.



108
109
110
# File 'lib/code_teams.rb', line 108

def raw_hash
  @raw_hash
end

Class Method Details

.from_hash(raw_hash) ⇒ Object



89
90
91
92
93
94
# File 'lib/code_teams.rb', line 89

def self.from_hash(raw_hash)
  new(
    config_yml: nil,
    raw_hash: raw_hash
  )
end

.from_yml(config_yml) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/code_teams.rb', line 79

def self.from_yml(config_yml)
  hash = YAML.load_file(config_yml)

  new(
    config_yml: config_yml,
    raw_hash: hash
  )
end

.register_pluginsObject



97
98
99
100
101
102
103
104
105
# File 'lib/code_teams.rb', line 97

def self.register_plugins
  Plugin.all_plugins.each do |plugin|
    # e.g., def github (on Team)
    define_method(plugin.data_accessor_name) do
      # e.g., MyGithubPlugin.for(team).github
      plugin.for(T.cast(self, Team)).public_send(plugin.data_accessor_name)
    end
  end
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



135
136
137
138
139
140
141
# File 'lib/code_teams.rb', line 135

def ==(other)
  if other.is_a?(CodeTeams::Team)
    name == other.name
  else
    false
  end
end

#hashObject



146
147
148
# File 'lib/code_teams.rb', line 146

def hash
  name.hash
end

#nameObject



125
126
127
# File 'lib/code_teams.rb', line 125

def name
  Plugins::Identity.for(self).identity.name
end

#to_tagObject



130
131
132
# File 'lib/code_teams.rb', line 130

def to_tag
  CodeTeams.tag_value_for(name)
end