Class: Codeowners::Owner
- Inherits:
-
Object
- Object
- Codeowners::Owner
- Defined in:
- lib/codeowners/owner.rb
Instance Attribute Summary collapse
-
#name ⇒ String
(also: #long_name)
readonly
Name of team in CODEOWNERS file (e.g. @meetcleo/chat).
-
#short_name ⇒ String
readonly
Name of team in config files (e.g. chat).
Instance Method Summary collapse
-
#initialize(name_string) ⇒ Owner
constructor
A new instance of Owner.
-
#match?(compare_string) ⇒ Boolean
Does this string match the name of the owner?.
-
#organization_name ⇒ String
Prefix for team names in the CODEOWNERS file.
- #to_s ⇒ Object
Constructor Details
#initialize(name_string) ⇒ Owner
Returns a new instance of Owner.
19 20 21 22 23 |
# File 'lib/codeowners/owner.rb', line 19 def initialize(name_string) name_string = "#{organization_name}/#{name_string}" unless name_string.start_with?(organization_name) @name = name_string @short_name = name_string.split('/').last end |
Instance Attribute Details
#name ⇒ String (readonly) Also known as: long_name
Name of team in CODEOWNERS file (e.g. @meetcleo/chat)
10 11 12 |
# File 'lib/codeowners/owner.rb', line 10 def name @name end |
#short_name ⇒ String (readonly)
Name of team in config files (e.g. chat)
16 17 18 |
# File 'lib/codeowners/owner.rb', line 16 def short_name @short_name end |
Instance Method Details
#match?(compare_string) ⇒ Boolean
Does this string match the name of the owner?
31 32 33 34 |
# File 'lib/codeowners/owner.rb', line 31 def match?(compare_string) compare_string = "#{organization_name}/#{compare_string}" unless compare_string.start_with?(organization_name) name == compare_string.to_s.downcase end |
#organization_name ⇒ String
Prefix for team names in the CODEOWNERS file
27 |
# File 'lib/codeowners/owner.rb', line 27 def organization_name = Configuration.instance.organization_name |
#to_s ⇒ Object
36 37 38 |
# File 'lib/codeowners/owner.rb', line 36 def to_s name.gsub(organization_name, '') end |