rvm 0.1.41 → 0.1.42
Sign up to get free protection for your applications and to get access to all the features.
- data/binscripts/rvm +1 -1
- data/binscripts/rvm-shell +32 -0
- data/binscripts/rvmsudo +1 -6
- data/config/db +2 -2
- data/config/known +2 -2
- data/config/md5 +6 -5
- data/contrib/install-system-wide +81 -0
- data/install +23 -24
- data/lib/VERSION.yml +1 -1
- data/lib/rvm.rb +156 -1
- data/lib/rvm/capistrano.rb +45 -0
- data/lib/rvm/environment.rb +62 -0
- data/lib/rvm/environment/alias.rb +69 -0
- data/lib/rvm/environment/cleanup.rb +54 -0
- data/lib/rvm/environment/configuration.rb +60 -0
- data/lib/rvm/environment/env.rb +52 -0
- data/lib/rvm/environment/gemset.rb +222 -0
- data/lib/rvm/environment/info.rb +13 -0
- data/lib/rvm/environment/list.rb +124 -0
- data/lib/rvm/environment/rubies.rb +50 -0
- data/lib/rvm/environment/sets.rb +123 -0
- data/lib/rvm/environment/tools.rb +41 -0
- data/lib/rvm/environment/utility.rb +167 -0
- data/lib/rvm/environment/wrapper.rb +23 -0
- data/lib/rvm/errors.rb +28 -0
- data/lib/rvm/shell.rb +21 -10
- data/lib/rvm/shell/abstract_wrapper.rb +145 -0
- data/lib/rvm/shell/result.rb +42 -0
- data/lib/rvm/shell/shell_wrapper.sh +10 -0
- data/lib/rvm/shell/single_shot_wrapper.rb +56 -0
- data/lib/rvm/shell/utility.rb +37 -0
- data/lib/rvm/version.rb +12 -8
- data/rvm.gemspec +27 -4
- data/scripts/cd +17 -32
- data/scripts/cli +46 -16
- data/scripts/completion +1 -1
- data/scripts/disk-usage +52 -0
- data/scripts/fetch +8 -2
- data/scripts/gemsets +15 -4
- data/scripts/initialize +3 -3
- data/scripts/install +23 -24
- data/scripts/list +16 -8
- data/scripts/log +4 -1
- data/scripts/man +0 -0
- data/scripts/manage +51 -34
- data/scripts/md5 +4 -5
- data/scripts/package +28 -6
- data/scripts/rubygems +2 -2
- data/scripts/rvm +2 -2
- data/scripts/rvm-install +23 -24
- data/scripts/selector +2 -2
- data/scripts/tools +34 -0
- data/scripts/update +23 -24
- data/scripts/utility +54 -12
- data/scripts/wrapper +21 -18
- metadata +29 -6
- data/lib/rvm/open4.rb +0 -395
- data/lib/rvm/rvm.rb +0 -14
data/binscripts/rvm
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
__rvm_shell_lookup_script() {
|
4
|
+
local relative_scripts_dir="$(dirname -- "$(dirname -- "$0")")/scripts"
|
5
|
+
for directory in "$rvm_scripts_path" "$HOME/.rvm/scripts" "/usr/local/rvm/scripts" "$relative_scripts_dir"; do
|
6
|
+
if [[ -d "$directory" && -s "$directory/rvm" ]]; then
|
7
|
+
echo "$directory/rvm"
|
8
|
+
return
|
9
|
+
fi
|
10
|
+
done
|
11
|
+
}
|
12
|
+
|
13
|
+
# If the first argument isn't -c, remove it and set
|
14
|
+
# it to the ruby string value.
|
15
|
+
if [[ -n "$1" && -n "$(echo "$1" | grep -v '^-')" ]]; then
|
16
|
+
rvm_shell_ruby_string="$1"
|
17
|
+
shift
|
18
|
+
fi
|
19
|
+
|
20
|
+
if [[ -n "$rvm_shell_ruby_string" ]]; then
|
21
|
+
rvm_shell_rvm_path="$(__rvm_shell_lookup_script)"
|
22
|
+
if [[ -n "$rvm_shell_rvm_path" ]]; then
|
23
|
+
source "$rvm_shell_rvm_path"
|
24
|
+
rvm "$rvm_shell_ruby_string"
|
25
|
+
if [[ "$?" -gt 0 ]]; then
|
26
|
+
echo "Error: RVM was unable to use '#$rvm_shell_ruby_string'" 1>&2
|
27
|
+
exit 1
|
28
|
+
fi
|
29
|
+
fi
|
30
|
+
fi
|
31
|
+
|
32
|
+
exec bash "$@"
|
data/binscripts/rvmsudo
CHANGED
@@ -1,8 +1,3 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
-
|
4
|
-
if [[ ! -z "$BUNDLE_PATH" ]] ; then prefix="BUNDLE_PATH='$BUNDLE_PATH' $prefix" ; fi
|
5
|
-
if [[ ! -z "$GEM_HOME" ]] ; then prefix="GEM_HOME='$GEM_HOME' $prefix" ; fi
|
6
|
-
if [[ ! -z "$GEM_PATH" ]] ; then prefix="GEM_PATH='$GEM_PATH' $prefix" ; fi
|
7
|
-
|
8
|
-
eval "sudo" "/usr/bin/env $prefix $@"
|
3
|
+
exec sudo -E "$@"
|
data/config/db
CHANGED
@@ -18,7 +18,7 @@ ruby_1.8_url=ftp://ftp.ruby-lang.org/pub/ruby/1.8
|
|
18
18
|
ruby_1.9_url=ftp://ftp.ruby-lang.org/pub/ruby/1.9
|
19
19
|
ruby_2.0_url=ftp://ftp.ruby-lang.org/pub/ruby/2.0
|
20
20
|
ruby_1.9.1_patch_level=378
|
21
|
-
ruby_1.9.2_patch_level=
|
21
|
+
ruby_1.9.2_patch_level=rc2
|
22
22
|
ruby_1.8.5_patch_level=231
|
23
23
|
ruby_1.8.6_patch_level=399
|
24
24
|
ruby_1.8.7_patch_level=299
|
@@ -46,7 +46,7 @@ macruby_version=0.6
|
|
46
46
|
macruby_url=http://www.macruby.org/files
|
47
47
|
macruby_repo_url=git://git.macruby.org/macruby/MacRuby.git
|
48
48
|
macruby_nightly_url=http://www.macruby.org/files/nightlies/macruby_nightly-latest.pkg
|
49
|
-
maglev_version=
|
49
|
+
maglev_version=23832
|
50
50
|
maglev_url=http://glass-downloads.gemstone.com/maglev
|
51
51
|
maglev_repo_url=git://github.com/MagLev/maglev.git
|
52
52
|
shyouhei_repo_url=git://github.com/shyouhei/ruby.git
|
data/config/known
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
(ruby-)1.9.1-head
|
10
10
|
(ruby-)1.9.2-preview1
|
11
11
|
(ruby-)1.9.2-preview3
|
12
|
-
(ruby-)1.9.2(-
|
12
|
+
(ruby-)1.9.2(-rc2)
|
13
13
|
(ruby-)1.9.2-head
|
14
14
|
ruby-head
|
15
15
|
|
@@ -31,7 +31,7 @@ ree-1.8.6-head
|
|
31
31
|
ree-1.8.7-head
|
32
32
|
|
33
33
|
# MagLev
|
34
|
-
maglev(-
|
34
|
+
maglev(-23832)
|
35
35
|
maglev-head
|
36
36
|
|
37
37
|
# Shyouhei head, the default mput
|
data/config/md5
CHANGED
@@ -25,9 +25,11 @@ ruby-1.9.1-p429.tar.gz=0f6d7630f26042e00bc59875755cf879
|
|
25
25
|
ruby-1.9.2-preview1.tar.gz=e2b8cdbf300f53472be09699a5837fd1
|
26
26
|
ruby-1.9.2-preview3.tar.gz=209e59f3495a5503fa948c2732f1d705
|
27
27
|
ruby-1.9.2-rc1.tar.gz=fdedd5b42ae89a9a46797823ad2d9acf
|
28
|
+
ruby-1.9.2-rc2.tar.gz=d12cd39eee4d99bc54b52aba5a0ba4e1
|
28
29
|
ruby-enterprise-1.8.6-20090610.tar.gz=0bf66ee626918464a6eccdd83c99d63a
|
29
30
|
ruby-enterprise-1.8.7-2009.10.tar.gz=3727eef7b6b1b2f31db7d091328d966e
|
30
31
|
ruby-enterprise-1.8.7-20090928.tar.gz=ae00018ce89d95419dfde370fcd485ac
|
32
|
+
ruby-enterprise-1.8.7-2010.02.tar.gz=4df7b09c01adfd711b0ab76837611542
|
31
33
|
rubygems-1.3.5.tgz=6e317335898e73beab15623cdd5f8cff
|
32
34
|
rubygems-1.3.6.tgz=789ca8e9ad1d4d3fe5f0534fcc038a0d
|
33
35
|
rubygems-1.3.7.tgz=e85cfadd025ff6ab689375adbf344bbe
|
@@ -48,8 +50,7 @@ zlib-1.2.3.tar.gz=debc62758716a169df9f62e6ab2bc634
|
|
48
50
|
curl-7.19.7.tar.gz=ecb2e37e45c9933e2a963cabe03670ab
|
49
51
|
pkg-config-0.23.tar.gz=d922a88782b64441d06547632fd85744
|
50
52
|
ironruby-1.0.zip=7a92888837b3507355ed391dbfc0ab83
|
51
|
-
GemStone-
|
52
|
-
GemStone-
|
53
|
-
MagLev-
|
54
|
-
MagLev-
|
55
|
-
|
53
|
+
GemStone-23832.Darwin-i386.tar.gz=2e5d34c21a064b04103def63d0221149
|
54
|
+
GemStone-23832.Linux-x86_64.tar.gz=429f81c5c0ec4c8d7188f176b1dc3374
|
55
|
+
MagLev-23832.Darwin-i386.tar.gz=d9925605f27a2b454aede7b410d99b8b
|
56
|
+
MagLev-23832.Linux-x86_64.tar.gz=f3f7048a353e1b1724adcecb56d50766
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Require root to install it.
|
4
|
+
if [[ "$(whoami)" != "root" ]]; then
|
5
|
+
echo "Please rerun this installer as root." >&2
|
6
|
+
exit 1
|
7
|
+
fi
|
8
|
+
|
9
|
+
# Check for the presence of git.
|
10
|
+
if ! command -v git >/dev/null 2>&1 ; then
|
11
|
+
echo "Please ensure git is installed and available in PATH to continue." >&2
|
12
|
+
exit 1
|
13
|
+
fi
|
14
|
+
|
15
|
+
# Load the rvm config.
|
16
|
+
[[ -s /etc/rvmrc ]] && source /etc/rvmrc
|
17
|
+
[[ -s "$HOME/.rvmrc" ]] && source "$HOME/.rvmrc"
|
18
|
+
|
19
|
+
rvm_path="${rvm_path:-"/usr/local/rvm"}"
|
20
|
+
|
21
|
+
mkdir -p "$rvm_path/src/"
|
22
|
+
builtin cd "$rvm_path/src"
|
23
|
+
|
24
|
+
rm -rf ./rvm/
|
25
|
+
|
26
|
+
git clone --depth 1 git://github.com/wayneeseguin/rvm.git
|
27
|
+
|
28
|
+
builtin cd rvm
|
29
|
+
|
30
|
+
"Running the install script."
|
31
|
+
bash ./scripts/install
|
32
|
+
|
33
|
+
rvm_group_name="${rvm_group_name:-"rvm"}"
|
34
|
+
|
35
|
+
if cat /etc/group | cut -d: -f1 | grep -q "^${rvm_group_name}$"; then
|
36
|
+
echo "Group exists, proceeding with installation."
|
37
|
+
else
|
38
|
+
echo "Creating the group '$rvm_group_name'"
|
39
|
+
groupadd -f "$rvm_group_name"
|
40
|
+
fi
|
41
|
+
echo "Adding root the '$rvm_group_name'"
|
42
|
+
usermod -a -G "$rvm_group_name" "$(whoami)"
|
43
|
+
|
44
|
+
echo "Setting up group permissions"
|
45
|
+
for dir in rvm bin share/man; do
|
46
|
+
chown -R root:"$rvm_group_name" /usr/local/$dir
|
47
|
+
chmod -R g+w /usr/local/$dir
|
48
|
+
done; unset dir
|
49
|
+
|
50
|
+
echo "Generating system wide rvmrc"
|
51
|
+
rm -f /etc/rvmrc
|
52
|
+
touch /etc/rvmrc
|
53
|
+
cat > /etc/rvmrc <<END_OF_RVMRC
|
54
|
+
# Setup default configuration for rvm.
|
55
|
+
export rvm_path="/usr/local/rvm"
|
56
|
+
export rvm_prefix="/usr/local"
|
57
|
+
export rvm_bin_path="\$rvm_prefix/bin"
|
58
|
+
export rvm_man_path="\$rvm_prefix/share/man"
|
59
|
+
END_OF_RVMRC
|
60
|
+
|
61
|
+
echo "Generating /etc/load_rvm to load rvm"
|
62
|
+
rm -f /usr/local/lib/rvm
|
63
|
+
touch /usr/local/lib/rvm
|
64
|
+
cat > /usr/local/lib/rvm <<END_OF_RVM_SH
|
65
|
+
# Automatically source rvm
|
66
|
+
if [[ -s "\$HOME/.rvm/scripts/rvm" ]]; then
|
67
|
+
source "\$HOME/.rvm/scripts/rvm"
|
68
|
+
elif [[ -s "/usr/local/rvm/scripts/rvm" ]]; then
|
69
|
+
source "/usr/local/rvm/scripts/rvm"
|
70
|
+
fi
|
71
|
+
END_OF_RVM_SH
|
72
|
+
|
73
|
+
echo "Correct permissions on rvmrc and load_rvm"
|
74
|
+
# Finally, ensure the rvmrc is owned by the group.
|
75
|
+
for file in /etc/rvmrc /usr/local/lib/rvm ; do
|
76
|
+
chown root:"$rvm_groop_name" "$file"
|
77
|
+
chmod g+w "$file"
|
78
|
+
done; unset file
|
79
|
+
|
80
|
+
echo "To use, source '/usr/local/lib/rvm' to your shell profile."
|
81
|
+
|
data/install
CHANGED
@@ -44,19 +44,19 @@ if echo "$*" | grep -q 'trace' ; then echo "$*" ; env | grep '^rvm_' ; set -x ;
|
|
44
44
|
while [[ $# -gt 0 ]] ; do
|
45
45
|
token="$1" ; shift
|
46
46
|
case "$token" in
|
47
|
-
--auto) rvm_auto_flag=1
|
47
|
+
--auto) rvm_auto_flag=1 ;;
|
48
48
|
--prefix) rvm_prefix="$1" ; shift ;;
|
49
49
|
--version) rvm_path="$(pwd)" ; __rvm_version ; unset rvm_path ; exit ;;
|
50
|
-
--help|*) usage
|
50
|
+
--help|*) usage ;;
|
51
51
|
esac
|
52
52
|
done
|
53
53
|
|
54
54
|
if [[ -z "$rvm_prefix" ]] ; then
|
55
55
|
__rvm_load_rvmrc
|
56
56
|
if [[ "root" = "$(whoami)" ]] ; then
|
57
|
-
rvm_prefix="/usr/local/"
|
57
|
+
rvm_prefix="${rvm_prefix:-"/usr/local/"}"
|
58
58
|
else
|
59
|
-
rvm_prefix="$HOME/."
|
59
|
+
rvm_prefix="${rvm_prefix:-"$HOME/."}"
|
60
60
|
fi
|
61
61
|
fi
|
62
62
|
|
@@ -87,7 +87,7 @@ rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
|
|
87
87
|
rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
|
88
88
|
rvm_log_path="${rvm_log_path:-"$rvm_path/log"}"
|
89
89
|
|
90
|
-
if [[ "root" = "$(whoami)" ]] ; then
|
90
|
+
if [[ -z "$rvm_prefix" ]] && [[ "root" = "$(whoami)" ]] ; then
|
91
91
|
rvm_bin_path="${rvm_bin_path:-"/usr/local/bin"}"
|
92
92
|
else
|
93
93
|
rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
|
@@ -114,7 +114,7 @@ fi
|
|
114
114
|
|
115
115
|
spinner
|
116
116
|
|
117
|
-
mkdir -p $rvm_archives_path $rvm_src_path $rvm_log_path $rvm_bin_path $rvm_gems_path $rvm_rubies_path $rvm_config_path $rvm_hooks_path $rvm_tmp_path
|
117
|
+
mkdir -p $rvm_archives_path $rvm_src_path $rvm_log_path $rvm_bin_path $rvm_gems_path $rvm_rubies_path $rvm_config_path $rvm_hooks_path $rvm_patches_path $rvm_tmp_path
|
118
118
|
|
119
119
|
for file in README LICENCE ; do
|
120
120
|
spinner
|
@@ -139,7 +139,7 @@ if [[ ! -s "$rvm_config_path/user" ]] ; then
|
|
139
139
|
fi
|
140
140
|
|
141
141
|
scripts=("monitor" "match" "log" "install" "color" "db" "fetch" "log" "set" "package")
|
142
|
-
for script_name in $scripts ; do
|
142
|
+
for script_name in "${scripts[@]}" ; do
|
143
143
|
spinner
|
144
144
|
chmod +x $rvm_scripts_path/$script_name
|
145
145
|
done
|
@@ -148,7 +148,7 @@ done
|
|
148
148
|
# Bin Scripts
|
149
149
|
#
|
150
150
|
# Cleanse and purge...
|
151
|
-
for file in rvm-prompt rvm rvmsudo ; do
|
151
|
+
for file in rvm-prompt rvm rvmsudo rvm-shell ; do
|
152
152
|
spinner && perl -e 'sleep 0.2'
|
153
153
|
rm -f "$rvm_bin_path/$file"
|
154
154
|
cp -f "$source_path/binscripts/$file" $rvm_bin_path/
|
@@ -160,7 +160,7 @@ chmod +x $rvm_bin_path/*
|
|
160
160
|
# RC Files
|
161
161
|
#
|
162
162
|
spinner
|
163
|
-
if [[
|
163
|
+
if [[ -n "$rvm_auto_flag" ]] ; then
|
164
164
|
printf "Checking rc files... ($rvm_rc_files)"
|
165
165
|
if [[ "$rvm_loaded_flag" != "1" ]] ; then
|
166
166
|
for rcfile in $(echo $rvm_rc_files) ; do
|
@@ -274,16 +274,16 @@ fi
|
|
274
274
|
# End of gemset migration.
|
275
275
|
#
|
276
276
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
chmod +x $rvm_bin_path
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
277
|
+
printf "\n Correct permissions for base binaries in $rvm_bin_path..."
|
278
|
+
mkdir -p $rvm_bin_path
|
279
|
+
for file in rvm rvmsudo rvm-shell ; do
|
280
|
+
[[ -s "$rvm_bin_path/$file" ]] && chmod +x "$rvm_bin_path/$file"
|
281
|
+
done; unset file
|
282
|
+
printf "\n Copying manpages into place."
|
283
|
+
for man_file in $(\ls "$install_source_path/man"); do
|
284
|
+
rm -rf "$rvm_man_path/$man_file"
|
285
|
+
cp -R "$install_source_path/man/$man_file" "$rvm_man_path/"
|
286
|
+
done
|
287
287
|
|
288
288
|
if [[ "$upgrade_flag" -eq 0 ]] ; then
|
289
289
|
./scripts/notes
|
@@ -303,20 +303,19 @@ if [[ "$upgrade_flag" -eq 1 ]] ; then
|
|
303
303
|
printf "\n$(tput setaf 6)Upgrade Notes\n"
|
304
304
|
printf "\n * 'rvm notes' tells you OS dependency packages for installing rubies."
|
305
305
|
printf "\n * If you encounter any issues with a ruby your best bet is to 'rvm remove X ; rvm install X' "
|
306
|
-
printf "\n * 1.8.7 default patchlevel is p174, override ~/.rvm/config/db in ~/.rvm/config/user"
|
307
306
|
printf "\n * Gemset separator is '@' and will remain unless any rubies error using it."
|
308
307
|
printf "\n$(tput sgr0)\n"
|
309
308
|
check_rubyopt_conditions
|
310
309
|
printf "\nUpgrade of RVM in $rvm_path/ is complete.\n\n"
|
311
310
|
else
|
312
|
-
if [[ "root" != "$(whoami)" ]] ; then
|
311
|
+
if [[ -z "$rvm_prefix" ]] && [[ "root" != "$(whoami)" ]] ; then
|
313
312
|
printf "\n$(tput setaf 1)You must now finish the install manually:$(tput sgr0)"
|
314
313
|
printf "\n1) Place the folowing line at the end of your shell's loading files(.bashrc or .bash_profile for bash and .zshrc for zsh), after all path/variable settings:"
|
315
314
|
printf "\n [[ -s \$HOME/.rvm/scripts/rvm ]] && source \$HOME/.rvm/scripts/rvm"
|
316
315
|
printf "\n Please note that this must only occur once - so, you only need to add it the first time you install rvm."
|
317
316
|
printf "\n2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly)."
|
318
|
-
printf "\n This means that if you see '[ -z "
|
319
|
-
printf "\n if [[
|
317
|
+
printf "\n This means that if you see '[ -z "\$PS1" ] && return' then you must change this line to:"
|
318
|
+
printf "\n if [[ -n "\$PS1" ]] ; then"
|
320
319
|
printf "\n ... original content that was below the && return line ..."
|
321
320
|
printf "\n fi # <= be sure to close the if."
|
322
321
|
printf "\n #EOF .bashrc"
|
@@ -325,7 +324,7 @@ else
|
|
325
324
|
printf "\n placing all non-interactive items in the .bashrc, including the 'source' line above"
|
326
325
|
printf "\n3) Then $(tput setaf 1)CLOSE THIS SHELL$(tput sgr0) and open a new one in order to use rvm.\n"
|
327
326
|
fi
|
328
|
-
if [[ -s $HOME/.bashrc ]] && grep '&& return' $HOME/.bashrc ; then
|
327
|
+
if [[ -s $HOME/.bashrc ]] && grep -q '&& return' $HOME/.bashrc ; then
|
329
328
|
printf "\n\nWARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc."
|
330
329
|
printf "\n This means that if you see '[ -z "\$PS1" ] && return' then you must change this line to:"
|
331
330
|
printf "\n if [[ -n "\$PS1" ]] ; then"
|
data/lib/VERSION.yml
CHANGED
data/lib/rvm.rb
CHANGED
@@ -1 +1,156 @@
|
|
1
|
-
|
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
|