vagrant-wrapper 1.2.0
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.
- data/bin/vagrant +7 -0
- data/lib/vagrant-wrapper.rb +112 -0
- metadata +62 -0
data/bin/vagrant
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'Shellwords'
|
2
|
+
|
3
|
+
# Main class for the VagrantWrapper driver.
|
4
|
+
# This driver will search predefined paths for a packaged version of Vagrant,
|
5
|
+
# followed by the system's environment PATH. Ideal functionality being that
|
6
|
+
# a stale Gem version of Vagrant will be overriden by the packaged version
|
7
|
+
# if the vagrant-wrapper Gem is required in your bundle.
|
8
|
+
class VagrantWrapper
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@vagrant_name = "vagrant"
|
12
|
+
@vagrant_path = nil
|
13
|
+
@search_paths = default_paths
|
14
|
+
@wrapper_mark = "END VAGRANT WRAPPER"
|
15
|
+
|
16
|
+
# Include environment paths as low priority searches.
|
17
|
+
env_path = ENV['PATH'].to_s
|
18
|
+
if "" != env_path
|
19
|
+
@search_paths.concat(env_path.split(':'))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Call the discovered version of Vagrant.
|
24
|
+
# The given arguments (if any) are passed along to the command line.
|
25
|
+
#
|
26
|
+
# The output will be returned.
|
27
|
+
def execute(*args)
|
28
|
+
if args.length > 0 && args[0].is_a?(Array)
|
29
|
+
send("exec_vagrant", *args[0])
|
30
|
+
else
|
31
|
+
send("exec_vagrant", *args)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Execute the discovered version of Vagrant.
|
36
|
+
# The given arguments (if any) are passed along to the command line.
|
37
|
+
#
|
38
|
+
# The vagrant process will replace this processe entirely, operating
|
39
|
+
# and outputting in an unmodified state.
|
40
|
+
def execute(*args)
|
41
|
+
if args.length > 0 && args[0].is_a?(Array)
|
42
|
+
send("exec_vagrant", *args[0])
|
43
|
+
else
|
44
|
+
send("exec_vagrant", *args)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Return the filesystem location of the discovered Vagrant install.
|
49
|
+
def vagrant_location
|
50
|
+
find_vagrant
|
51
|
+
end
|
52
|
+
|
53
|
+
# Return the version of the discovered Vagrent install.
|
54
|
+
def vagrant_version
|
55
|
+
ver = call_vagrant "-v"
|
56
|
+
unless ver.nil?
|
57
|
+
ver = ver[/(\.?[0-9]+)+/]
|
58
|
+
end
|
59
|
+
ver
|
60
|
+
end
|
61
|
+
|
62
|
+
# Default paths to search for the packaged version of Vagrant.
|
63
|
+
# /opt/vagrant/bin
|
64
|
+
# /usr/local/bin
|
65
|
+
# /usr/bin
|
66
|
+
# /bin
|
67
|
+
def default_paths
|
68
|
+
%w{
|
69
|
+
/opt/vagrant/bin
|
70
|
+
/usr/local/bin
|
71
|
+
/usr/bin
|
72
|
+
/bin
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
protected
|
77
|
+
|
78
|
+
# Locate the installed version of Vagrant using the provided paths.
|
79
|
+
# Exclude the wrapper itself, should it be discovered by the search.
|
80
|
+
def find_vagrant
|
81
|
+
unless @vagrant_path
|
82
|
+
@search_paths.each do |path|
|
83
|
+
test_bin = "#{path}/#{@vagrant_name}"
|
84
|
+
next unless ::File.executable?(test_bin)
|
85
|
+
next if (%x{tail -n1 #{test_bin}}.match(@wrapper_mark) != nil)
|
86
|
+
@vagrant_path = test_bin
|
87
|
+
break
|
88
|
+
end
|
89
|
+
end
|
90
|
+
@vagrant_path
|
91
|
+
end
|
92
|
+
|
93
|
+
# Call Vagrant once and return the output of the command.
|
94
|
+
def call_vagrant(*args)
|
95
|
+
unless vagrant = find_vagrant
|
96
|
+
return nil
|
97
|
+
end
|
98
|
+
args.unshift(vagrant)
|
99
|
+
%x{#{Shellwords.join(args)} + ' 2>&1'}
|
100
|
+
end
|
101
|
+
|
102
|
+
# Give execution control to Vagrant.
|
103
|
+
def exec_vagrant(*args)
|
104
|
+
unless vagrant = find_vagrant
|
105
|
+
$stderr.puts "Vagrant does not appear to be installed."
|
106
|
+
$stderr.puts "See http://www.vagrantup.com for instructions."
|
107
|
+
exit(1)
|
108
|
+
end
|
109
|
+
args.unshift(vagrant)
|
110
|
+
exec(Shellwords.join(args))
|
111
|
+
end
|
112
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- BinaryBabel OSS
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! 'Given Vagrant 1.1+ is distributed only via packaged installers, this
|
15
|
+
Gem provides
|
16
|
+
|
17
|
+
a wrapper such-that an existing Gem install of the older Vagrant will not take
|
18
|
+
|
19
|
+
precedence on the command line in a bundled project. Eg. shell calls to ''vagrant''
|
20
|
+
|
21
|
+
will use the packaged version.
|
22
|
+
|
23
|
+
|
24
|
+
(NOTE: The version of the Gem does not determine the version of Vagrant it links
|
25
|
+
to.)
|
26
|
+
|
27
|
+
'
|
28
|
+
email:
|
29
|
+
- projects@binarybabel.org
|
30
|
+
executables:
|
31
|
+
- vagrant
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- lib/vagrant-wrapper.rb
|
36
|
+
- bin/vagrant
|
37
|
+
homepage: http://code.binbab.org
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.8.24
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Wrapper/binstub for os packaged version of Vagrant.
|
62
|
+
test_files: []
|