Class: NexusCli::Configuration
- Inherits:
-
Object
- Object
- NexusCli::Configuration
- Includes:
- Chozo::VariaModel
- Defined in:
- lib/nexus_cli/configuration.rb
Constant Summary collapse
- DEFAULT_FILE =
(ENV['HOME'] ? "~/.nexus_cli" : "/root/.nexus_cli").freeze
Class Method Summary collapse
-
.file_path ⇒ String
The filepath to the nexus cli configuration file.
-
.from_file ⇒ NexusCli::Configuration
Creates a new instance of the Configuration object from the config file.
-
.from_overrides(overrides) ⇒ NexusCli::Configuration
Creates a new instance of the Configuration object based on some overrides.
-
.validate!(config) ⇒ Object
Validates an instance of the Configuration object and raises when there is an error with it.
Instance Method Summary collapse
-
#initialize(options) ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize(options) ⇒ Configuration
Returns a new instance of Configuration.
75 76 77 78 |
# File 'lib/nexus_cli/configuration.rb', line 75 def initialize() mass_assign() self.repository = [:repository] end |
Class Method Details
.file_path ⇒ String
The filepath to the nexus cli configuration file
12 13 14 |
# File 'lib/nexus_cli/configuration.rb', line 12 def file_path File.(ENV['NEXUS_CONFIG'] || File.(DEFAULT_FILE)) end |
.from_file ⇒ NexusCli::Configuration
Creates a new instance of the Configuration object from the config file
31 32 33 34 35 36 37 |
# File 'lib/nexus_cli/configuration.rb', line 31 def from_file config = YAML.load_file(file_path) raise MissingSettingsFileException unless config config = config.with_indifferent_access new(config) end |
.from_overrides(overrides) ⇒ NexusCli::Configuration
Creates a new instance of the Configuration object based on some overrides
21 22 23 24 25 |
# File 'lib/nexus_cli/configuration.rb', line 21 def from_overrides(overrides) raise MissingSettingsFileException unless overrides overrides = overrides.with_indifferent_access new(overrides) end |
.validate!(config) ⇒ Object
Validates an instance of the Configuration object and raises when there is an error with it
45 46 47 48 49 |
# File 'lib/nexus_cli/configuration.rb', line 45 def validate!(config) unless config.valid? raise InvalidSettingsException.new(config.errors) end end |
Instance Method Details
#validate! ⇒ Object
52 53 54 |
# File 'lib/nexus_cli/configuration.rb', line 52 def validate! self.class.validate!(self) end |