scripts/gems in rvm-0.0.99 vs scripts/gems in rvm-0.0.999
- old
+ new
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
source $rvm_path/scripts/utility
+source $rvm_path/scripts/selector
color_green=$($rvm_scripts_path/color "green")
color_red=$($rvm_scripts_path/color "red")
color_yellow=$($rvm_scripts_path/color "yellow")
color_none=$($rvm_scripts_path/color "none")
@@ -12,32 +13,43 @@
if [[ -d "$rvm_ruby_gem_home" ]] && which gem &> /dev/null ; then rvm_ruby_gem_home="$(gem env home)" ; fi
trap "if [[ -d $rvm_path/tmp/ ]] && [[ -f $rvm_path/tmp/$$ ]] ; then rm -f $rvm_path/tmp/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15
__rvm_gems_name() {
- echo "$rvm_gem_set_name"
+ echo "$(gem env gemdir)" | awk -F'%' '{print $2}'
}
__rvm_gems_dir() {
echo "$rvm_ruby_gem_home"
}
__rvm_gems_list() {
- if [[ $rvm_path =~ rvm ]] ; then
- for gemdir in "${rvm_gem_path}"/${rvm_ruby_string}%* ; do
- echo "$gemdir" | awk -F'%' '{print $2}'
- done
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
+
+ $rvm_scripts_path/log "info" "Listing gems(ets) for $rvm_ruby_string found in $rvm_gem_path/"
+
+ if [[ ! -z "$rvm_gem_path" ]] ; then
+ if [[ ! -z $rvm_ruby_string ]] ; then
+ for gemdir in $rvm_gem_path/${rvm_ruby_string}%* ; do
+ echo "$gemdir" | awk -F'%' '{print $2}'
+ done
+ else
+ $rvm_scripts_path/log "error" "\$rvm_ruby_string is not set!"
+ fi
+ else
+ $rvm_scripts_path/log "error" "\$rvm_gem_path is not set!"
fi
}
__rvm_gems_delete() {
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
if [[ ! -z "$rvm_gem_set_name" ]] ; then
gemdir="$rvm_gem_path/$rvm_ruby_string%$rvm_gem_set_name"
- if [[ -d "$gemdir" ]] && [[ ! -z "$rvm_force_flag" ]] ; then
+ 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 installed gems '$rvm_gem_set_name' ($gemdir)?"
echo -n "(anything other than 'yes' will cancel) > "
read response
if [[ "yes" = "$response" ]] ; then
rm -rf "$gemdir"
else
@@ -261,9 +273,13 @@
__rvm_gems_list
elif [[ "gemdir" = "$action" ]] ; then
__rvm_gems_gemdir
elif [[ "install" = "$action" ]] ; then
__rvm_gem_install $*
+elif [[ "clear" = "$action" ]] ; then
+ $rvm_scripts_path/log "info" "gems(et) cleared."
+ exit 0
else
$rvm_scripts_path/log "error" "gems must be passed an action as the first parameter {load,dump,delete,name,list,gemdir,install}"
fi
+exit $?