Class: CarthageCache::Configurator
- Inherits:
-
Object
- Object
- CarthageCache::Configurator
- Defined in:
- lib/carthage_cache/configurator.rb
Constant Summary collapse
- CONFIG_FILE_NAME =
".carthage_cache.yml"
Instance Attribute Summary collapse
-
#base_config ⇒ Object
readonly
Returns the value of attribute base_config.
-
#config_file_path ⇒ Object
readonly
Returns the value of attribute config_file_path.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(project_path, base_config = {}) ⇒ Configurator
constructor
A new instance of Configurator.
- #save_config(config) ⇒ Object
Constructor Details
#initialize(project_path, base_config = {}) ⇒ Configurator
Returns a new instance of Configurator.
12 13 14 15 |
# File 'lib/carthage_cache/configurator.rb', line 12 def initialize(project_path, base_config = {}) @config_file_path = File.join(project_path, CONFIG_FILE_NAME) @base_config = default_configuration.merge(base_config) end |
Instance Attribute Details
#base_config ⇒ Object (readonly)
Returns the value of attribute base_config.
10 11 12 |
# File 'lib/carthage_cache/configurator.rb', line 10 def base_config @base_config end |
#config_file_path ⇒ Object (readonly)
Returns the value of attribute config_file_path.
9 10 11 |
# File 'lib/carthage_cache/configurator.rb', line 9 def config_file_path @config_file_path end |
Instance Method Details
#config ⇒ Object
17 18 19 |
# File 'lib/carthage_cache/configurator.rb', line 17 def config @config ||= load_config end |
#save_config(config) ⇒ Object
21 22 23 24 25 |
# File 'lib/carthage_cache/configurator.rb', line 21 def save_config(config) if valid?(config) File.open(config_file_path, 'w') { |f| f.write config.to_yaml } end end |