Class: PEBuild::Provisioner::PEBootstrap::AnswersFile

Inherits:
Object
  • Object
show all
Defined in:
lib/pe_build/provisioner/pe_bootstrap/answers_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(machine, config, work_dir) ⇒ AnswersFile

Returns a new instance of AnswersFile.

Parameters:

  • machine (Vagrant::Machine)
  • config (Object < Vagrant.plugin('2', :config)])

    onfig [Object < Vagrant.plugin(‘2’, :config)]

  • work_dir (String)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pe_build/provisioner/pe_bootstrap/answers_file.rb', line 10

def initialize(machine, config, work_dir)
  @machine, @config = machine, config
  @work_dir = Pathname.new(work_dir)

  @logger = Log4r::Logger.new('vagrant::provisioner::pe_bootstrap::answers_file')

  @answer_dir  = @work_dir.join('answers')
  @output_file = @answer_dir.join "#{@machine.name}.txt"

  set_template_path
end

Instance Method Details

#generateObject



22
23
24
25
26
27
# File 'lib/pe_build/provisioner/pe_bootstrap/answers_file.rb', line 22

def generate
  @logger.info "Writing answers file for #{@machine.inspect} to #{@output_file}"
  @answer_dir.mkpath unless @answer_dir.exist?

  @output_file.open('w') { |fh| fh.write(render_answers) }
end