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'], :loom_file_patterns => ['*.loom'], :loomfile_autoloads => [ 'loomext/corefacts', 'loomext/coremods', ], :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
TODO: disallow CONFIG_VAR properties named after Config methods.…
-
#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.
39 40 41 42 43 44 45 46 47 |
# File 'lib/loom/config.rb', line 39 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
65 66 67 68 69 70 71 72 73 |
# File 'lib/loom/config.rb', line 65 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
49 50 51 |
# File 'lib/loom/config.rb', line 49 def [](key) @config_map[key] end |
#files ⇒ Object
TODO: disallow CONFIG_VAR properties named after Config methods.… like files. this is shitty, but I don’t want to do a larger change.
60 61 62 |
# File 'lib/loom/config.rb', line 60 def files @file_manager end |
#to_yaml ⇒ Object Also known as: dump
53 54 55 |
# File 'lib/loom/config.rb', line 53 def to_yaml @config_map.to_yaml end |