gemrage 0.1.1 → 0.1.2
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/Gemfile +2 -0
- data/Gemfile.lock +5 -0
- data/VERSION +1 -1
- data/gemrage.gemspec +148 -3
- data/lib/rubygems/commands/scan_command.rb +77 -4
- data/vendor/ruby/1.8/bin/rvm-install +19 -0
- data/vendor/ruby/1.8/cache/macaddr-1.0.0.gem +0 -0
- data/vendor/ruby/1.8/cache/rvm-1.0.14.gem +0 -0
- data/vendor/ruby/1.8/gems/macaddr-1.0.0/README +33 -0
- data/vendor/ruby/1.8/gems/macaddr-1.0.0/gemspec.rb +27 -0
- data/vendor/ruby/1.8/gems/macaddr-1.0.0/install.rb +210 -0
- data/vendor/ruby/1.8/gems/macaddr-1.0.0/lib/macaddr.rb +69 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/LICENCE +18 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/README +127 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/bin/rvm-install +5 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm +76 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-auto-ruby +24 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-prompt +204 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-shell +35 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-update-head +35 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-update-latest +27 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvmsudo +24 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/config/db +71 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/config/known +55 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/config/md5 +87 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/gemset_snapshot +25 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/install-system-wide +191 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/r +44 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/examples/rvmrc +47 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/gemsets/default.gems +1 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/gemsets/global.gems +1 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/alias +46 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/benchmark +17 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/cleanup +23 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/debug +8 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/disk-usage +15 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/docs +22 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/exec +33 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/fetch +5 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gem +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gemdir +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gemset +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/implode +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/info +64 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/install +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/list +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/migrate +15 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/monitor +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/notes +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/package +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rake +14 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/remove +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/repair +23 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/reset +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/ruby +84 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rubygems +11 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rvmrc +34 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/snapshot +15 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/specs +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/srcdir +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/tests +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/tools +22 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/uninstall +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/update +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/upgrade +18 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/use +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/wrapper +41 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/install +631 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/VERSION.yml +4 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/capistrano.rb +45 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/alias.rb +69 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/cleanup.rb +54 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/configuration.rb +60 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb +52 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/gemset.rb +222 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/info.rb +13 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/list.rb +124 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/rubies.rb +50 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/sets.rb +123 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/tools.rb +68 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/utility.rb +173 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/wrapper.rb +23 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment.rb +64 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/errors.rb +31 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb +51 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/abstract_wrapper.rb +145 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/calculate_rvm_path.sh +26 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/result.rb +42 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/shell_wrapper.sh +10 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/single_shot_wrapper.rb +56 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/utility.rb +37 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell.rb +25 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/version.rb +19 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm.rb +156 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/man/man1/rvm.1 +385 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/man/man1/rvm.1.gz +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/rvm.gemspec +184 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/alias +225 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/aliases +4 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array +32 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/base +49 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cd +87 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cleanup +58 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cli +781 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/color +49 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/completion +151 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/db +87 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/default +64 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/disk-usage +60 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/docs +115 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/env +46 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/environment-convertor +74 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/fetch +229 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/gemsets +950 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash +37 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/help +46 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hook +23 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/info +214 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/initialize +29 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/install +631 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/irbrc +9 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/irbrc.rb +63 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/list +315 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/log +38 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/maglev +193 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/manage +2094 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/match +6 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/md5 +22 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/migrate +175 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/monitor +105 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/notes +121 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/override_gem +14 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/package +301 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/patches +64 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/patchsets +87 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/repair +199 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rubygems +157 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rvm +120 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rvm-install +631 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/selector +818 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/set +301 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/snapshot +262 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/tools +58 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/update +631 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/upgrade +144 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/utility +1557 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/version +17 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/wrapper +210 -0
- data/vendor/ruby/1.8/specifications/macaddr-1.0.0.gemspec +27 -0
- data/vendor/ruby/1.8/specifications/rvm-1.0.14.gemspec +42 -0
- metadata +149 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Calculates a default rvm path
|
|
4
|
+
|
|
5
|
+
# Check first.
|
|
6
|
+
if [[ -n "$rvm_path" ]]; then
|
|
7
|
+
echo "$rvm_path"
|
|
8
|
+
exit
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
# Load extra files.
|
|
12
|
+
|
|
13
|
+
[[ -s ~/.rvmrc ]] && source ~/.rvmrc >/dev/null 2>&1
|
|
14
|
+
[[ -s /etc/.rvmrc ]] && source /etc/rvmrc >/dev/null 2>&1
|
|
15
|
+
|
|
16
|
+
if [[ -n "$rvm_path" ]]; then
|
|
17
|
+
echo "$rvm_path"
|
|
18
|
+
elif [[ -d ~/.rvm ]]; then
|
|
19
|
+
echo "~/.rvm"
|
|
20
|
+
elif [[ -d /usr/local/rvm ]]; then
|
|
21
|
+
echo "/usr/local/rvm"
|
|
22
|
+
else
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
exit 0
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module RVM
|
|
2
|
+
module Shell
|
|
3
|
+
# Represents the output of a shell command.
|
|
4
|
+
# This includes the exit status (and the helpful #successful? method)
|
|
5
|
+
# as well accessors for the command and stdout / stderr.
|
|
6
|
+
class Result
|
|
7
|
+
|
|
8
|
+
attr_reader :command, :stdout, :stderr, :raw_status
|
|
9
|
+
|
|
10
|
+
# Creates a new result object with the given details.
|
|
11
|
+
def initialize(command, status, stdout, stderr)
|
|
12
|
+
@command = command.dup.freeze
|
|
13
|
+
@raw_status = status
|
|
14
|
+
@environment = @raw_status["environment"] || {}
|
|
15
|
+
@successful = (exit_status == 0)
|
|
16
|
+
@stdout = stdout.freeze
|
|
17
|
+
@stderr = stderr.freeze
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns the hash of the environment.
|
|
21
|
+
def env
|
|
22
|
+
@environment
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Whether or not the command had a successful exit status.
|
|
26
|
+
def successful?
|
|
27
|
+
@successful
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Returns a value from the outputs environment.
|
|
31
|
+
def [](key)
|
|
32
|
+
env[key.to_s]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns the exit status for the program
|
|
36
|
+
def exit_status
|
|
37
|
+
@exit_status ||= (Integer(@raw_status["exit_status"]) rescue 1)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Prints an epilog to a shell command.
|
|
2
|
+
__rvm_show_command_epilog() {
|
|
3
|
+
local last_command_result="$?"
|
|
4
|
+
echo "---------------RVM-RESULTS-START---------------"
|
|
5
|
+
echo "---"
|
|
6
|
+
echo " exit_status: \"$last_command_result\""
|
|
7
|
+
echo " environment:"
|
|
8
|
+
env | sed "s#'#\\'#g" | sed -e 's#"#\\"#g' -e "s#\\([^=]*\\)=\\(.*\\)# '\1': \"\2\"#"
|
|
9
|
+
echo "----------------RVM-RESULTS-END----------------"
|
|
10
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'open3'
|
|
2
|
+
|
|
3
|
+
module RVM
|
|
4
|
+
module Shell
|
|
5
|
+
# Implementation of the abstract wrapper class that opens a new
|
|
6
|
+
# instance of bash when a command is run, only keeping it around
|
|
7
|
+
# for the lifetime of the command. Possibly inefficient but for
|
|
8
|
+
# the moment simplest and hence default implementation.
|
|
9
|
+
class SingleShotWrapper < AbstractWrapper
|
|
10
|
+
|
|
11
|
+
attr_accessor :current
|
|
12
|
+
|
|
13
|
+
# Runs a given command in the current shell.
|
|
14
|
+
# Defaults the command to true if empty.
|
|
15
|
+
def run_command(command)
|
|
16
|
+
command = "true" if command.to_s.strip.empty?
|
|
17
|
+
with_shell_instance do
|
|
18
|
+
stdin.puts wrapped_command(command)
|
|
19
|
+
stdin.close
|
|
20
|
+
out, err = stdout.read, stderr.read
|
|
21
|
+
out, status, _ = raw_stdout_to_parts(out)
|
|
22
|
+
return status, out, err
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Runs a command, ensuring no output is collected.
|
|
27
|
+
def run_command_silently(command)
|
|
28
|
+
with_shell_instance do
|
|
29
|
+
stdin.puts silent_command(command)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
protected
|
|
34
|
+
|
|
35
|
+
# yields stdio, stderr and stdin for a shell instance.
|
|
36
|
+
# If there isn't a current shell instance, it will create a new one.
|
|
37
|
+
# In said scenario, it will also cleanup once it is done.
|
|
38
|
+
def with_shell_instance(&blk)
|
|
39
|
+
no_current = @current.nil?
|
|
40
|
+
if no_current
|
|
41
|
+
@current = Open3.popen3(self.shell_executable)
|
|
42
|
+
invoke_setup!
|
|
43
|
+
end
|
|
44
|
+
yield
|
|
45
|
+
ensure
|
|
46
|
+
@current = nil if no_current
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Direct access to each of the named descriptors
|
|
50
|
+
def stdin; @current[0]; end
|
|
51
|
+
def stdout; @current[1]; end
|
|
52
|
+
def stderr; @current[2]; end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module RVM
|
|
2
|
+
module Shell
|
|
3
|
+
module Utility
|
|
4
|
+
|
|
5
|
+
public
|
|
6
|
+
|
|
7
|
+
# Takes an array / number of arguments and converts
|
|
8
|
+
# them to a string useable for passing into a shell call.
|
|
9
|
+
def escape_arguments(*args)
|
|
10
|
+
return '' if args.nil?
|
|
11
|
+
args.flatten.map { |a| escape_argument(a.to_s) }.join(" ")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Given a string, converts to the escaped format. This ensures
|
|
15
|
+
# that things such as variables aren't evaluated into strings
|
|
16
|
+
# and everything else is setup as expected.
|
|
17
|
+
def escape_argument(s)
|
|
18
|
+
return "''" if s.empty?
|
|
19
|
+
s.scan(/('+|[^']+)/).map do |section|
|
|
20
|
+
section = section.first
|
|
21
|
+
if section[0] == ?'
|
|
22
|
+
"\\'" * section.length
|
|
23
|
+
else
|
|
24
|
+
"'#{section}'"
|
|
25
|
+
end
|
|
26
|
+
end.join
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# From a command, will build up a runnable command. If args isn't provided,
|
|
30
|
+
# it will escape arguments.
|
|
31
|
+
def build_cli_call(command, args = nil)
|
|
32
|
+
"#{command} #{escape_arguments(args)}".strip
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module RVM
|
|
2
|
+
# Provides Generic access to a more ruby-like shell interface.
|
|
3
|
+
# For more details, see AbstractWrapper.
|
|
4
|
+
module Shell
|
|
5
|
+
|
|
6
|
+
autoload :AbstractWrapper, 'rvm/shell/abstract_wrapper'
|
|
7
|
+
autoload :SingleShotWrapper, 'rvm/shell/single_shot_wrapper'
|
|
8
|
+
# Current unimplemented
|
|
9
|
+
#autoload :PersistingWrapper, 'rvm/shell/persisting_wrapper'
|
|
10
|
+
autoload :TestWrapper, 'rvm/shell/test_wrapper'
|
|
11
|
+
autoload :Utility, 'rvm/shell/utility'
|
|
12
|
+
autoload :Result, 'rvm/shell/result'
|
|
13
|
+
|
|
14
|
+
# Returns the default shell wrapper class to use
|
|
15
|
+
def self.default_wrapper
|
|
16
|
+
@@default_wrapper ||= SingleShotWrapper
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Sets the default shell wrapper class to use.
|
|
20
|
+
def self.default_wrapper=(wrapper)
|
|
21
|
+
@@default_wrapper = wrapper
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
module RVM
|
|
4
|
+
module Version
|
|
5
|
+
|
|
6
|
+
# YAML of raw version info
|
|
7
|
+
VERSION_YAML = YAML.load_file(File.expand_path("../VERSION.yml", File.dirname(__FILE__)))
|
|
8
|
+
|
|
9
|
+
# Current major version of rvm
|
|
10
|
+
MAJOR = VERSION_YAML[:major]
|
|
11
|
+
# Current minor version of rvm
|
|
12
|
+
MINOR = VERSION_YAML[:minor]
|
|
13
|
+
# Current patch level of rvm
|
|
14
|
+
PATCH = VERSION_YAML[:patch]
|
|
15
|
+
# A String with the current rvm version
|
|
16
|
+
STRING = [MAJOR, MINOR, PATCH].join(".").freeze
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# == Ruby Version Manager - Ruby API
|
|
2
|
+
#
|
|
3
|
+
# Provides a wrapper around the command line api implemented as part of the api.
|
|
4
|
+
# If you're not familiar with rvm, please read http://rvm.beginrescueend.com/
|
|
5
|
+
# first.
|
|
6
|
+
#
|
|
7
|
+
# == Usage
|
|
8
|
+
#
|
|
9
|
+
# When using the rvm ruby api, you gain access to most of the commands, including the set
|
|
10
|
+
# functionality. As a side node, the RVM module provides access to most of the api
|
|
11
|
+
# both via direct api wrappers (of the form <tt><tool>_<action></tt> - e.g. +alias_create+,
|
|
12
|
+
# +gemset_use+ and +wrapper+).
|
|
13
|
+
#
|
|
14
|
+
# == The Environment Model
|
|
15
|
+
#
|
|
16
|
+
# The RVM ruby api is implemented using an environment model. Each environment maps directly
|
|
17
|
+
# to some ruby string interpretable by rvm (e.g. +ree+, +ruby-1.8.7-p174+, +system+, +rbx@rails+
|
|
18
|
+
# and so on) and is considered a sandboxed environment (for commands like use etc) in which you
|
|
19
|
+
# can deal with rvm. it's worth noting that a single environment can have multiple environment
|
|
20
|
+
# instances and for the most part creating of these instances is best handled by the RVM.environment
|
|
21
|
+
# and RVM.environments methods.
|
|
22
|
+
#
|
|
23
|
+
# Each Environment (and instance of RVM::Environment) provides access to the rvm ruby api (in some
|
|
24
|
+
# cases, the api may not directly be related to the current ruby - but for simplicity / consistency
|
|
25
|
+
# purposes, they are still implemented as methods of RVM::Environment).
|
|
26
|
+
#
|
|
27
|
+
# When you perform an action with side effects (e.g. RVM::Environment#gemset_use or RVM::Environment#use)
|
|
28
|
+
# this will mutate the ruby string of the given environment (hence, an environment is considered mutable).
|
|
29
|
+
#
|
|
30
|
+
# Lastly, for the actual command line work, RVM::Environment works with an instance of RVM::Shell::AbstractWrapper.
|
|
31
|
+
# This performs logic (such as correctly escaping strings, calling the environment and such) in a way that
|
|
32
|
+
# is both reusable and simplified.
|
|
33
|
+
#
|
|
34
|
+
# By default, method_missing is used on the RVM module to proxy method calls to RVM.current (itself
|
|
35
|
+
# calling RVM::Environment.current), meaning things like RVM.gemset_name, RVM.alias_create and the like
|
|
36
|
+
# work. This is considered the 'global' instance and should be avoided unless needed directly.
|
|
37
|
+
#
|
|
38
|
+
# RVM::Environment.current will first attempt to use the current ruby string (determined by
|
|
39
|
+
# +ENV['GEM_HOME']+ but will fall back to using the rubies load path if that isn't available).
|
|
40
|
+
#
|
|
41
|
+
# In many cases, (e.g. +alias+, +list+ and the like) there is a more ruby-like wrapper class,
|
|
42
|
+
# typically available via <tt>RVM::Environment#<action></tt>.
|
|
43
|
+
#
|
|
44
|
+
# == Side Notes
|
|
45
|
+
#
|
|
46
|
+
# In the cases this api differs, see the RVM::Environment class for more information.
|
|
47
|
+
#
|
|
48
|
+
# You can check the name of a given environment in two ways - RVM::Environment#environment_name
|
|
49
|
+
# for the short version / the version set by RVM::Environment#use, RVM::Environment#gemset_use
|
|
50
|
+
# or RVM.environment. If you wish to get the full, expanded string (which has things such as
|
|
51
|
+
# the actual version of the selected ruby), you instead with to use RVM::Environment#expanded_name.
|
|
52
|
+
#
|
|
53
|
+
# Lastly, If you do need to pass environment variables to a specific environment, please use
|
|
54
|
+
# RVM::Environment.new, versus RVM.environment
|
|
55
|
+
#
|
|
56
|
+
module RVM
|
|
57
|
+
require 'rvm/errors'
|
|
58
|
+
|
|
59
|
+
autoload :Shell, 'rvm/shell'
|
|
60
|
+
autoload :Environment, 'rvm/environment'
|
|
61
|
+
autoload :Version, 'rvm/version'
|
|
62
|
+
|
|
63
|
+
class << self
|
|
64
|
+
|
|
65
|
+
# Returns the current global environment.
|
|
66
|
+
def current
|
|
67
|
+
Environment.current
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Reset the current global environment to the default / what it was
|
|
71
|
+
# when the process first started.
|
|
72
|
+
def reset_current!
|
|
73
|
+
Environment.reset_current!
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Returns an array of multiple environments. If given
|
|
77
|
+
# a block, will yield each time with the given environment.
|
|
78
|
+
#
|
|
79
|
+
# RVM.environments("ree@rails3,rbx@rails3") do |env|
|
|
80
|
+
# puts "Full environment: #{env.expanded_name}"
|
|
81
|
+
# end
|
|
82
|
+
#
|
|
83
|
+
# Alternatively, you can use the more ruby-like fashion:
|
|
84
|
+
#
|
|
85
|
+
# RVM.environments("ree@rails3", "rbx@rails3") do |env|
|
|
86
|
+
# puts "Full environment: #{env.expanded_name}"
|
|
87
|
+
# end
|
|
88
|
+
#
|
|
89
|
+
def environments(*names, &blk)
|
|
90
|
+
# Normalize the names before using them on for the environment.
|
|
91
|
+
names.flatten.join(",").split(",").uniq.map do |n|
|
|
92
|
+
environment(n, &blk)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Returns the environment with the given name.
|
|
97
|
+
# If passed a block, will yield with that as the single argument.
|
|
98
|
+
#
|
|
99
|
+
# RVM.environment("ree@rails3") do |env|
|
|
100
|
+
# puts "Gemset is #{env.gemset.name}"
|
|
101
|
+
# end
|
|
102
|
+
#
|
|
103
|
+
def environment(name)
|
|
104
|
+
# TODO: Maintain an Environment cache.
|
|
105
|
+
# The cache needs to track changes via use etc though.
|
|
106
|
+
env = Environment.new(name)
|
|
107
|
+
yield env if block_given?
|
|
108
|
+
env
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Merges items into the default config, essentially
|
|
112
|
+
# setting environment variables passed to child processes:
|
|
113
|
+
#
|
|
114
|
+
# RVM.merge_config!({
|
|
115
|
+
# :some_shell_variable => "me",
|
|
116
|
+
# })
|
|
117
|
+
#
|
|
118
|
+
def merge_config!(config = {})
|
|
119
|
+
Environment.merge_config!(config)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Returns the current 'best guess' value for rvm_path.
|
|
123
|
+
def path
|
|
124
|
+
Environment.rvm_path
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Shortcut to set rvm_path. Will set it on all new instances
|
|
128
|
+
# but wont affect currently running environments.
|
|
129
|
+
def path=(value)
|
|
130
|
+
Environment.rvm_path = value
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
private
|
|
134
|
+
|
|
135
|
+
def cache_method_call(name)
|
|
136
|
+
class_eval <<-END, __FILE__, __LINE__
|
|
137
|
+
def #{name}(*args, &blk)
|
|
138
|
+
current.__send__(:#{name}, *args, &blk)
|
|
139
|
+
end
|
|
140
|
+
END
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Proxies methods to the current environment, creating a
|
|
144
|
+
# method before dispatching to speed up future calls.
|
|
145
|
+
def method_missing(name, *args, &blk)
|
|
146
|
+
if current.respond_to?(name)
|
|
147
|
+
cache_method_call name
|
|
148
|
+
current.__send__ name, *args, &blk
|
|
149
|
+
else
|
|
150
|
+
super
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
end
|