Class: Topo::Provision::ContextGenerator
- Inherits:
-
Object
- Object
- Topo::Provision::ContextGenerator
show all
- Includes:
- Topo::ParseGen
- Defined in:
- lib/topo/provision/generators/context.rb
Constant Summary
collapse
- @@driver_files =
{
'default' =>'chef/provisioning',
'aws' =>'chef/provisioning/aws_driver',
'vagrant' => 'chef/provisioning/vagrant_driver/driver'
}
- @@template =
nil
Instance Method Summary
collapse
#convert_keys_to_sym, #convert_keys_to_sym_deep, #expand_ref, #lazy_attribute_to_s, #topo_refs, #value_from_path
Constructor Details
#initialize(data, default_driver) ⇒ ContextGenerator
Returns a new instance of ContextGenerator.
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/topo/provision/generators/context.rb', line 41
def initialize(data, default_driver)
@driver = data['driver'].split(':', 2).first if data['driver']
@driver ||= default_driver
@require_driver = @@driver_files['default']
if @driver && @@driver_files.key?(@driver)
@require_driver = @@driver_files[@driver]
end
@machine_options = convert_keys_to_sym(data['machine_options']) if data['machine_options']
@driver = data['driver']
end
|
Instance Method Details
#default_action(action) ⇒ Object
56
57
58
|
# File 'lib/topo/provision/generators/context.rb', line 56
def default_action(action)
puts(template.result(binding))
end
|
#deploy ⇒ Object
52
53
54
|
# File 'lib/topo/provision/generators/context.rb', line 52
def deploy()
puts(template.result(binding))
end
|
#template ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/topo/provision/generators/context.rb', line 60
def template()
unless @@template
path = File.expand_path("../templates/context.erb", __FILE__)
@@template = ERB.new(File.new(path).read, nil, '>')
end
@@template
end
|