Module: Patch::Config
Overview
Deal with config files, hashes
Instance Method Summary collapse
- #to_hub(nodes_config, options = {}) ⇒ Hub
-
#to_node_maps(nodes, config) ⇒ Array<Node::Map>
Instantiate Node::Map objects given a map config hash.
-
#to_nodes(config, options = {}) ⇒ Node::Container
Instantiate node objects from the given node config or config file.
-
#to_patches(nodes, config) ⇒ Array<Patch>
Instantiate patch objects from the given patch config file, filename or hash.
Instance Method Details
#to_hub(nodes_config, options = {}) ⇒ Hub
12 13 14 15 16 17 |
# File 'lib/patch/config.rb', line 12 def to_hub(nodes_config, = {}) log = Log.new(.fetch(:log, $>)) unless [:log].nil? nodes = to_nodes(nodes_config, :log => log) patches = to_patches(nodes, [:patches]) unless [:patches].nil? Hub.new(:log => log, :patches => patches) end |
#to_node_maps(nodes, config) ⇒ Array<Node::Map>
Instantiate Node::Map objects given a map config hash
47 48 49 |
# File 'lib/patch/config.rb', line 47 def to_node_maps(nodes, config) config.map { |from, to| get_node_map(nodes, from, to) } end |
#to_nodes(config, options = {}) ⇒ Node::Container
Instantiate node objects from the given node config or config file
37 38 39 40 41 |
# File 'lib/patch/config.rb', line 37 def to_nodes(config, = {}) config = ensure_hash(config) node_array = config[:nodes].map { |node_config| to_node(node_config, ) } Node::Container.new(node_array) end |
#to_patches(nodes, config) ⇒ Array<Patch>
Instantiate patch objects from the given patch config file, filename or hash
23 24 25 26 27 28 29 30 |
# File 'lib/patch/config.rb', line 23 def to_patches(nodes, config) config = ensure_hash(config) patches = [] config[:patches].each do |name, patch_config| patches << to_patch(name, nodes, patch_config) end patches end |