Sha256: 758beaa31267907dc2f3d32b2f4abece52e6fa6d027b75bc3e7411e75c0debd1

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

class VagrantWizard::PromptParser
  attr_reader :output
  attr_reader :key
  attr_accessor :advanced

  def initialize(prompt)
    @prompt = prompt
    @advanced = false
    @key = @prompt['key']
    @output = nil
  end

  def prompt
    promptType = @prompt['type']
    promptQuestion = @prompt['prompt']

    begin
      require "vagrant-wizard/inputs/#{promptType}"
    rescue LoadError
      puts "Unable to process input type '#{promptType}'"
      if @prompt.key?('default')
        @output = @prompt['default']
      end
      exit
    end

    className = Object.const_get("VagrantWizard::#{promptType.capitalize}")
    prompt = className.new(promptQuestion, @prompt)

    if @prompt.key?('advanced') && @advanced == false
      if @prompt['advanced'] == true
        prompt.silent = true
      end
    end

    @output = prompt.prompt()
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-wizard-0.3.0 lib/vagrant-wizard/prompt-parser.rb