Class: StateSync::Configuration

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

Constant Summary collapse

PROVIDERS =
%i[github gitlab].freeze
DATA_FORMATS =
%i[struct hash].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
# File 'lib/state_sync/configuration.rb', line 7

def initialize
  @provider    = :github
  @data_format = :struct
end

Instance Attribute Details

#data_formatObject

Returns the value of attribute data_format.



5
6
7
# File 'lib/state_sync/configuration.rb', line 5

def data_format
  @data_format
end

#providerObject

Returns the value of attribute provider.



5
6
7
# File 'lib/state_sync/configuration.rb', line 5

def provider
  @provider
end

#repoObject

Returns the value of attribute repo.



5
6
7
# File 'lib/state_sync/configuration.rb', line 5

def repo
  @repo
end

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/state_sync/configuration.rb', line 5

def token
  @token
end

Instance Method Details

#validate!Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/state_sync/configuration.rb', line 12

def validate!
  unless PROVIDERS.include?(provider)
    raise StateSync::ConfigurationError, "provider must be :github or :gitlab"
  end

  raise StateSync::ConfigurationError, "repo must be set (e.g. \"owner/repo\")" if repo.nil? || repo.strip.empty?

  unless DATA_FORMATS.include?(data_format)
    raise StateSync::ConfigurationError, "data_format must be :struct or :hash"
  end
end