Module: Laborantin::Metaprog::Configurable
- Included in:
- Environment, Runner, Scenario
- Defined in:
- lib/laborantin/core/configurable.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
A hash placeholder for extra config (e.g. git revision for the git implementation).
Instance Method Summary collapse
- #config_path ⇒ Object
-
#load_config!(path = config_path) ⇒ Object
restore the configuration from the config file.
-
#save_config ⇒ Object
saves the @config in a YAML config file.
Instance Attribute Details
#config ⇒ Object
A hash placeholder for extra config (e.g. git revision for the git implementation)
6 7 8 |
# File 'lib/laborantin/core/configurable.rb', line 6 def config @config end |
Instance Method Details
#config_path ⇒ Object
23 24 25 |
# File 'lib/laborantin/core/configurable.rb', line 23 def config_path "config.yaml" end |
#load_config!(path = config_path) ⇒ Object
restore the configuration from the config file
16 17 18 19 20 21 |
# File 'lib/laborantin/core/configurable.rb', line 16 def load_config!(path=config_path) if File.file?(path) @config = YAML.load_file(path) end @config ||= {} end |
#save_config ⇒ Object
saves the @config in a YAML config file
9 10 11 12 13 |
# File 'lib/laborantin/core/configurable.rb', line 9 def save_config File.open(config_path, 'w') do |f| f.puts YAML.dump(config) end end |