Class: Loom::Config
- Inherits:
-
Object
- Object
- Loom::Config
- Defined in:
- lib/loom/config.rb
Defined Under Namespace
Classes: FileManager
Constant Summary collapse
- CONFIG_VARS =
TODO: Add a more module config_var registry mechanism for Modules and FactProviders to register their own values & defaults.
{ :loom_search_paths => ['/etc/loom', File.join(ENV['HOME'], '.loom'), './.loom'], :loom_files => ['site.loom'], :inventory_all_hosts => false, :inventory_hosts => [], :inventory_groups => [], :log_level => :warn, # [debug, info, warn, error, fatal, or Integer] :log_device => :stderr, # [stderr, stdout, file descriptor, or file name] :log_colorize => true, :run_failure_strategy => :exclude_host, # [exclude_host, fail_fast, cowboy] :run_verbose => false, :sshkit_execution_strategy => :sequence, # [sequence, parallel, groups] :sshkit_log_level => :warn, }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #files ⇒ Object
-
#initialize(**config_map) ⇒ Config
constructor
A new instance of Config.
- #to_yaml ⇒ Object (also: #dump)
Constructor Details
#initialize(**config_map) ⇒ Config
Returns a new instance of Config.
33 34 35 36 37 38 39 40 41 |
# File 'lib/loom/config.rb', line 33 def initialize(**config_map) config_map.each do |k,v| # allows attr_reader methods from CONFIG_VAR to work instance_variable_set :"@#{k}", v end @config_map = config_map @file_manager = FileManager.new self end |
Class Method Details
.configure(config = nil) {|config_struct| ... } ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/loom/config.rb', line 57 def configure(config=nil, &block) # do NOT call Loom.log inside this block, the logger may not be # configured, triggering an infinite recursion map = config ? config.config_map : CONFIG_VARS.dup config_struct = OpenStruct.new **map yield config_struct if block_given? Config.new config_struct.to_h end |
Instance Method Details
#[](key) ⇒ Object
43 44 45 |
# File 'lib/loom/config.rb', line 43 def [](key) @config_map[key] end |
#files ⇒ Object
52 53 54 |
# File 'lib/loom/config.rb', line 52 def files @file_manager end |
#to_yaml ⇒ Object Also known as: dump
47 48 49 |
# File 'lib/loom/config.rb', line 47 def to_yaml @config_map.to_yaml end |