class Chef::Topo::Converter
Base converter
Attributes
input[RW]
Public Class Methods
convert(format, data)
click to toggle source
# File lib/chef/topo/converter.rb, line 51 def self.convert(format, data) converter = self.converter(format) converter.convert(data) end
converter(format)
click to toggle source
Get the right converter for the input format
# File lib/chef/topo/converter.rb, line 36 def self.converter(format) converter_class = @@converter_classes[format] converter_class = load_converter(format) unless converter_class Object.const_get(converter_class).new(format) end
load_converter(format)
click to toggle source
# File lib/chef/topo/converter.rb, line 43 def self.load_converter(format) require "chef/topo/converter/#{format}" @@converter_classes[format] rescue LoadError STDERR.puts("#{format} is not a known format for the topology file") exit(1) end
new(format, data = nil)
click to toggle source
# File lib/chef/topo/converter.rb, line 58 def initialize(format, data = nil) @format = format @input = data @output = { 'nodes' => [] } end
register_converter(format, class_name)
click to toggle source
# File lib/chef/topo/converter.rb, line 31 def self.register_converter(format, class_name) @@converter_classes[format] = class_name end
Public Instance Methods
convert(data = nil)
click to toggle source
# File lib/chef/topo/converter.rb, line 68 def convert(data = nil) @input = data if data @output = @input @output end