Class: StateSync::Configuration
- Inherits:
-
Object
- Object
- StateSync::Configuration
- 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
-
#data_format ⇒ Object
Returns the value of attribute data_format.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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_format ⇒ Object
Returns the value of attribute data_format.
5 6 7 |
# File 'lib/state_sync/configuration.rb', line 5 def data_format @data_format end |
#provider ⇒ Object
Returns the value of attribute provider.
5 6 7 |
# File 'lib/state_sync/configuration.rb', line 5 def provider @provider end |
#repo ⇒ Object
Returns the value of attribute repo.
5 6 7 |
# File 'lib/state_sync/configuration.rb', line 5 def repo @repo end |
#token ⇒ Object
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 |