Class: Codeowners::Owner

Inherits:
Object
  • Object
show all
Defined in:
lib/codeowners/owner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_string) ⇒ Owner

Returns a new instance of Owner.

Parameters:

  • name_string (String)

    Name of team in CODEOWNERS file (e.g. ‘“@meetcleo/chat”`)



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

#nameString (readonly) Also known as: long_name

Name of team in CODEOWNERS file (e.g. @meetcleo/chat)

Returns:

  • (String)


10
11
12
# File 'lib/codeowners/owner.rb', line 10

def name
  @name
end

#short_nameString (readonly)

Name of team in config files (e.g. chat)

Returns:

  • (String)


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?

Returns:

  • (Boolean)


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_nameString

Prefix for team names in the CODEOWNERS file

Returns:

  • (String)


27
# File 'lib/codeowners/owner.rb', line 27

def organization_name = Configuration.instance.organization_name

#to_sObject



36
37
38
# File 'lib/codeowners/owner.rb', line 36

def to_s
  name.gsub(organization_name, '')
end