Class: Vbuilder::Generator::Provider
- Inherits:
-
Object
- Object
- Vbuilder::Generator::Provider
- Defined in:
- lib/vbuilder/generator/provider.rb
Instance Method Summary collapse
- #check_dependencies ⇒ Object
- #get_binding ⇒ Object
-
#initialize(hash) ⇒ Provider
constructor
A new instance of Provider.
- #render(provider) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Provider
Returns a new instance of Provider.
5 6 7 8 9 10 11 |
# File 'lib/vbuilder/generator/provider.rb', line 5 def initialize(hash) @vm_box = nil @ssh_username = nil hash.each do |name, value| instance_variable_set("@#{name}", value) end end |
Instance Method Details
#check_dependencies ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vbuilder/generator/provider.rb', line 26 def check_dependencies installed = `vagrant plugin list` if @meta[:dependencies].count > 0 @meta[:dependencies].each do |dependency| if !installed.include? dependency puts "Unmet dependency" puts "Missing plugin '#{dependency}'" exit 1 end end end end |
#get_binding ⇒ Object
13 14 15 |
# File 'lib/vbuilder/generator/provider.rb', line 13 def get_binding binding() end |
#render(provider) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/vbuilder/generator/provider.rb', line 17 def render(provider) template_file = "../../templates/providers/#{@meta[:provider]}.erb" file = File.(template_file, __FILE__) content = File.read(file) t = ERB.new(content) t.result(binding) end |