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.
90 91 92 93 |
# File 'lib/nexus_cli/configuration.rb', line 90 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
34 35 36 37 38 39 |
# File 'lib/nexus_cli/configuration.rb', line 34 def from_file config = load_config 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 26 27 28 |
# File 'lib/nexus_cli/configuration.rb', line 21 def from_overrides(overrides) raise MissingSettingsFileException unless overrides overrides = overrides.with_indifferent_access configuration = (load_config || Hash.new).with_indifferent_access configuration.merge!(overrides) new(configuration) end |
.validate!(config) ⇒ Object
Validates an instance of the Configuration object and raises when there is an error with it
47 48 49 50 51 |
# File 'lib/nexus_cli/configuration.rb', line 47 def validate!(config) unless config.valid? raise InvalidSettingsException.new(config.errors) end end |
Instance Method Details
#validate! ⇒ Object
67 68 69 |
# File 'lib/nexus_cli/configuration.rb', line 67 def validate! self.class.validate!(self) end |