Browse files

Only call colors once per color. Set rvm_ruby_gem_home if it is not set.

  • Loading branch information...
1 parent 1a3dd4c commit db9ffd10bbf82b55fa9a0fd58c001ab15c90e3aa @wayneeseguin wayneeseguin committed Dec 11, 2009
Showing with 11 additions and 8 deletions.
  1. +11 −8 scripts/gems
View
19 scripts/gems
@@ -2,10 +2,14 @@
#source $rvm_path/scripts/rvm
source $rvm_path/scripts/utility
-source $rvm_path/scripts/selector
-#rvm_ruby_string="${rvm_ruby_string:-system}"
-#__rvm_select
+#source $rvm_path/scripts/selector
+color_green=$($rvm_scripts_path/color "green")
+color_green=$($rvm_scripts_path/color "red")
+color_yellow=$($rvm_scripts_path/color "yellow")
+color_none=$($rvm_scripts_path/color "none")
+
+if [[ -z "$rvm_ruby_gem_home" ]] ; then rvm_ruby_gem_home="$(gem env home)" ; fi
if [[ "$rvm_trace_flag" -eq 1 ]] ; then set -x ; export rvm_trace_flag ; fi
trap "rm -f $rvm_path/$$* > /dev/null 2>&1 ; exit" 0 1 2 3 15
@@ -153,9 +157,10 @@ __rvm_gem_install() {
#
# Evaluate
#
+
if [[ -z "$rvm_force_flag" ]] && [[ -f "${rvm_ruby_gem_home}/specifications/${gem_file_name}spec" ]] ; then
unset gem
- $rvm_scripts_path/log "info" "$($rvm_scripts_path/color "green")$gem_name $gem_version$($rvm_scripts_path/color "none") exists, skipping (--force to re-install)"
+ $rvm_scripts_path/log "info" "$color_green$gem_name $gem_version$yellow exists, skipping (--force to re-install)"
else
if [[ -f "$gem" ]] ; then
cache_file="$gem"
@@ -212,9 +217,9 @@ __rvm_gem_install() {
eval $command > /dev/null 2>&1
result=$?
if [[ $result -eq 0 ]] ; then
- $rvm_scripts_path/log "info" "$($rvm_scripts_path/color "green")$gem_name $gem_version$($rvm_scripts_path/color "none") installed."
+ $rvm_scripts_path/log "info" "$color_green$gem_name $gem_version$color_none installed."
else
- $rvm_scripts_path/log "error" "$($rvm_scripts_path/color "red")$gem_name $gem_version$($rvm_scripts_path/color "none") failed to install."
+ $rvm_scripts_path/log "error" "$color_red$gem_name $gem_version$color_none failed to install."
fi
fi
unset gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string
@@ -237,8 +242,6 @@ __rvm_gems_gemdir() {
unset GEM_PATH
-#if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
-
if [[ -z "$(which gem 2>/dev/null)" ]] ; then
$rvm_scripts_path/log "error" "'gem' was not found, cannot perform gem actions."
return 1

0 comments on commit db9ffd1

Please sign in to comment.