Class: KnifeTopo::Processor
- Inherits:
-
Object
- Object
- KnifeTopo::Processor
- Defined in:
- lib/chef/knife/topo/processor.rb
Overview
Base processor
Direct Known Subclasses
Constant Summary collapse
- @@processor_classes =
rubocop:disable Style/ClassVars
{}
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
Class Method Summary collapse
- .for_topo(topo) ⇒ Object
- .load_processor(strategy) ⇒ Object
-
.processor(topo) ⇒ Object
Get the right processor.
- .register_processor(strategy, class_name) ⇒ Object
Instance Method Summary collapse
- #generate_artifacts(_context = {}) ⇒ Object
- #generate_nodes ⇒ Object
-
#initialize(topo) ⇒ Processor
constructor
A new instance of Processor.
- #upload_artifacts(_context = {}) ⇒ Object
Constructor Details
#initialize(topo) ⇒ Processor
Returns a new instance of Processor.
57 58 59 |
# File 'lib/chef/knife/topo/processor.rb', line 57 def initialize(topo) @topo = topo end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
55 56 57 |
# File 'lib/chef/knife/topo/processor.rb', line 55 def input @input end |
Class Method Details
.for_topo(topo) ⇒ Object
51 52 53 |
# File 'lib/chef/knife/topo/processor.rb', line 51 def self.for_topo(topo) processor(topo) end |
.load_processor(strategy) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/chef/knife/topo/processor.rb', line 43 def self.load_processor(strategy) require "chef/knife/topo/processor/#{strategy}" @@processor_classes[strategy] rescue LoadError STDERR.puts("#{strategy} is not a known strategy") exit(1) end |
.processor(topo) ⇒ Object
Get the right processor
35 36 37 38 39 40 41 |
# File 'lib/chef/knife/topo/processor.rb', line 35 def self.processor(topo) strategy = topo.strategy processor_class = @@processor_classes[strategy] processor_class = load_processor(strategy) unless processor_class Object.const_get(processor_class).new(topo) end |
.register_processor(strategy, class_name) ⇒ Object
30 31 32 |
# File 'lib/chef/knife/topo/processor.rb', line 30 def self.register_processor(strategy, class_name) @@processor_classes[strategy] = class_name end |
Instance Method Details
#generate_artifacts(_context = {}) ⇒ Object
68 69 70 |
# File 'lib/chef/knife/topo/processor.rb', line 68 def generate_artifacts(_context = {}) {} end |
#generate_nodes ⇒ Object
64 65 66 |
# File 'lib/chef/knife/topo/processor.rb', line 64 def generate_nodes @topo.merged_nodes end |
#upload_artifacts(_context = {}) ⇒ Object
72 73 |
# File 'lib/chef/knife/topo/processor.rb', line 72 def upload_artifacts(_context = {}) end |