scripts/gems in rvm-0.1.12 vs scripts/gems in rvm-0.1.13
- old
+ new
@@ -10,11 +10,11 @@
if [[ ! -z "$rvm_trace_flag" ]] ; then set -x ; export rvm_trace_flag ; fi
rvm_ruby_gem_home="${rvm_ruby_gem_home:-$GEM_HOME}"
if [[ -d "$rvm_ruby_gem_home" ]] && which gem &> /dev/null ; then rvm_ruby_gem_home="$(gem env home)" ; fi
-trap "if [[ -d $rvm_tmp_path/ ]] && [[ -f $rvm_tmp_path/$$ ]] ; then rm -f $rvm_tmp_path/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15
+trap "if [[ -d $rvm_tmp_path/ ]] && [[ -s $rvm_tmp_path/$$ ]] ; then rm -f $rvm_tmp_path/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15
__rvm_gems_name() {
echo "$(gem env gemdir)" | awk -F'%' '{print $2}'
}
@@ -45,15 +45,15 @@
if [[ ! -z "$rvm_gem_set_name" ]] ; then
gemdir="$rvm_gems_path/$rvm_ruby_string%$rvm_gem_set_name"
if [[ -d "$gemdir" ]] && [[ "$gemdir" != '/' ]] && [[ ! -z "$rvm_force_flag" ]] ; then
rm -rf "$gemdir"
elif [[ -d "$gemdir" ]] ; then
- $rvm_scripts_path/log "warn" "Are you SURE you wish to remove the installed gems '$rvm_gem_set_name' ($gemdir)?"
+ $rvm_scripts_path/log "warn" "Are you SURE you wish to remove the entire gemset '$rvm_gem_set_name' ($gemdir)?"
echo -n "(anything other than 'yes' will cancel) > "
read response
if [[ "yes" = "$response" ]] ; then
- rm -rf "$gemdir"
+ rm -f $gemdir/cache && rm -rf $gemdir
else
$rvm_scripts_path/log "info" "Not doing anything, phew... close call that one eh?"
fi
else
$rvm_scripts_path/log "info" "$gemdir already does not exist."
@@ -61,10 +61,33 @@
else
$rvm_scripts_path/log "error" "A gems name must be specified in order to delete a gems."
fi
}
+__rvm_gems_nuke() {
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
+ if [[ ! -z "$rvm_gem_set_name" ]] ; then
+ gemdir="$rvm_gems_path/$rvm_ruby_string%$rvm_gem_set_name"
+ if [[ -d "$gemdir" ]] && [[ "$gemdir" != '/' ]] && [[ ! -z "$rvm_force_flag" ]] ; then
+ cd $gemdir && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
+ elif [[ -d "$gemdir" ]] ; then
+ $rvm_scripts_path/log "warn" "Are you SURE you wish to remove the installed gems for gemset '%$rvm_gem_set_name' ($gemdir)?"
+ echo -n "(anything other than 'yes' will cancel) > "
+ read response
+ if [[ "yes" = "$response" ]] ; then
+ cd $gemdir && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
+ else
+ $rvm_scripts_path/log "info" "Not doing anything, phew... close call that one eh?"
+ fi
+ else
+ $rvm_scripts_path/log "info" "$gemdir already does not exist."
+ fi ; unset gemdir
+ else
+ $rvm_scripts_path/log "error" "A gems name must be specified in order to delete a gems."
+ fi
+}
+
__rvm_gems_dump() {
rvm_file_name="${rvm_file_name:-$gems_args}"
if [[ ! -z "$rvm_ruby_gem_home" ]] ; then
export GEM_HOME="$rvm_ruby_gem_home"
@@ -102,31 +125,31 @@
export GEM_HOME="$rvm_ruby_gem_home"
export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string%global/bin"
fi
if [[ ! -z "$(echo "$gems_args" | awk '/\.gem.*$/')" ]] ; then
- rvm_gem_set_name="$(echo "$gems_args" | sed 's#\.gem.*##g')"
+ rvm_gem_set_name="$(echo "$gems_args" | sed 's#\.gem.*##g' | sed 's# ##g')"
else
- rvm_gem_set_name="$gems_args"
+ rvm_gem_set_name="$(echo "$gems_args" | sed 's# ##g')"
fi
- if [[ -f "$rvm_gem_set_name.gems" ]] ; then
+ if [[ -s "$rvm_gem_set_name.gems" ]] ; then
rvm_file_name="$rvm_gem_set_name.gems"
- elif [[ -f "default.gems" ]] ; then
+ elif [[ -s "default.gems" ]] ; then
rvm_file_name="default.gems"
- elif [[ -f "system.gems" ]] ; then
+ elif [[ -s "system.gems" ]] ; then
rvm_file_name="system.gems"
- elif [[ -f ".gems" ]] ; then
+ elif [[ -s ".gems" ]] ; then
rvm_file_name=".gems"
else
$rvm_scripts_path/log "error" "No *.gems file found."
return 1
fi
mkdir -p "$rvm_gems_path/cache" # Ensure the base cache dir is initialized.
- if [[ -f "$rvm_file_name" ]] ; then
+ if [[ -s "$rvm_file_name" ]] ; then
echo "Loading $rvm_file_name file..."
rvm_ruby_gem_list=$(\ls $rvm_ruby_gem_home/specifications/ 2> /dev/null | sed 's#.gems.*$##' 2> /dev/null)
while read -r line
do # Keep this on 2nd line :(
@@ -157,11 +180,11 @@
else
unset gem_version # no version
fi
fi
- if [[ -f "$gem" ]] ; then
+ if [[ -s "$gem" ]] ; then
gem_file_name="$gem"
elif $rvm_scripts_path/match "$gem" ".gem$" ; then
gem_file_name="$gem"
elif [[ -z "${gem_version/ /}" ]] ; then # no v/Users/wayne/projects/db0/rvm/scripts/gems
gem_file_name="${gem_name/ /}*.gem"
@@ -178,31 +201,31 @@
# Now we determine if a .gem cache file is already installed
if [[ -z "$rvm_force_flag" ]] && [[ -f "${rvm_ruby_gem_home}/specifications/$(basename $gem_file_name)spec" ]] ; then
unset gem
$rvm_scripts_path/log "info" "$color_green$gem_name $gem_version$yellow exists, skipping (--force to re-install)"
else
- if [[ -f "$gem" ]] ; then
+ if [[ -s "$gem" ]] ; then
cache_file="$gem"
- elif [[ -f "$rvm_gems_path/cache/${gem_file_name}" ]] ; then
+ elif [[ -s "$rvm_gems_path/cache/${gem_file_name}" ]] ; then
cache_file="$rvm_gems_path/cache/${gem_file_name}"
else
cache_file="${cache_file:-$(\ls ${rvm_gems_path}/cache/${gem_file_name} 2> /dev/null | sort | head -n1)}"
fi
- if [[ ! -f "$cache_file" ]] ; then
- if [[ -f "$gem_file_name" ]] ; then
+ if [[ ! -s "$cache_file" ]] ; then
+ if [[ -s "$gem_file_name" ]] ; then
gem="$gem_file_name"
elif [[ -z "${gem_version/ /}" ]] ; then
gem="${gem_name/ /}"
else
gem="${gem_name/ /} -v $gem_version"
fi
else # cached
gem_file_name="$(basename "$cache_file")"
gem_string="$(echo "$gem_file_name" | sed 's#\.gem$##')"
- if [[ -z "$rvm_force_flag" ]] && [[ -f "${rvm_ruby_gem_home}/specifications/$(basename $gem_file_name)spec" ]] ; then
+ if [[ -z "$rvm_force_flag" ]] && [[ -s "${rvm_ruby_gem_home}/specifications/$(basename $gem_file_name)spec" ]] ; then
unset gem # already installed, not forcing reinstall.
$rvm_scripts_path/log "info" "$color_green$gem_name $gem_version$yellow exists, skipping (--force to re-install)"
else
if [[ -s "$rvm_gems_path/cache/$(basename $gem_file_name)" ]] ; then
mkdir -p "$rvm_tmp_path/$$/"
@@ -258,15 +281,17 @@
$rvm_scripts_path/log "error" "'gem' was not found, cannot perform gem actions."
return 1
fi
action="$(echo $* | awk '{print $1}')"
-gems_args="$(echo $* | awk '{$1="" ; print}' | sed 's/^[ \t]*//')"
+gems_args="$(echo $* | awk '{$1="" ; print}' | sed 's/^\s*//')"
if [[ "load" = "$action" ]] ; then
__rvm_gems_load
elif [[ "dump" = "$action" ]] ; then
__rvm_gems_dump
+elif [[ "nuke" = "$action" ]] ; then
+ __rvm_gems_nuke
elif [[ "delete" = "$action" ]] ; then
__rvm_gems_delete
elif [[ "name" = "$action" ]] ; then
__rvm_gems_name
elif [[ "dir" = "$action" ]] ; then