Class: CarthageCacheRes::Configurator
- Inherits:
-
Object
- Object
- CarthageCacheRes::Configurator
- Defined in:
- lib/carthage_cache_res/configurator.rb
Constant Summary collapse
- CONFIG_FILE_NAME =
".carthage_cache_res.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.
-
#terminal ⇒ Object
readonly
Returns the value of attribute terminal.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(terminal, project_path, base_config = {}) ⇒ Configurator
constructor
A new instance of Configurator.
- #save_config(config) ⇒ Object
Constructor Details
#initialize(terminal, project_path, base_config = {}) ⇒ Configurator
Returns a new instance of Configurator.
13 14 15 16 17 |
# File 'lib/carthage_cache_res/configurator.rb', line 13 def initialize(terminal, project_path, base_config = {}) @config_file_path = File.join(project_path, CONFIG_FILE_NAME) @base_config = merge_config(base_config) @terminal = terminal end |
Instance Attribute Details
#base_config ⇒ Object (readonly)
Returns the value of attribute base_config.
10 11 12 |
# File 'lib/carthage_cache_res/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_res/configurator.rb', line 9 def config_file_path @config_file_path end |
#terminal ⇒ Object (readonly)
Returns the value of attribute terminal.
11 12 13 |
# File 'lib/carthage_cache_res/configurator.rb', line 11 def terminal @terminal end |
Instance Method Details
#config ⇒ Object
19 20 21 |
# File 'lib/carthage_cache_res/configurator.rb', line 19 def config @config ||= load_config! end |
#save_config(config) ⇒ Object
23 24 25 26 |
# File 'lib/carthage_cache_res/configurator.rb', line 23 def save_config(config) raise "Invalid configuration" unless config.valid? File.open(config_file_path, 'w') { |f| f.write config.to_yaml } end |