vagrant-hostel 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  module VagrantHostel
2
- class Command < Vagrant::Command::Base
2
+ class Command < Vagrant.plugin(2, :command)
3
3
  def execute
4
4
  options = {}
5
5
  options[:force] = false
@@ -12,7 +12,15 @@ module VagrantHostel
12
12
  # Parse the options
13
13
  argv = parse_options(opts)
14
14
 
15
- puts "Hello: #{argv}"
15
+ puts "Hostel: #{argv}"
16
+ vm_name = argv[0]
17
+ multiple = argv[1]
18
+ puts "#{@env.methods}"
19
+
20
+ with_target_vms(vm_name) do |vm|
21
+ puts "#{vm.config.vm.host_name}"
22
+ end
23
+
16
24
  0
17
25
  end
18
26
  end
@@ -0,0 +1,82 @@
1
+ module VagrantHostel
2
+ class Config < Vagrant.plugin(2, :config)
3
+ def initialize
4
+ @__defined_vm_keys = []
5
+ @__defined_vms = {}
6
+ @replicants = 1
7
+ end
8
+
9
+ def finalize!
10
+ (0..@replicants-1).each do |i|
11
+ puts i
12
+ end
13
+ end
14
+
15
+ # Below we mimic (i.e. copy & paste) functionality of Vagrant from:
16
+ # VagrantPlugins::Kernel_V2::VMConfig
17
+ #
18
+ # The aim is to provide our own `define` method to use in place of
19
+ # `config.vm.define`
20
+ # -------
21
+
22
+ DEFAULT_VM_NAME = :default
23
+
24
+ def merge(other)
25
+ super.tap do |result|
26
+ # Merge defined VMs by first merging the defined VM keys,
27
+ # preserving the order in which they were defined.
28
+ other_defined_vm_keys = other.instance_variable_get(:@__defined_vm_keys)
29
+ other_defined_vm_keys -= @__defined_vm_keys
30
+ new_defined_vm_keys = @__defined_vm_keys + other_defined_vm_keys
31
+
32
+ # Merge the actual defined VMs.
33
+ other_defined_vms = other.instance_variable_get(:@__defined_vms)
34
+ new_defined_vms = {}
35
+
36
+ @__defined_vms.each do |key, subvm|
37
+ new_defined_vms[key] = subvm.clone
38
+ end
39
+
40
+ other_defined_vms.each do |key, subvm|
41
+ if !new_defined_vms.has_key?(key)
42
+ new_defined_vms[key] = subvm.clone
43
+ else
44
+ new_defined_vms[key].config_procs.concat(subvm.config_procs)
45
+ new_defined_vms[key].options.merge!(subvm.options)
46
+ end
47
+ end
48
+
49
+ result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys)
50
+ result.instance_variable_set(:@__defined_vms, new_defined_vms)
51
+ end
52
+ end
53
+
54
+ def defined_vms
55
+ @__defined_vms
56
+ end
57
+
58
+ # This returns the keys of the sub-vms in the order they were
59
+ # defined.
60
+ def defined_vm_keys
61
+ @__defined_vm_keys
62
+ end
63
+
64
+ def define(name, options=nil, &block)
65
+ name = name.to_sym
66
+ options ||= {}
67
+ options[:config_version] ||= "2"
68
+
69
+ # Add the name to the array of VM keys. This array is used to
70
+ # preserve the order in which VMs are defined.
71
+ @__defined_vm_keys << name if !@__defined_vm_keys.include?(name)
72
+
73
+ # Add the SubVM to the hash of defined VMs
74
+ if !@__defined_vms[name]
75
+ @__defined_vms[name] = VagrantConfigSubVM.new
76
+ end
77
+
78
+ @__defined_vms[name].options.merge!(options)
79
+ @__defined_vms[name].config_procs << [options[:config_version], block] if block
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,15 @@
1
+ module VagrantHostel
2
+ class MyPlugin < Vagrant.plugin("2")
3
+ name "Hostel"
4
+
5
+ command "hostel" do
6
+ require_relative "command"
7
+ Command
8
+ end
9
+
10
+ config "hostel" do
11
+ require_relative "config"
12
+ Config
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module VagrantHostel
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/vagrant_init.rb CHANGED
@@ -7,6 +7,7 @@ rescue LoadError
7
7
  raise "The Vagrant Hostel plugin must be run within Vagrant."
8
8
  end
9
9
 
10
- require 'vagrant-hostel/command'
10
+ require 'vagrant-hostel/plugin'
11
11
 
12
- Vagrant.commands.register(:hostel) { VagrantHostel::Command }
12
+ # v1 syntax:
13
+ #Vagrant.commands.register(:hostel) { VagrantHostel::Command }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-hostel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-18 00:00:00.000000000 Z
12
+ date: 2013-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -57,6 +57,8 @@ files:
57
57
  - README.md
58
58
  - Rakefile
59
59
  - lib/vagrant-hostel/command.rb
60
+ - lib/vagrant-hostel/config.rb
61
+ - lib/vagrant-hostel/plugin.rb
60
62
  - lib/vagrant-hostel/version.rb
61
63
  - lib/vagrant_init.rb
62
64
  - vagrant-hostel.gemspec
@@ -75,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
77
  version: '0'
76
78
  segments:
77
79
  - 0
78
- hash: 2866712974864689558
80
+ hash: 2146763337475154752
79
81
  required_rubygems_version: !ruby/object:Gem::Requirement
80
82
  none: false
81
83
  requirements:
@@ -84,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
86
  version: '0'
85
87
  segments:
86
88
  - 0
87
- hash: 2866712974864689558
89
+ hash: 2146763337475154752
88
90
  requirements: []
89
91
  rubyforge_project:
90
92
  rubygems_version: 1.8.25