scripts/gemsets in rvm-1.0.8 vs scripts/gemsets in rvm-1.0.9
- old
+ new
@@ -22,57 +22,70 @@
"
}
gemset_update() {
+
if [[ -z "$rvm_ruby_strings" ]]; then
+
"$rvm_path/scripts/log" "info" "Running gem update for all rubies and gemsets."
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' ',')"
+
rvm_ruby_strings="${rvm_ruby_strings/%,}"
+
rvm_ruby_strings="${rvm_ruby_strings//.\/}"
+
else
"$rvm_path/scripts/log" "info" "Running gem update for the specified rubies."
fi
+
export rvm_ruby_strings
+
"$rvm_path/scripts/set" "gem" "update"
+
return $?
}
gemset_globalcache() {
+
local gc_status globalcache_enabled directories directory_name full_directory_path directory_name
if [[ "$1" == "enabled" ]]; then
__rvm_using_gemset_globalcache
globalcache_enabled=$?
+
gc_status="Unknown"
if [[ $globalcache_enabled -eq 0 ]]; then
gc_status="Enabled"
else
gc_status="Disabled"
fi
- "$rvm_path/scripts/log" "info" "Gemset global cache is currently: $gc_status"
+ "$rvm_path/scripts/log" "info" \
+ "Gemset global cache is currently: $gc_status"
return "$globalcache_enabled"
elif [[ "$1" == "disable" ]]; then
- "$rvm_path/scripts/log" "info" "Removing the global cache (note: this will empty the caches)"
+ "$rvm_path/scripts/log" "info" \
+ "Removing the global cache (note: this will empty the caches)"
directories=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print))
for directory_name in "${directories[@]//.\/}"; do
current_cache_path="${rvm_gems_path:-"$rvm_path/gems"}/$directory_name/cache"
if [[ -L "$current_cache_path" && "$(readlink "$current_cache_path")" == "$rvm_gems_cache_path" ]]; then
- "$rvm_path/scripts/log" "info" "Reverting the gem cache for $directory_name to an empty directory."
+ "$rvm_path/scripts/log" "info" \
+ "Reverting the gem cache for $directory_name to an empty directory."
rm -f "$current_cache_path" 2>/dev/null
mkdir -p "$current_cache_path" 2>/dev/null
fi
@@ -80,11 +93,12 @@
"$rvm_path/scripts/db" "$rvm_path/config/user" "use_gemset_globalcache" "delete"
elif [[ "$1" == "enable" ]]; then
- "$rvm_path/scripts/log" "info" "Enabling global cache for gems."
+ "$rvm_path/scripts/log" "info" \
+ "Enabling global cache for gems."
mkdir -p "$rvm_gems_cache_path"
directories=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print))
@@ -438,18 +452,26 @@
return 0
}
gemset_import() {
+ unset -f gem
+
if [[ -n "${rvm_ruby_gem_home:-""}" ]] ; then
export GEM_HOME="$rvm_ruby_gem_home"
- export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin"
+ export GEM_PATH="$rvm_ruby_gem_home"
export BUNDLE_PATH="$rvm_ruby_gem_home"
+ else
+ rvm_ruby_gem_home=${GEM_HOME:-$(gem env gemdir)}
fi
- rvm_file_name="${gems_args}"
+ #rvm_gemset_name="${gems_args//.gem*/}"
+ #rvm_gemset_name="${gems_args// /}"
+ rvm_file_name="${gems_args// /}"
+
+ # TODO: this could likely be better with find
if [[ -s "${rvm_file_name%.gems*}.gems" ]] ; then
rvm_file_name="${rvm_file_name%.gems*}.gems"
elif [[ -s "${rvm_gemset_name}.gems" ]] ; then
rvm_file_name="${rvm_gemset_name}.gems"
@@ -466,12 +488,18 @@
else
"$rvm_path/scripts/log" "error" "No *.gems file found."
return 1
fi
- mkdir -p "$rvm_gems_cache_path" # Ensure the base cache dir is initialized.
+ if [[ ! -d "$rvm_ruby_gem_home/specifications/" ]] ; then
+ mkdir -p "$rvm_ruby_gem_home/specifications/"
+ fi
+ if [[ ! -d "$rvm_gems_cache_path" ]] ; then
+ mkdir -p "$rvm_gems_cache_path" # Ensure the base cache dir is initialized.
+ fi
+
if [[ -s "$rvm_file_name" ]] ; then
echo "Importing $rvm_file_name file..."
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,11 +563,11 @@
}
# Install a gem
gem_install() {
- local result gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action
+ local gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action
result=0
# First we parse the gem args to pick apart the pieces.
__rvm_parse_gems_args
@@ -606,19 +634,21 @@
# TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line.
if [[ "rvm_make_flags_flag" -eq 1 ]] ; then __rvm_make_flags ; fi
if [[ -n "$rvm_ruby_gem_home" && "$rvm_ruby_gem_home" != "${rvm_gems_path:-"$rvm_path/gems"}" ]] ; then
- command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} command gem install $gems_args $rvm_gem_options $gem_postfix $vars"
+ 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"
else
#--ignore-dependencies
- command="$gem_prefix command gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
+ command="$gem_prefix gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
fi
+ unset -f gem
+
__rvm_run "gem.install" "$command" "installing ${gem_name} ${gem_version}..."
result=$?
if [[ $result -eq 0 ]] ; then
@@ -715,41 +745,56 @@
}
# Loads the default gemsets for the current interpreter and gemset.
gemset_initial() {
+ local gemsets gemset path paths
+
+ rvm_gemsets_path="${rvm_gemsets_path:-"$rvm_path/gemsets"}"
+
"$rvm_path/scripts/log" "info" \
"Importing initial gemsets for $(__rvm_environment_identifier)."
- mkdir -p "$rvm_path/gemsets/${rvm_ruby_string//-//}" 2>/dev/null
+ if [[ ! -d "$rvm_gemsets_path/${rvm_ruby_string//-/\/}" ]] ; then
+ mkdir -p "$rvm_gemsets_path/${rvm_ruby_string//-/\/}" 2>/dev/null
+ fi
- for gemsets_path in $(__rvm_ruby_string_paths_under "$rvm_path/gemsets") ; do
+ paths=($(__rvm_ruby_string_paths_under "$rvm_gemsets_path"))
- # TODO: This can be condensed.
- if [[ -d "$gemsets_path" ]] ; then
+ echo "paths: ${paths[@]}"
- if [[ -n "$rvm_gemset_name" && -s "${gemsets_path}/${rvm_gemset_name}.gems" ]] ; then
- (
- rvm --create "$rvm_ruby_string"
- "$rvm_path/scripts/gemsets" import "${gemsets_path}/${rvm_gemset_name}.gems"
- )
+ for path in "${paths[@]}" ; do
+
+ if [[ -n "$rvm_gemset_name" ]] ; then
+
+ if [[ -s "${rvm_gemset_name}.gems" ]] ; then
+
+ ( gems_args="${rvm_gemset_name}.gems" ; gemset_import )
+
fi
- if [[ -s "${gemsets_path}/default.gems" ]] ; then
- (
- rvm --create "$rvm_ruby_string"
- "$rvm_path/scripts/gemsets" import "$gemsets_path/default.gems"
- )
+ else
+
+ if [[ -s "${path}/default.gems" ]] ; then
+
+ ( gems_args="${path}/default.gems" ; gemset_import )
+
fi
- if [[ -s "${gemsets_path}/global.gems" ]] ; then
+ if [[ -s "${path}/global.gems" ]] ; then
+
(
- rvm --create "$rvm_ruby_string@global"
- "$rvm_path/scripts/gemsets" import "${gemsets_path}/global.gems"
+ rvm_create_flag=1
+ rvm_ruby_gem_home="${rvm_ruby_gem_home//@*/}@global"
+ gems_args="${path}/global.gems"
+ gemset_import
)
+
fi
+
fi
+
done
"$rvm_path/scripts/log" "info" \
"Installation of gems for $(__rvm_environment_identifier) is complete."
@@ -771,13 +816,18 @@
export rvm_gemset_name="${args[1]:-""}" # For wherever used.
rvm_sticky_flag=1
if [[ -z "$rvm_ruby_string" ]] ; then
+
if echo "${GEM_HOME:-""}" | grep -q 'rvm' ; then
+
rvm_ruby_string="${GEM_HOME##*/}"
+
rvm_ruby_string="${rvm_ruby_string%%@*}"
+
fi
+
fi
case "$action" in
import|load)