Sha256: a16174fd5fee11adcdb6acdeff88b431fdb09c2e10223eab887a4840926ab4d0

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require 'erb'

module Veewee
  module Builder
    module Vmfusion

      module BoxHelper
      class ErbBinding < OpenStruct
        def get_binding
          return binding()
        end
      end

      def vmx_template(definition)
        # We only want specific variables for ERB

        data = {
          :cpu_count => definition.cpu_count, :memory_size => definition.memory_size,
          :controller_type => "lsilogic",
          :fusion_os_type => definition.os_type_id,
          :mac_addres => "auto generated",
          :iso_file => "#{File.join(env.config.veewee.iso_dir,definition.iso_file)}",
          :box_name => name,
          :vnc_port => vnc_port
        }

        vars = ErbBinding.new(data)
        template_path=File.join(File.dirname(__FILE__),"template.vmx.erb")
        template=File.open(template_path).readlines.join
        erb = ERB.new(template)
        vars_binding = vars.send(:get_binding)
        result=erb.result(vars_binding)
        return result
      end
    end

  end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veewee-0.3.0.alpha4 lib/veewee/builder/vmfusion/helper/template.rb
veewee-0.3.0.alpha3 lib/veewee/builder/vmfusion/helper/template.rb
veewee-0.3.0.alpha2 lib/veewee/builder/vmfusion/helper/template.rb
veewee-0.3.0.alpha1 lib/veewee/builder/vmfusion/helper/template.rb