Class: Fulmar::Domain::Service::ConfigurationService
- Inherits:
-
Object
- Object
- Fulmar::Domain::Service::ConfigurationService
- Includes:
- Singleton
- Defined in:
- lib/fulmar/domain/service/configuration_service.rb
Overview
Loads and prepares the configuration from the yaml file TODO: Clone target configuration when used as a parameter to another service so an environment change won’t affect it Not Sure if that is actually a god idea
Constant Summary collapse
- FULMAR_FILE =
'Fulmarfile'- FULMAR_CONFIGURATION =
'FulmarConfiguration'- FULMAR_CONFIGURATION_DIR =
'Fulmar'- DEPLOYMENT_CONFIG_FILE =
'deployment.yml'- BLANK_CONFIG =
{ project: {}, environments: {}, features: {}, hosts: {}, }
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#load_user_config ⇒ Object
Returns the value of attribute load_user_config.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #base_path ⇒ Object
- #config_files ⇒ Object
- #configuration ⇒ Object
-
#initialize ⇒ ConfigurationService
constructor
A new instance of ConfigurationService.
-
#merge(other) ⇒ Object
Merge another configuration into the currently active one Useful for supplying a default configuration, as values are not overwritten.
-
#reset ⇒ Object
Reset the loaded configuration, forcing a reload this is currently used for reloading the config without the user config file to test the project configuration.
Constructor Details
#initialize ⇒ ConfigurationService
Returns a new instance of ConfigurationService.
31 32 33 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 31 def initialize @load_user_config = true end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
29 30 31 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 29 def debug @debug end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
28 29 30 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 28 def environment @environment end |
#load_user_config ⇒ Object
Returns the value of attribute load_user_config.
29 30 31 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 29 def load_user_config @load_user_config end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
28 29 30 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 28 def target @target end |
Instance Method Details
#base_path ⇒ Object
35 36 37 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 35 def base_path @base_path ||= lookup_base_path end |
#config_files ⇒ Object
52 53 54 55 56 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 52 def config_files files = Dir.glob(File.join(base_path, FULMAR_CONFIGURATION_DIR, '*.config.yml')).sort files << "#{ENV['HOME']}/.fulmar.yml" if File.exist?("#{ENV['HOME']}/.fulmar.yml") && @load_user_config files end |
#configuration ⇒ Object
39 40 41 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 39 def configuration @config ||= load_configuration end |
#merge(other) ⇒ Object
Merge another configuration into the currently active one Useful for supplying a default configuration, as values are not overwritten. Hashes are merged.
47 48 49 50 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 47 def merge(other) return unless @environment && @target configuration[:environments][@environment][@target] = other.deep_merge(configuration[:environments][@environment][@target]) end |
#reset ⇒ Object
Reset the loaded configuration, forcing a reload this is currently used for reloading the config without the user config file to test the project configuration
61 62 63 |
# File 'lib/fulmar/domain/service/configuration_service.rb', line 61 def reset @config = nil end |