Module: VagrantPlugins::VagrantJson
- Defined in:
- lib/vagrant-json.rb,
lib/vagrant-json/plugin.rb,
lib/vagrant-json/version.rb,
lib/vagrant-json/config/json.rb,
lib/vagrant-json/command/init.rb,
lib/vagrant-json/command/root.rb
Defined Under Namespace
Modules: Command, Config
Classes: Plugin
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
Class Method Details
.apply_settings(vm, yml) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/vagrant-json.rb', line 12
def self.apply_settings(vm, yml)
yml.each do |key0, value0|
if !value0.is_a?(Hash) vm.send("#{key0}=".to_sym, value0) else method_object = vm.method("#{key0}".to_sym) value0.each do |key1, value1| method_object.call("#{key1}".to_sym, value1) end
end
end
end
|
.source_root ⇒ Object
8
9
10
|
# File 'lib/vagrant-json.rb', line 8
def self.source_root
@source_root ||= Pathname.new(File.expand_path '../../', __FILE__)
end
|
.up!(config) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/vagrant-json.rb', line 25
def self.up!(config)
require 'json'
require 'yaml'
vms = []
if config.directory
end
files = Dir.glob("*.{json,yaml,yml}").map {|f| JSON.parse(YAML.load_file(f).to_json, symbolize_names: true)}
files.each do |file|
if file[:boxes]
vms.concat(file[:boxes])
else
vms << file
end
end
vms.each do |vm|
config.vm.define "#{vm[:hostname]}" do |vm_config|
apply_settings(vm_config.vm, vm)
end
end
end
|