gemrage 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,950 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
source "$rvm_path/scripts/base"
|
4
|
+
|
5
|
+
rvm_ruby_gem_home="${rvm_ruby_gem_home:-$GEM_HOME}"
|
6
|
+
|
7
|
+
if [[ ! -d "$rvm_ruby_gem_home" ]] && command -v gem > /dev/null 2>&1; then rvm_ruby_gem_home="$(gem env home)" ; fi
|
8
|
+
|
9
|
+
usage()
|
10
|
+
{
|
11
|
+
printf "
|
12
|
+
Usage:
|
13
|
+
|
14
|
+
rvm gemset [action]
|
15
|
+
|
16
|
+
Action:
|
17
|
+
|
18
|
+
{import,export,create,copy,empty,delete,name,dir,list,gemdir,install,pristine,clear,use,update,unpack,globalcache}
|
19
|
+
|
20
|
+
Description:
|
21
|
+
|
22
|
+
Commands for working with and manipulating gemsets within RVM.
|
23
|
+
|
24
|
+
"
|
25
|
+
}
|
26
|
+
|
27
|
+
gemset_update()
|
28
|
+
{
|
29
|
+
|
30
|
+
if [[ -z "$rvm_ruby_strings" ]]; then
|
31
|
+
|
32
|
+
"$rvm_path/scripts/log" "info" "Running gem update for all rubies and gemsets."
|
33
|
+
|
34
|
+
rvm_ruby_strings="$(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print 2>/dev/null | grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ',')"
|
35
|
+
|
36
|
+
rvm_ruby_strings="${rvm_ruby_strings/%,}"
|
37
|
+
|
38
|
+
rvm_ruby_strings="${rvm_ruby_strings//.\/}"
|
39
|
+
|
40
|
+
else
|
41
|
+
"$rvm_path/scripts/log" "info" "Running gem update for the specified rubies."
|
42
|
+
fi
|
43
|
+
|
44
|
+
export rvm_ruby_strings
|
45
|
+
|
46
|
+
"$rvm_path/scripts/set" "gem" "update"
|
47
|
+
|
48
|
+
return $?
|
49
|
+
}
|
50
|
+
|
51
|
+
gemset_globalcache()
|
52
|
+
{
|
53
|
+
local gc_status globalcache_enabled directories directory_name full_directory_path directory_name
|
54
|
+
|
55
|
+
if [[ "$1" == "enabled" ]]; then
|
56
|
+
|
57
|
+
__rvm_using_gemset_globalcache
|
58
|
+
|
59
|
+
globalcache_enabled=$?
|
60
|
+
|
61
|
+
gc_status="Unknown"
|
62
|
+
|
63
|
+
if [[ $globalcache_enabled -eq 0 ]]; then
|
64
|
+
gc_status="Enabled"
|
65
|
+
else
|
66
|
+
gc_status="Disabled"
|
67
|
+
fi
|
68
|
+
|
69
|
+
"$rvm_path/scripts/log" "info" \
|
70
|
+
"Gemset global cache is currently: $gc_status"
|
71
|
+
|
72
|
+
return "$globalcache_enabled"
|
73
|
+
|
74
|
+
elif [[ "$1" == "disable" ]]; then
|
75
|
+
|
76
|
+
"$rvm_path/scripts/log" "info" \
|
77
|
+
"Removing the global cache (note: this will empty the caches)"
|
78
|
+
|
79
|
+
directories=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print))
|
80
|
+
|
81
|
+
for directory_name in "${directories[@]//.\/}"; do
|
82
|
+
|
83
|
+
current_cache_path="${rvm_gems_path:-"$rvm_path/gems"}/$directory_name/cache"
|
84
|
+
|
85
|
+
if [[ -L "$current_cache_path" && "$(readlink "$current_cache_path")" == "$rvm_gems_cache_path" ]]; then
|
86
|
+
|
87
|
+
"$rvm_path/scripts/log" "info" \
|
88
|
+
"Reverting the gem cache for $directory_name to an empty directory."
|
89
|
+
|
90
|
+
rm -f "$current_cache_path" 2>/dev/null
|
91
|
+
|
92
|
+
mkdir -p "$current_cache_path" 2>/dev/null
|
93
|
+
fi
|
94
|
+
done
|
95
|
+
|
96
|
+
"$rvm_path/scripts/db" "$rvm_path/config/user" "use_gemset_globalcache" "delete"
|
97
|
+
|
98
|
+
elif [[ "$1" == "enable" ]]; then
|
99
|
+
|
100
|
+
"$rvm_path/scripts/log" "info" \
|
101
|
+
"Enabling global cache for gems."
|
102
|
+
|
103
|
+
mkdir -p "$rvm_gems_cache_path"
|
104
|
+
|
105
|
+
directories=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print))
|
106
|
+
|
107
|
+
for directory_name in "${directories[@]//.\/}" ; do
|
108
|
+
|
109
|
+
current_cache_path="${rvm_gems_path:-"$rvm_path/gems"}/$directory_name/cache"
|
110
|
+
|
111
|
+
if [[ -d "$current_cache_path" && ! -L "$current_cache_path" ]]; then
|
112
|
+
|
113
|
+
"$rvm_path/scripts/log" "info" "Moving the gem cache for $directory_name to the global cache."
|
114
|
+
|
115
|
+
mv "$current_cache_path/"*.gem "$rvm_gems_cache_path/" 2>/dev/null
|
116
|
+
|
117
|
+
rm -rf "$current_cache_path"
|
118
|
+
|
119
|
+
ln -nfs "$rvm_gems_cache_path" "$current_cache_path"
|
120
|
+
fi
|
121
|
+
|
122
|
+
done
|
123
|
+
|
124
|
+
"$rvm_path/scripts/db" "$rvm_path/config/user" "use_gemset_globalcache" "true"
|
125
|
+
|
126
|
+
else
|
127
|
+
printf "
|
128
|
+
|
129
|
+
Usage:
|
130
|
+
|
131
|
+
rvm gemset globalcache {enable,disable}
|
132
|
+
|
133
|
+
Enable / Disable the use of a global gem cachedir.
|
134
|
+
|
135
|
+
"
|
136
|
+
return 1
|
137
|
+
fi
|
138
|
+
}
|
139
|
+
|
140
|
+
gemset_name()
|
141
|
+
{
|
142
|
+
gemset_dir | awk -F${rvm_gemset_separator:-"@"} '{print $2}'
|
143
|
+
return $?
|
144
|
+
}
|
145
|
+
|
146
|
+
gemset_dir()
|
147
|
+
{
|
148
|
+
echo "$rvm_ruby_gem_home"
|
149
|
+
return $?
|
150
|
+
}
|
151
|
+
|
152
|
+
gemset_create()
|
153
|
+
{
|
154
|
+
local gem_home gemset gemsets prefix
|
155
|
+
|
156
|
+
if [[ -n "$rvm_ruby_string" ]] ; then
|
157
|
+
__rvm_select
|
158
|
+
fi
|
159
|
+
|
160
|
+
prefix=$(echo $rvm_ruby_gem_home | sed 's/'${rvm_gemset_separator:-"@"}'.*$//')
|
161
|
+
|
162
|
+
gemsets=(${args[@]})
|
163
|
+
|
164
|
+
for gemset in "${gemsets[@]}" ; do
|
165
|
+
|
166
|
+
if [[ "$gemset" == *"${rvm_gemset_separator:-"@"}"* ]]; then
|
167
|
+
"$rvm_path/scripts/log" "error" \
|
168
|
+
"Can not create gemset '$gemset', it contains a \"${rvm_gemset_separator:-"@"}\"."
|
169
|
+
continue
|
170
|
+
fi
|
171
|
+
|
172
|
+
if [[ -z "$gemset" || "$gemset" = *"${rvm_gemset_separator:-"@"}" ]] ; then
|
173
|
+
"$rvm_path/scripts/log" "error" \
|
174
|
+
"Can not create gemset '$gemset', Missing name. "
|
175
|
+
continue
|
176
|
+
fi
|
177
|
+
|
178
|
+
gem_home="${prefix}${rvm_gemset_separator:-"@"}${gemset}"
|
179
|
+
|
180
|
+
if [[ ! -d "$gem_home" ]] ; then
|
181
|
+
mkdir -p "$gem_home"
|
182
|
+
fi
|
183
|
+
|
184
|
+
# When the globalcache is enabled, we need to ensure we setup the cache directory correctly.
|
185
|
+
if __rvm_using_gemset_globalcache ; then
|
186
|
+
|
187
|
+
if [[ -d "$gem_home/cache" && ! -L "$gem_home/cache" ]]; then
|
188
|
+
|
189
|
+
mv "$gem_home/cache"/*.gem "$rvm_gems_cache_path/" 2>/dev/null
|
190
|
+
|
191
|
+
rm -rf "$gem_home/cache"
|
192
|
+
fi
|
193
|
+
|
194
|
+
ln -nfs "$rvm_gems_cache_path" "$gem_home/cache"
|
195
|
+
fi
|
196
|
+
|
197
|
+
"$rvm_path/scripts/log" "info" "'$gemset' gemset created ($gem_home)."
|
198
|
+
done
|
199
|
+
|
200
|
+
return 0
|
201
|
+
}
|
202
|
+
|
203
|
+
gemset_list()
|
204
|
+
{
|
205
|
+
if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
|
206
|
+
|
207
|
+
"$rvm_path/scripts/log" "info" \
|
208
|
+
"\ngemsets for $rvm_ruby_string (found in ${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string)"
|
209
|
+
|
210
|
+
if [[ -d "${rvm_gems_path:-"$rvm_path/gems"}" ]] ; then
|
211
|
+
|
212
|
+
if [[ -n "${rvm_ruby_string:-""}" ]] ; then
|
213
|
+
|
214
|
+
ls "${rvm_gems_path:-"$rvm_path/gems"}/" | awk -F"${rvm_gemset_separator:-"@"}" "/${rvm_ruby_string}${rvm_gemset_separator:-"@"}/{print \$2}" 2>/dev/null
|
215
|
+
|
216
|
+
else
|
217
|
+
"$rvm_path/scripts/log" "error" \
|
218
|
+
"\$rvm_ruby_string is not set!"
|
219
|
+
return 1
|
220
|
+
fi
|
221
|
+
|
222
|
+
else
|
223
|
+
"$rvm_path/scripts/log" "error" \
|
224
|
+
"${rvm_gems_path:-"$rvm_path/gems"} does not exist!"
|
225
|
+
return 1
|
226
|
+
fi
|
227
|
+
printf "\n"
|
228
|
+
|
229
|
+
return 0
|
230
|
+
}
|
231
|
+
|
232
|
+
gemset_delete()
|
233
|
+
{
|
234
|
+
gemsets=(${args[@]})
|
235
|
+
|
236
|
+
if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
|
237
|
+
|
238
|
+
if [[ -n "${gemsets[__array_start]}" ]] ; then
|
239
|
+
rvm_gemset_name="${gemsets[__array_start]}"
|
240
|
+
fi
|
241
|
+
|
242
|
+
if [[ -n "$rvm_gemset_name" ]] ; then
|
243
|
+
|
244
|
+
gemdir="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name"
|
245
|
+
|
246
|
+
if [[ -d "$gemdir" && "$gemdir" != '/' && ${rvm_force_flag:-0} -gt 0 ]] ; then
|
247
|
+
|
248
|
+
rm -rf "$gemdir"
|
249
|
+
|
250
|
+
elif [[ -d "$gemdir" ]] ; then
|
251
|
+
|
252
|
+
"$rvm_path/scripts/log" "warn" "Are you SURE you wish to remove the entire gemset directory '$rvm_gemset_name' ($gemdir)?"
|
253
|
+
|
254
|
+
printf "(anything other than 'yes' will cancel) > "
|
255
|
+
|
256
|
+
read response
|
257
|
+
|
258
|
+
if [[ "yes" = "$response" ]] ; then
|
259
|
+
|
260
|
+
if [[ -L "$gemdir/cache" ]] ; then
|
261
|
+
rm -f "$gemdir/cache"
|
262
|
+
fi
|
263
|
+
|
264
|
+
rm -rf "$gemdir"
|
265
|
+
|
266
|
+
else
|
267
|
+
"$rvm_path/scripts/log" "info" \
|
268
|
+
"Not doing anything, phew... close call that one eh?"
|
269
|
+
fi
|
270
|
+
|
271
|
+
else
|
272
|
+
"$rvm_path/scripts/log" "info" \
|
273
|
+
"$gemdir already does not exist."
|
274
|
+
fi
|
275
|
+
|
276
|
+
else
|
277
|
+
"$rvm_path/scripts/log" "error" \
|
278
|
+
"A gemset name must be specified in order to delete a gems."
|
279
|
+
return 1
|
280
|
+
fi
|
281
|
+
|
282
|
+
return 0
|
283
|
+
}
|
284
|
+
|
285
|
+
gemset_empty()
|
286
|
+
{
|
287
|
+
local gemdir
|
288
|
+
|
289
|
+
if [[ -z "${rvm_ruby_gem_home:-""}" ]] ; then __rvm_select ; fi
|
290
|
+
|
291
|
+
gemdir="$rvm_ruby_gem_home"
|
292
|
+
|
293
|
+
if [[ -d "$gemdir" && "$gemdir" != '/' && ${rvm_force_flag:-0} -gt 0 ]] ; then
|
294
|
+
|
295
|
+
builtin cd "$gemdir" && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
|
296
|
+
|
297
|
+
elif [[ -d "$gemdir" ]] ; then
|
298
|
+
|
299
|
+
"$rvm_path/scripts/log" "warn" \
|
300
|
+
"Are you SURE you wish to remove the installed gemset for gemset '$(basename "$gemdir")' ($gemdir)?"
|
301
|
+
|
302
|
+
echo -n "(anything other than 'yes' will cancel) > "
|
303
|
+
|
304
|
+
read response
|
305
|
+
|
306
|
+
if [[ "yes" = "$response" ]] ; then
|
307
|
+
|
308
|
+
builtin cd "$gemdir" && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
|
309
|
+
|
310
|
+
else
|
311
|
+
"$rvm_path/scripts/log" "info" \
|
312
|
+
"Not doing anything, phew... close call that one eh?"
|
313
|
+
fi
|
314
|
+
|
315
|
+
else
|
316
|
+
"$rvm_path/scripts/log" "info" \
|
317
|
+
"$gemdir already does not exist."
|
318
|
+
fi
|
319
|
+
|
320
|
+
return 0
|
321
|
+
}
|
322
|
+
|
323
|
+
# Migrate gemsets from ruby X to ruby Y
|
324
|
+
gemset_copy()
|
325
|
+
{
|
326
|
+
local source_ruby destination_ruby source_path destination_path
|
327
|
+
|
328
|
+
source_ruby="${args[__array_start]:-""}"
|
329
|
+
args[$__array_start]="" ; args=(${args[@]})
|
330
|
+
|
331
|
+
destination_ruby="${args[__array_start]:-""}"
|
332
|
+
args[$__array_start]="" ; args=(${args[@]})
|
333
|
+
|
334
|
+
if [[ -z "$destination_ruby" || -z "$source_ruby" ]] ; then
|
335
|
+
"$rvm_path/scripts/log" "error" "Source and destination must be specified: 'rvm gemset copy X Y'"
|
336
|
+
return 1
|
337
|
+
fi
|
338
|
+
|
339
|
+
# TODO: Account for more possibilities:
|
340
|
+
# rvm gemset copy 1.9.2 @gemsetb # From 1.9.2 default to current ruby, 1.9.2 exists.
|
341
|
+
# rvm gemset copy @gemseta @gemsetb # Current ruby, gemseta exists.
|
342
|
+
# rvm gemset copy gemseta gemsetb # Currenty Ruby, gemseta exists.
|
343
|
+
# rvm gemset copy gemseta 1.8.7@gemsetb # Currenty Ruby@gemseta, current ruby@gemseta exists.
|
344
|
+
|
345
|
+
source_path="$(rvm_silence_logging=1 rvm "$source_ruby" gem env gemdir)"
|
346
|
+
|
347
|
+
destination_path="$(rvm_silence_logging=1 rvm "$destination_ruby" gem env gemdir)"
|
348
|
+
|
349
|
+
if [[ -z "$source_path" || ! -d "$source_path" ]]; then
|
350
|
+
"$rvm_path/scripts/log" "error" \
|
351
|
+
"Unable to expand '$source_ruby' or directory does not exist."
|
352
|
+
return 1
|
353
|
+
fi
|
354
|
+
|
355
|
+
if [[ -z "$destination_path" ]]; then
|
356
|
+
"$rvm_path/scripts/log" "error" \
|
357
|
+
"Unable to expand '$destination_ruby'"
|
358
|
+
return 1
|
359
|
+
fi
|
360
|
+
|
361
|
+
if [[ -d "$source_path" ]] ; then
|
362
|
+
|
363
|
+
"$rvm_path/scripts/log" "info" "Copying gemset from $source_ruby to $destination_ruby"
|
364
|
+
|
365
|
+
for dir in bin doc gems specifications cache ; do
|
366
|
+
|
367
|
+
mkdir -p "$destination_path/$dir"
|
368
|
+
|
369
|
+
if [[ -d "$source_path/$dir" ]] ; then
|
370
|
+
cp -Rf "$source_path/$dir" "$destination_path/"
|
371
|
+
|
372
|
+
elif [[ -L "$source_path/$dir" ]] ; then
|
373
|
+
cp "$source_path/$dir" "$destination_path/$dir"
|
374
|
+
fi
|
375
|
+
|
376
|
+
done
|
377
|
+
|
378
|
+
"$rvm_path/scripts/log" "info" \
|
379
|
+
"Making gemset for $destination_ruby pristine."
|
380
|
+
|
381
|
+
__rvm_run_with_env "gemset.pristine" "$destination_ruby" "rvm gemset pristine"
|
382
|
+
|
383
|
+
else
|
384
|
+
"$rvm_path/scripts/log" "error" \
|
385
|
+
"Gems directory does not exist for $source_path ($source_path)"
|
386
|
+
return 1
|
387
|
+
fi
|
388
|
+
}
|
389
|
+
|
390
|
+
gemset_unpack()
|
391
|
+
{
|
392
|
+
local gems name directory version versions
|
393
|
+
|
394
|
+
directory="${args[$__array_start]}"
|
395
|
+
|
396
|
+
if [[ -z "$directory" ]] ; then
|
397
|
+
directory="vendor/gems"
|
398
|
+
fi
|
399
|
+
|
400
|
+
if [[ -n "$rvm_ruby_gem_home" ]] ; then
|
401
|
+
export GEM_HOME="$rvm_ruby_gem_home"
|
402
|
+
export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin"
|
403
|
+
export BUNDLE_PATH="$rvm_ruby_gem_home"
|
404
|
+
fi
|
405
|
+
|
406
|
+
"$rvm_path/scripts/log" "info" \
|
407
|
+
"Unpacking current environments gemset to ${directory}\n"
|
408
|
+
|
409
|
+
unset -f gem
|
410
|
+
|
411
|
+
gems=($(command gem list | sed 's#[\(|\)]##g' | sed -e 's#, #,#g' -e 's/ /;/g'))
|
412
|
+
|
413
|
+
for gem in ${gems[@]} ; do
|
414
|
+
|
415
|
+
name="${gem/;*/}"
|
416
|
+
|
417
|
+
versions="${gem/*;/}" ; versions=(${versions//,/ })
|
418
|
+
|
419
|
+
for version in "${versions[@]}" ; do
|
420
|
+
|
421
|
+
( command gem unpack "$name" -v"$version" --target "$directory" )&
|
422
|
+
|
423
|
+
done
|
424
|
+
|
425
|
+
done ; wait
|
426
|
+
|
427
|
+
"$rvm_path/scripts/log" "info" \
|
428
|
+
"Unpacking into ${directory} complete\n"
|
429
|
+
|
430
|
+
return 0
|
431
|
+
}
|
432
|
+
|
433
|
+
gemset_export()
|
434
|
+
{
|
435
|
+
local gems name file_name version versions
|
436
|
+
|
437
|
+
rvm_file_name="${rvm_file_name:-${gems_args// }}"
|
438
|
+
|
439
|
+
if [[ -n "$rvm_ruby_gem_home" ]] ; then
|
440
|
+
export GEM_HOME="$rvm_ruby_gem_home"
|
441
|
+
export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin"
|
442
|
+
export BUNDLE_PATH="$rvm_ruby_gem_home"
|
443
|
+
fi
|
444
|
+
|
445
|
+
if [[ -z "$rvm_file_name" ]] ; then
|
446
|
+
|
447
|
+
if [[ -n "$rvm_gemset_name" ]] ; then
|
448
|
+
rvm_file_name="$rvm_gemset_name.gems"
|
449
|
+
|
450
|
+
else
|
451
|
+
rvm_file_name="default.gems"
|
452
|
+
fi
|
453
|
+
fi
|
454
|
+
|
455
|
+
"$rvm_path/scripts/log" "info" \
|
456
|
+
"Exporting current environments gemset to $rvm_file_name"
|
457
|
+
|
458
|
+
touch "$rvm_file_name"
|
459
|
+
|
460
|
+
echo "# $rvm_file_name generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator" > "$rvm_file_name"
|
461
|
+
|
462
|
+
gems=($(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | tr ' ' ';'))
|
463
|
+
|
464
|
+
for gem in "${gems[@]}" ; do
|
465
|
+
|
466
|
+
name="${gem/;*/}"
|
467
|
+
|
468
|
+
if [[ ${rvm_latest_flag:-0} -eq 0 ]] ; then
|
469
|
+
|
470
|
+
versions="${gem/*;/}" ; versions="${versions//,/ }"
|
471
|
+
|
472
|
+
for version in $versions ; do
|
473
|
+
echo "$name -v$version" >> $rvm_file_name
|
474
|
+
done ; unset version versions
|
475
|
+
|
476
|
+
else
|
477
|
+
echo "$name" >> $rvm_file_name
|
478
|
+
fi
|
479
|
+
done
|
480
|
+
|
481
|
+
return 0
|
482
|
+
}
|
483
|
+
|
484
|
+
gemset_import()
|
485
|
+
{
|
486
|
+
unset -f gem
|
487
|
+
|
488
|
+
if [[ -n "${rvm_ruby_gem_home:-""}" ]] ; then
|
489
|
+
export GEM_HOME="$rvm_ruby_gem_home"
|
490
|
+
export GEM_PATH="$rvm_ruby_gem_home"
|
491
|
+
export BUNDLE_PATH="$rvm_ruby_gem_home"
|
492
|
+
else
|
493
|
+
rvm_ruby_gem_home=${GEM_HOME:-$(gem env gemdir)}
|
494
|
+
fi
|
495
|
+
|
496
|
+
#rvm_gemset_name="${gems_args//.gem*/}"
|
497
|
+
#rvm_gemset_name="${gems_args// /}"
|
498
|
+
|
499
|
+
rvm_file_name="${gems_args// /}"
|
500
|
+
|
501
|
+
# TODO: this could likely be better with find
|
502
|
+
if [[ -s "${rvm_file_name%.gems*}.gems" ]] ; then
|
503
|
+
rvm_file_name="${rvm_file_name%.gems*}.gems"
|
504
|
+
|
505
|
+
elif [[ -s "${rvm_gemset_name}.gems" ]] ; then
|
506
|
+
rvm_file_name="${rvm_gemset_name}.gems"
|
507
|
+
|
508
|
+
elif [[ -s "default.gems" ]] ; then
|
509
|
+
rvm_file_name="default.gems"
|
510
|
+
|
511
|
+
elif [[ -s "system.gems" ]] ; then
|
512
|
+
rvm_file_name="system.gems"
|
513
|
+
|
514
|
+
elif [[ -s ".gems" ]] ; then
|
515
|
+
rvm_file_name=".gems"
|
516
|
+
|
517
|
+
else
|
518
|
+
"$rvm_path/scripts/log" "error" "No *.gems file found."
|
519
|
+
return 1
|
520
|
+
fi
|
521
|
+
|
522
|
+
if [[ ! -d "$rvm_ruby_gem_home/specifications/" ]] ; then
|
523
|
+
mkdir -p "$rvm_ruby_gem_home/specifications/"
|
524
|
+
fi
|
525
|
+
|
526
|
+
if [[ ! -d "$rvm_gems_cache_path" ]] ; then
|
527
|
+
mkdir -p "$rvm_gems_cache_path" # Ensure the base cache dir is initialized.
|
528
|
+
fi
|
529
|
+
|
530
|
+
if [[ -s "$rvm_file_name" ]] ; then
|
531
|
+
|
532
|
+
echo "Importing $rvm_file_name file..."
|
533
|
+
|
534
|
+
rvm_ruby_gem_list=$(builtin cd "$rvm_ruby_gem_home/specifications/" ; find . -maxdepth 1 -mindepth 1 -type f -print 2> /dev/null | sed -e 's#.gems.*$##' 2> /dev/null)
|
535
|
+
rvm_ruby_gem_list="${rvm_ruby_gem_list//.\/}"
|
536
|
+
|
537
|
+
while read -r line
|
538
|
+
do # Keep this on 2nd line :(
|
539
|
+
|
540
|
+
if [[ -n "${line// /}" ]] ; then
|
541
|
+
gems_args="$line" ; gem_install
|
542
|
+
fi
|
543
|
+
|
544
|
+
done < <(awk '/^[^#]+/{print}' "${rvm_file_name}")
|
545
|
+
|
546
|
+
else
|
547
|
+
"$rvm_path/scripts/log" "error" "${rvm_file_name} does not exist to import from."
|
548
|
+
fi
|
549
|
+
}
|
550
|
+
|
551
|
+
__rvm_parse_gems_args()
|
552
|
+
{
|
553
|
+
gem="${gems_args/;*}" ; gem_prefix=""
|
554
|
+
|
555
|
+
if echo "$gems_args" | grep -q ';' ; then
|
556
|
+
gem_prefix="${gems_args/*;}"
|
557
|
+
fi
|
558
|
+
|
559
|
+
if "$rvm_path/scripts/match" "$gem" ".gem$" ; then
|
560
|
+
gem_name="$(basename "${gem/.gem/}" | awk -F'-' '{$NF=NULL;print}')"
|
561
|
+
gem_version="$(basename "${gem/.gem/}" | awk -F'-' '{print $NF}' )"
|
562
|
+
gem_postfix="$(basename "${gem/*.gem/}")"
|
563
|
+
|
564
|
+
else
|
565
|
+
gem_name="${gem/ */}"
|
566
|
+
|
567
|
+
if "$rvm_path/scripts/match" "$gem" "--version" ; then
|
568
|
+
gem_version="$(echo "$gem" | sed -e 's#.*--version[=]*[ ]*##' | awk '{print $1}')"
|
569
|
+
gem_postfix="$(echo "$gem" | sed -e "s#${gem_name/ /}##" -e "s#--version[=]*[ ]*${gem_version/ /}##")"
|
570
|
+
|
571
|
+
elif "$rvm_path/scripts/match" "$gem" "-v" ; then
|
572
|
+
gem_version="$(echo "$gem" | sed -e 's#.*-v[=]*[ ]*##' | awk '{print $1}')"
|
573
|
+
gem_postfix="$(echo "$gem" | sed -e "s#${gem_name/ /}##" -e "s#-v[=]*[ ]*${gem_version/ /}##")"
|
574
|
+
|
575
|
+
else
|
576
|
+
unset gem_version # no version
|
577
|
+
fi
|
578
|
+
fi
|
579
|
+
|
580
|
+
if [[ -s "$gem" ]] ; then
|
581
|
+
gem_file_name="$gem"
|
582
|
+
|
583
|
+
elif "$rvm_path/scripts/match" "$gem" ".gem$" ; then
|
584
|
+
gem_file_name="$gem"
|
585
|
+
|
586
|
+
elif [[ -z "${gem_version/ /}" ]] ; then
|
587
|
+
gem_file_name="${gem_name/ /}*.gem"
|
588
|
+
|
589
|
+
else # version
|
590
|
+
gem_file_name="${gem_name/ /}-${gem_version/ /}.gem"
|
591
|
+
fi
|
592
|
+
}
|
593
|
+
|
594
|
+
# Install a gem
|
595
|
+
gem_install()
|
596
|
+
{
|
597
|
+
local gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action
|
598
|
+
|
599
|
+
result=0
|
600
|
+
|
601
|
+
# First we parse the gem args to pick apart the pieces.
|
602
|
+
__rvm_parse_gems_args
|
603
|
+
|
604
|
+
# Now we determine if a .gem cache file is already installed
|
605
|
+
if [[ ${rvm_force_flag:-0} -eq 0 && -f "${rvm_ruby_gem_home}/specifications/$(basename "$gem_file_name")spec" ]] ; then
|
606
|
+
gem=""
|
607
|
+
|
608
|
+
"$rvm_path/scripts/log" "info" \
|
609
|
+
"$gem_name $gem_version exists, skipping (--force to re-install)"
|
610
|
+
|
611
|
+
else
|
612
|
+
if [[ -s "$gem" ]] ; then
|
613
|
+
cache_file="$gem"
|
614
|
+
|
615
|
+
elif [[ -s "$(__rvm_current_gemcache_dir)/${gem_file_name}" ]] ; then
|
616
|
+
cache_file="$(__rvm_current_gemcache_dir)/${gem_file_name}"
|
617
|
+
|
618
|
+
else
|
619
|
+
cache_file="${cache_file:-$( find "$(__rvm_current_gemcache_dir)/${gem_file_name}" -maxdepth 1 -mindepth 1 -type f -print 2> /dev/null | sort | head -n1)}"
|
620
|
+
cache_file="${cache_file//.\/}"
|
621
|
+
fi
|
622
|
+
|
623
|
+
if [[ ! -s "$cache_file" ]] ; then
|
624
|
+
|
625
|
+
if [[ -s "$gem_file_name" ]] ; then
|
626
|
+
gem="$gem_file_name"
|
627
|
+
|
628
|
+
elif [[ -z "${gem_version// /}" ]] ; then
|
629
|
+
gem="${gem_name// /}"
|
630
|
+
|
631
|
+
else
|
632
|
+
gem="${gem_name// /} -v $gem_version"
|
633
|
+
fi
|
634
|
+
else # cached
|
635
|
+
|
636
|
+
gem_file_name="$(basename "$cache_file")"
|
637
|
+
|
638
|
+
gem_string="$(echo "$gem_file_name" | sed 's#\.gem$##')"
|
639
|
+
|
640
|
+
if [[ ${rvm_force_flag:-0} -eq 0 && -s "${rvm_ruby_gem_home}/specifications/$(basename $gem_file_name)spec" ]] ; then
|
641
|
+
unset gem # already installed, not forcing reinstall.
|
642
|
+
|
643
|
+
"$rvm_path/scripts/log" "info" "$gem_name $gem_version exists, skipping (--force to re-install)"
|
644
|
+
|
645
|
+
else
|
646
|
+
if [[ -s "$(__rvm_current_gemcache_dir)/$(basename $gem_file_name)" ]] ; then
|
647
|
+
|
648
|
+
mkdir -p "${rvm_tmp_path:-"$rvm_path/tmp"}/$$/"
|
649
|
+
|
650
|
+
mv "$(__rvm_current_gemcache_dir)/$gem_file_name" "${rvm_tmp_path:-"$rvm_path/tmp"}/$$/$gem_file_name"
|
651
|
+
|
652
|
+
gem="${rvm_tmp_path:-"$rvm_path/tmp"}/$$/$gem_file_name -f -l"
|
653
|
+
else
|
654
|
+
gem="$cache_file"
|
655
|
+
fi
|
656
|
+
fi
|
657
|
+
fi
|
658
|
+
fi
|
659
|
+
|
660
|
+
# If $gem is still set, go forward with the install.
|
661
|
+
if [[ -n "$gem" ]] ; then
|
662
|
+
|
663
|
+
# TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line.
|
664
|
+
if [[ "rvm_make_flags_flag" -eq 1 ]] ; then __rvm_make_flags ; fi
|
665
|
+
|
666
|
+
if [[ -n "$rvm_ruby_gem_home" && "$rvm_ruby_gem_home" != "${rvm_gems_path:-"$rvm_path/gems"}" ]] ; then
|
667
|
+
|
668
|
+
command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home' BUNDLE_PATH='${rvm_ruby_gem_home}' $gem_prefix gem install $gems_args $rvm_gem_options $gem_postfix $vars"
|
669
|
+
|
670
|
+
else
|
671
|
+
|
672
|
+
#--ignore-dependencies
|
673
|
+
command="$gem_prefix gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
|
674
|
+
|
675
|
+
fi
|
676
|
+
|
677
|
+
unset -f gem
|
678
|
+
|
679
|
+
__rvm_run "gem.install" "$command" "installing ${gem_name} ${gem_version}..."
|
680
|
+
result=$?
|
681
|
+
|
682
|
+
if [[ $result -eq 0 ]] ; then
|
683
|
+
|
684
|
+
"$rvm_path/scripts/log" "info" \
|
685
|
+
"$gem_name $gem_version installed ( output logged to: $rvm_path/log/$rvm_ruby_string/gem.install.log )"
|
686
|
+
|
687
|
+
else
|
688
|
+
|
689
|
+
"$rvm_path/scripts/log" "error" \
|
690
|
+
"$gem_name $gem_version failed to install ( output logged to: $rvm_path/log/$rvm_ruby_string/gem.install.error.log )"
|
691
|
+
|
692
|
+
fi
|
693
|
+
fi
|
694
|
+
|
695
|
+
return $result
|
696
|
+
}
|
697
|
+
|
698
|
+
# Output the user's current gem directory.
|
699
|
+
gemset_info()
|
700
|
+
{
|
701
|
+
if [[ ${rvm_user_flag:-0} -eq 1 ]] ; then
|
702
|
+
echo $(rvm system ; gem env | grep "\- $HOME" | awk '{print $NF}')
|
703
|
+
|
704
|
+
elif [[ ${rvm_system_flag:-0} -eq 1 ]] ; then
|
705
|
+
echo $(rvm system ; gem env $action system)
|
706
|
+
|
707
|
+
elif [[ -n "${rvm_ruby_string:-""}" ]] ; then
|
708
|
+
echo $(rvm "$rvm_ruby_string" ; gem env $action)
|
709
|
+
|
710
|
+
elif [[ -n "${GEM_HOME:-""}" ]] ; then
|
711
|
+
echo "$GEM_HOME"
|
712
|
+
|
713
|
+
else
|
714
|
+
gem env $action
|
715
|
+
fi
|
716
|
+
|
717
|
+
return $?
|
718
|
+
}
|
719
|
+
|
720
|
+
gemset_prune()
|
721
|
+
{
|
722
|
+
local temporary_cache_path live_cache_path gemset_name version versions cached_gem_name cached_file_path
|
723
|
+
|
724
|
+
temporary_cache_path="$GEM_HOME/temporary-cache"
|
725
|
+
|
726
|
+
live_cache_path="$GEM_HOME/cache"
|
727
|
+
|
728
|
+
mkdir -p "$temporary_cache_path"
|
729
|
+
|
730
|
+
"$rvm_path/scripts/log" "info" \
|
731
|
+
"Moving active gems into temporary cache..."
|
732
|
+
|
733
|
+
while read -r used_gem
|
734
|
+
do
|
735
|
+
gem_name="$(echo "$used_gem" | sed -e 's/ .*//')"
|
736
|
+
|
737
|
+
versions="$(echo "${used_gem//, / }" | sed -e 's/.* (//' -e 's/)//')"
|
738
|
+
|
739
|
+
for version in $versions; do
|
740
|
+
|
741
|
+
cached_gem_name="${gem_name}-${version}.gem"
|
742
|
+
|
743
|
+
cached_file_path="${live_cache_path}/${cached_gem_name}"
|
744
|
+
|
745
|
+
if [[ -f "$cached_file_path" ]]; then
|
746
|
+
mv "$cached_file_path" "${temporary_cache_path}/${cached_gem_name}"
|
747
|
+
fi
|
748
|
+
done
|
749
|
+
done < <(gem list --versions)
|
750
|
+
|
751
|
+
"$rvm_path/scripts/log" "info" \
|
752
|
+
"Removing live cache and restoring temporary cache..."
|
753
|
+
|
754
|
+
# Switch the cache back.
|
755
|
+
rm -rf "$live_cache_path"
|
756
|
+
|
757
|
+
mv "$temporary_cache_path" "$live_cache_path"
|
758
|
+
|
759
|
+
return 0
|
760
|
+
}
|
761
|
+
|
762
|
+
gemset_pristine()
|
763
|
+
{
|
764
|
+
if ( unset -f gem ; command -v gem > /dev/null ) ; then
|
765
|
+
|
766
|
+
gem pristine --all
|
767
|
+
|
768
|
+
return $?
|
769
|
+
|
770
|
+
else
|
771
|
+
|
772
|
+
"$rvm_path/scripts/log" "error" \
|
773
|
+
"'gem' command not found in PATH"
|
774
|
+
|
775
|
+
return 1
|
776
|
+
fi
|
777
|
+
}
|
778
|
+
|
779
|
+
# Loads the default gemsets for the current interpreter and gemset.
|
780
|
+
gemset_initial()
|
781
|
+
{
|
782
|
+
local gemsets gemset path paths
|
783
|
+
|
784
|
+
rvm_gemsets_path="${rvm_gemsets_path:-"$rvm_path/gemsets"}"
|
785
|
+
|
786
|
+
"$rvm_path/scripts/log" "info" \
|
787
|
+
"Importing initial gemsets for $(__rvm_environment_identifier)."
|
788
|
+
|
789
|
+
if [[ ! -d "$rvm_gemsets_path/${rvm_ruby_string//-//}" ]] ; then
|
790
|
+
mkdir -p "$rvm_gemsets_path/${rvm_ruby_string//-//}" 2>/dev/null
|
791
|
+
fi
|
792
|
+
|
793
|
+
paths=($(__rvm_ruby_string_paths_under "$rvm_gemsets_path"))
|
794
|
+
|
795
|
+
echo "paths: ${paths[@]}"
|
796
|
+
|
797
|
+
for path in "${paths[@]}" ; do
|
798
|
+
|
799
|
+
if [[ -n "$rvm_gemset_name" ]] ; then
|
800
|
+
|
801
|
+
if [[ -s "${rvm_gemset_name}.gems" ]] ; then
|
802
|
+
|
803
|
+
( gems_args="${rvm_gemset_name}.gems" ; gemset_import )
|
804
|
+
|
805
|
+
fi
|
806
|
+
|
807
|
+
else
|
808
|
+
|
809
|
+
if [[ -s "${path}/default.gems" ]] ; then
|
810
|
+
|
811
|
+
( gems_args="${path}/default.gems" ; gemset_import )
|
812
|
+
|
813
|
+
fi
|
814
|
+
|
815
|
+
if [[ -s "${path}/global.gems" ]] ; then
|
816
|
+
|
817
|
+
(
|
818
|
+
rvm_create_flag=1
|
819
|
+
rvm_ruby_gem_home="${rvm_ruby_gem_home//@*/}@global"
|
820
|
+
gems_args="${path}/global.gems"
|
821
|
+
gemset_import
|
822
|
+
)
|
823
|
+
|
824
|
+
fi
|
825
|
+
|
826
|
+
fi
|
827
|
+
|
828
|
+
done
|
829
|
+
|
830
|
+
"$rvm_path/scripts/log" "info" \
|
831
|
+
"Installation of gems for $(__rvm_environment_identifier) is complete."
|
832
|
+
|
833
|
+
return 0
|
834
|
+
}
|
835
|
+
|
836
|
+
unset GEM_PATH
|
837
|
+
|
838
|
+
if ! command -v gem > /dev/null ; then
|
839
|
+
"$rvm_path/scripts/log" "error" \
|
840
|
+
"'gem' was not found, cannot perform gem actions (Do you have an RVM ruby selected?)"
|
841
|
+
exit 1
|
842
|
+
fi
|
843
|
+
|
844
|
+
args=($*)
|
845
|
+
action="${args[$__array_start]}"
|
846
|
+
args[$__array_start]=""
|
847
|
+
args=(${args[@]})
|
848
|
+
gems_args="$(echo ${args[@]}) " # Strip trailing / leading / extra spacing.
|
849
|
+
|
850
|
+
export rvm_gemset_name="${args[1]:-""}" # For wherever used.
|
851
|
+
rvm_sticky_flag=1
|
852
|
+
|
853
|
+
if [[ -z "$rvm_ruby_string" ]] ; then
|
854
|
+
|
855
|
+
if echo "${GEM_HOME:-""}" | grep -q 'rvm' ; then
|
856
|
+
|
857
|
+
rvm_ruby_string="${GEM_HOME##*/}"
|
858
|
+
|
859
|
+
rvm_ruby_string="${rvm_ruby_string%%@*}"
|
860
|
+
|
861
|
+
fi
|
862
|
+
|
863
|
+
fi
|
864
|
+
|
865
|
+
case "$action" in
|
866
|
+
|
867
|
+
import|load)
|
868
|
+
|
869
|
+
if [[ -z "${rvm_ruby_strings:-""}" ]]; then
|
870
|
+
|
871
|
+
gemset_import
|
872
|
+
|
873
|
+
else
|
874
|
+
original_env="$(__rvm_environment_identifier)"
|
875
|
+
|
876
|
+
for rvm_ruby_string in $(echo "$rvm_ruby_strings" | tr "," " "); do
|
877
|
+
|
878
|
+
__rvm_become
|
879
|
+
|
880
|
+
gemset_import
|
881
|
+
done
|
882
|
+
|
883
|
+
__rvm_become "$original_env"
|
884
|
+
|
885
|
+
unset original_env
|
886
|
+
fi
|
887
|
+
;;
|
888
|
+
export|dump)
|
889
|
+
gemset_export
|
890
|
+
;;
|
891
|
+
create)
|
892
|
+
gemset_create
|
893
|
+
;;
|
894
|
+
copy)
|
895
|
+
gemset_copy
|
896
|
+
;;
|
897
|
+
empty)
|
898
|
+
gemset_empty
|
899
|
+
;;
|
900
|
+
delete)
|
901
|
+
gemset_delete
|
902
|
+
;;
|
903
|
+
name|string)
|
904
|
+
gemset_name
|
905
|
+
;;
|
906
|
+
dir)
|
907
|
+
gemset_dir
|
908
|
+
;;
|
909
|
+
list)
|
910
|
+
gemset_list
|
911
|
+
;;
|
912
|
+
gemdir|gempath|gemhome|home|path|version)
|
913
|
+
gemset_info
|
914
|
+
;;
|
915
|
+
install)
|
916
|
+
gem_install "$@"
|
917
|
+
;;
|
918
|
+
pristine)
|
919
|
+
gemset_pristine "$@"
|
920
|
+
;;
|
921
|
+
initial)
|
922
|
+
gemset_initial
|
923
|
+
;;
|
924
|
+
prune)
|
925
|
+
gemset_prune
|
926
|
+
;;
|
927
|
+
update)
|
928
|
+
gemset_update
|
929
|
+
;;
|
930
|
+
unpack)
|
931
|
+
gemset_unpack
|
932
|
+
;;
|
933
|
+
globalcache)
|
934
|
+
gemset_globalcache "$2"
|
935
|
+
;;
|
936
|
+
clear)
|
937
|
+
"$rvm_path/scripts/log" "info" "gemset cleared."
|
938
|
+
exit 0
|
939
|
+
;;
|
940
|
+
help)
|
941
|
+
usage
|
942
|
+
exit 0
|
943
|
+
;;
|
944
|
+
*)
|
945
|
+
usage
|
946
|
+
exit 1
|
947
|
+
;;
|
948
|
+
esac
|
949
|
+
|
950
|
+
exit $?
|