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.



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

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.



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

def config_yml
  @config_yml
end

#raw_hashObject (readonly)

Returns the value of attribute raw_hash.



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

def raw_hash
  @raw_hash
end

Class Method Details

.from_hash(raw_hash) ⇒ Object



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

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

.from_yml(config_yml) ⇒ Object



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

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

  new(
    config_yml: config_yml,
    raw_hash: hash
  )
end

.register_pluginsObject



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

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?



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

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

#hashObject



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

def hash
  name.hash
end

#nameObject



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

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

#to_tagObject



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

def to_tag
  CodeTeams.tag_value_for(name)
end