Class: PEBuild::Provisioner::PEBootstrap::AnswersFile Private
- Inherits:
-
Object
- Object
- PEBuild::Provisioner::PEBootstrap::AnswersFile
- Defined in:
- lib/pe_build/provisioner/pe_bootstrap/answers_file.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A sub-provisioner which generates answer file content.
This is an internal provisioner which is invoked by
PEBuild::Provisioner::PEBootstrap
.
Instance Attribute Summary collapse
- #template ⇒ Object readonly private
Instance Method Summary collapse
- #generate ⇒ Object private
-
#initialize(machine, config, work_dir) ⇒ AnswersFile
constructor
private
A new instance of AnswersFile.
- #render_answers ⇒ Object private
Constructor Details
#initialize(machine, config, work_dir) ⇒ AnswersFile
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of AnswersFile.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pe_build/provisioner/pe_bootstrap/answers_file.rb', line 18 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 Attribute Details
#template ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/pe_build/provisioner/pe_bootstrap/answers_file.rb', line 13 def template @template end |
Instance Method Details
#generate ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 |
# File 'lib/pe_build/provisioner/pe_bootstrap/answers_file.rb', line 30 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 |
#render_answers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 44 |
# File 'lib/pe_build/provisioner/pe_bootstrap/answers_file.rb', line 37 def render_answers answer_template = template_data unless @config.answer_extras.empty? answer_template += ("\n" + @config.answer_extras.map {|e| e.to_s}.join("\n") + "\n") end ERB.new(answer_template).result(binding) end |