vagrant-wrapper 1.2.1.1 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 501d5a1c6d888a816d5d52c6cf6ab3ddad9c60f4
4
+ data.tar.gz: a610dd50af7805c8d6ef27af0c734afc0b5761b4
5
+ SHA512:
6
+ metadata.gz: 8b525222282ff19adbc416305d48c330d07a54bb471c7b9689e5587c29ada8e1cf7a4e26f8c394284f04f6ac34a9f9601bd10cd3aeeb443363c40a7953eaeb9b
7
+ data.tar.gz: 7b1c76b4c488077e38f2c1550ca9cc08925ad264969bd2fc1fe826424eeee10bc5c01f2f93be9bf565903bd3cbf0972df8fe250dacda03f96a0d1773a9e5d6e1
data/README.md CHANGED
@@ -8,15 +8,23 @@ A gem providing access and bundling to the newer packaged versions of Vagrant. (
8
8
 
9
9
  **Please note:** this Gem does not install any version of Vagrant, it provides a compatibility layer over the newer packaged version. However, functions are included which may be used to guide the installation of Vagrant, when necessary.
10
10
 
11
- **[More information on why this Gem exists can be seen in the Background section below.](#background---aka-the-vagrant-gem-enigma)**
11
+ ### Background - AKA the Vagrant Gem Enigma
12
+
13
+ Examples of the problem this gem solves, and the history behind it, have been moved to the [ENIGMA.md](ENIGMA.md) file.
14
+
15
+ ## Version 2.0 Now Available
16
+
17
+ - Now supporting Windows!
18
+ - Testing cleaned up and updated to RSpec3
19
+
20
+ Big thank you to @btm for writing these updates, and @tknerr for helping to test.
21
+
12
22
 
13
23
 
14
24
  # Installation and Usage
15
25
 
16
26
  Require the Vagrant Wrapper via your Gemfile, then run `bundle install`.
17
27
 
18
- source 'https://rubygems.org'
19
-
20
28
  gem 'vagrant-wrapper'
21
29
 
22
30
  Shell calls to 'vagrant' in your project will now always use the packaged version of Vagrant if available,
@@ -28,54 +36,6 @@ and use the older Gem version, even if they are shelling out as well.
28
36
  **Please note:** The wrapper searches for a packaged installation of Vagrant first, and then falls back to any version it can find in the PATH. Therefore it will link to the 1.0.x gem version if that's all that is installed, so you should always enforce a minimum Vagrant version, see below.
29
37
 
30
38
 
31
- ## Gemfile examples
32
-
33
- **Let's assume you have both Vagrant 1.0.7 installed via a Gem, and Vagrant 1.2 installed via the official package.**
34
-
35
- ### A... Older 'vagrant' gemfiles
36
-
37
- This older Gemfile will still launch Vagrant 1.0.7, as expected:
38
-
39
- **Gemfile**
40
-
41
- source 'https://rubygems.org'
42
- gem 'vagrant'
43
-
44
- **Output**
45
-
46
- puts %x{vagrant -v}
47
- => "Vagrant version 1.0.7"
48
-
49
- _Notes below on [VAGRANT_HOME](#vagrant_home) with older versions._
50
-
51
- ### B... Simply Leaving out 'vagrant'
52
-
53
- This is the key problem the Vagrant Wrapper seeks to solve, because otherwise (without uninstalling the vagrant gem), your shell calls will still be routed to 1.0.7.
54
-
55
- **Gemfile**
56
-
57
- source 'https://rubygems.org'
58
-
59
- **Output**
60
-
61
- puts %x{vagrant -v}
62
- => "Vagrant version 1.0.7"
63
-
64
- ### C... Including 'vagrant-wrapper'
65
-
66
- Calls to vagrant now route to the newer packaged version.
67
-
68
- **Gemfile**
69
-
70
- source 'https://rubygems.org'
71
- gem 'vagrant-wrapper'
72
-
73
- **Output**
74
-
75
- puts %x{vagrant -v}
76
- => "Vagrant version 1.2.0"
77
-
78
-
79
39
  ## Shell interaction
80
40
 
81
41
  By requiring 'vagrant-wrapper' in your Gemfile, all calls to vagrant (inside and outside of Ruby), will use the packaged Vagrant install if available.
@@ -171,34 +131,7 @@ Major differences in Vagrant will refuse to use the same existing shared data di
171
131
 
172
132
  $ export VAGRANT_HOME=~/.vagrant.old
173
133
 
174
- ----------
175
-
176
- # Background - AKA the Vagrant Gem enigma
177
-
178
- Per the creator's discretion, Vagrant 1.1+ no longer ships in Gem form,
179
- [see here](https://groups.google.com/d/msg/vagrant-up/kX_wvn7wcds/luwNur4kgDEJ),
180
- in favor of packaged installers.
181
-
182
- There are many ways in which this is a strong move for the project, and in theory Vagrant's ability to use
183
- its own bundled Ruby allows it to operate in a vacuum. So why does this wrapper exist?
184
-
185
- The problem is that Gems do (and will always) exist for the older versions. If they are installed they tend
186
- to override the system installed version of Vagrant if shell calls are made from within Ruby projects.
187
-
188
- As an example, if you have any bundled project that requires the 'vagrant' gem via its Gemfile, and a newer
189
- project that does not require this Gem (hoping to rely on the system packaged version), you'll find that
190
- the Gem version of Vagrant will always be called when your program attempts to access Vagrant via a shell
191
- or subprocess.
192
-
193
- This is because the Rubygems bin directory is higher in your PATH, and using "bundle exec" will not help.
194
- Even though Bundler will attempt to broker between multiple versions of Gems, it cannot handle the choice
195
- between the Gem version and the system version.
196
-
197
- Your only option would be to remove the old vagrant gem between projects, which is cumbersome. Also the problem will recur if you run a "bundle install" on a project which still includes the older Gem. This wrapper
198
- solves the problem by giving your newer projects something to include and override the older Gem versions
199
- of Vagrant.
200
134
 
201
- ----------
202
135
 
203
136
  # Development and Maintenance
204
137
 
data/bin/vagrant CHANGED
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'vagrant-wrapper'
3
+ begin
4
+ require 'vagrant-wrapper'
5
+ rescue LoadError
6
+ # This ensures the integration tests pass if the gem is not installed
7
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
8
+ retry
9
+ end
4
10
 
5
11
  min_ver = nil
6
12
 
@@ -22,11 +22,13 @@ require 'shellwords'
22
22
  # if the vagrant-wrapper Gem is required in your bundle.
23
23
  class VagrantWrapper
24
24
 
25
+ # The string used to detect ourselves and a gem wrapper of ourselves
26
+ WRAPPER_MARK = "vagrant-wrapper"
27
+
25
28
  def initialize(*args)
26
- @vagrant_name = "vagrant"
29
+ @vagrant_name = windows? ? "vagrant.exe" : "vagrant"
27
30
  @vagrant_path = nil
28
31
  @search_paths = default_paths + env_paths
29
- @wrapper_mark = "END VAGRANT WRAPPER"
30
32
 
31
33
  # Optional first parameter sets required version.
32
34
  unless args.length < 1 or args[0].nil?
@@ -79,7 +81,7 @@ class VagrantWrapper
79
81
  def vagrant_version
80
82
  ver = call_vagrant "-v"
81
83
  unless ver.nil?
82
- ver = ver[/(\.?[0-9]+)+/]
84
+ ver = ver[/Vagrant( version)? ([0-9]+(\.[0-9]+)+)/, 2]
83
85
  end
84
86
  ver
85
87
  end
@@ -90,19 +92,31 @@ class VagrantWrapper
90
92
  # /usr/bin
91
93
  # /bin
92
94
  def default_paths
93
- %w{
94
- /opt/vagrant/bin
95
- /usr/local/bin
96
- /usr/bin
97
- /bin
98
- }
95
+ if windows?
96
+ %w{
97
+ C:\HashiCorp\Vagrant\bin
98
+ /c/HashiCorp/Vagrant/bin
99
+ }
100
+ else
101
+ %w{
102
+ /opt/vagrant/bin
103
+ /usr/local/bin
104
+ /usr/bin
105
+ /bin
106
+ }
107
+ end
99
108
  end
100
109
 
101
110
  # Environment search paths to be used as low priority search.
102
111
  def env_paths
103
112
  path = ENV['PATH'].to_s.strip
104
113
  return [] if path.empty?
105
- path.split(':')
114
+ separator = if windows?
115
+ ';'
116
+ else
117
+ ':'
118
+ end
119
+ path.split(separator)
106
120
  end
107
121
 
108
122
  def self.install_instructions
@@ -129,9 +143,9 @@ class VagrantWrapper
129
143
  def find_vagrant
130
144
  unless @vagrant_path
131
145
  @search_paths.each do |path|
132
- test_bin = "#{path}/#{@vagrant_name}"
146
+ test_bin = "#{path}#{path_separator}#{@vagrant_name}"
133
147
  next unless ::File.executable?(test_bin)
134
- next if (%x{tail -n1 #{test_bin}}.match(@wrapper_mark) != nil)
148
+ next if is_wrapper?(test_bin)
135
149
  @vagrant_path = test_bin
136
150
  break
137
151
  end
@@ -152,10 +166,26 @@ class VagrantWrapper
152
166
  def exec_vagrant(*args)
153
167
  unless vagrant = find_vagrant
154
168
  $stderr.puts "Vagrant is not installed."
155
- $stderr.print install_instructions
169
+ $stderr.print VagrantWrapper.install_instructions
156
170
  exit(1)
157
171
  end
158
172
  args.unshift(vagrant)
159
173
  exec(Shellwords.join(args))
160
174
  end
175
+
176
+ def windows?
177
+ !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
178
+ end
179
+
180
+ def is_wrapper?(file)
181
+ File.readlines(file).grep(/#{WRAPPER_MARK}/).any?
182
+ end
183
+
184
+ def path_separator
185
+ if windows?
186
+ File::ALT_SEPARATOR || '\\'.freeze
187
+ else
188
+ File::SEPARATOR
189
+ end
190
+ end
161
191
  end
@@ -13,6 +13,6 @@
13
13
  #
14
14
 
15
15
  class VagrantWrapper
16
- VERSION = '1.2.1.1'
17
- RELEASE_DATE = '2013-05-20'
16
+ VERSION = '2.0'
17
+ RELEASE_DATE = '2014-12-16'
18
18
  end
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1.1
5
- prerelease:
4
+ version: '2.0'
6
5
  platform: ruby
7
6
  authors:
8
7
  - BinaryBabel OSS
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-20 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '3.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '3.0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: vagrant
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - '='
52
46
  - !ruby/object:Gem::Version
@@ -54,22 +48,15 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - '='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.0.7
62
- description: ! 'Since Vagrant 1.1+ is no longer distributed via Gems, vagrant-wrapper
63
- allows you to require and interact
64
-
65
- with the newer package versions via your Gemfile, shell, or Ruby code. It allows
66
- the newer packaged
67
-
55
+ description: |
56
+ Since Vagrant 1.1+ is no longer distributed via Gems, vagrant-wrapper allows you to require and interact
57
+ with the newer package versions via your Gemfile, shell, or Ruby code. It allows the newer packaged
68
58
  version to take precedence even if the older Vagrant gem remains installed.
69
-
70
59
  See https://github.com/org-binbab/gem-vagrant-wrapper for more details.
71
-
72
- '
73
60
  email:
74
61
  - projects@binarybabel.org
75
62
  executables:
@@ -79,39 +66,32 @@ extra_rdoc_files: []
79
66
  files:
80
67
  - LICENSE
81
68
  - README.md
69
+ - bin/vagrant
70
+ - lib/vagrant-wrapper.rb
82
71
  - lib/vagrant-wrapper/exceptions.rb
83
72
  - lib/vagrant-wrapper/version.rb
84
- - lib/vagrant-wrapper.rb
85
- - bin/vagrant
86
73
  homepage: http://code.binbab.org
87
74
  licenses:
88
75
  - MIT
76
+ metadata: {}
89
77
  post_install_message:
90
78
  rdoc_options: []
91
79
  require_paths:
92
80
  - lib
93
81
  required_ruby_version: !ruby/object:Gem::Requirement
94
- none: false
95
82
  requirements:
96
- - - ! '>='
83
+ - - ">="
97
84
  - !ruby/object:Gem::Version
98
85
  version: '0'
99
- segments:
100
- - 0
101
- hash: 1894894601892164128
102
86
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
87
  requirements:
105
- - - ! '>='
88
+ - - ">="
106
89
  - !ruby/object:Gem::Version
107
90
  version: '0'
108
- segments:
109
- - 0
110
- hash: 1894894601892164128
111
91
  requirements: []
112
92
  rubyforge_project:
113
- rubygems_version: 1.8.24
93
+ rubygems_version: 2.2.2
114
94
  signing_key:
115
- specification_version: 3
95
+ specification_version: 4
116
96
  summary: Wrapper/binstub for os packaged version of Vagrant.
117
97
  test_files: []