Class: Codeowners::Configuration

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

Overview

Stores configuration options for the Codeowners gem.

Defined Under Namespace

Classes: MissingConfigurationError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(organization_name: nil) ⇒ Configuration

Returns a new instance of Configuration.

Parameters:

  • organization_name (String) (defaults to: nil)

    the name of the Github organization



25
26
27
# File 'lib/codeowners/configuration.rb', line 25

def initialize(organization_name: nil)
  self.organization_name = organization_name
end

Class Method Details

.instanceObject



15
16
17
# File 'lib/codeowners/configuration.rb', line 15

def self.instance
  @instance ||= new
end

.reset_singleton_instance!Object



19
20
21
# File 'lib/codeowners/configuration.rb', line 19

def self.reset_singleton_instance!
  @instance = nil
end

Instance Method Details

#organization_nameString

The organization name for teams

Returns:

  • (String)

    the name of the organization

Raises:



32
33
34
35
36
# File 'lib/codeowners/configuration.rb', line 32

def organization_name
  raise MissingConfigurationError, 'Organization name is required' if @organization_name.nil?

  @organization_name.dup
end

#organization_name=(value) ⇒ Object

Set the default organization name for teams

Parameters:

  • value (String)

    the name of the organization



41
42
43
44
45
# File 'lib/codeowners/configuration.rb', line 41

def organization_name=(value)
  value = value.to_s.dup
  value.prepend(AT_PREFIX) unless value.start_with?(AT_PREFIX)
  @organization_name = value
end