wayneeseguin-rvm 0.0.40 → 0.0.42

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,10 +14,16 @@ if [ ! -d "$source_dir" ] ; then unset source_dir ; fi
14
14
  source_dir="${source_dir:-$cwd}"
15
15
  rvm_dir=~/.rvm
16
16
 
17
- echo -e "\nInstalling rvm source to ~/.rvm/scripts/rvm..."
17
+ echo -e "\nInstalling rvm to ~/.rvm/ ..."
18
18
  for dir in src scripts bin log archives config gems examples ; do
19
19
  mkdir -p $rvm_dir/$dir
20
20
  done
21
+ for dir in config scripts examples lib ; do
22
+ mkdir -p $rvm_dir/$dir
23
+ /bin/cp -r $source_dir/$dir/ $rvm_dir/$dir
24
+ done
25
+ cp $source_dir/scripts/rvm-prompt $rvm_dir/bin/
26
+ chmod +x $rvm_dir/bin/rvm-prompt
21
27
 
22
28
  # State what is required to use rvm
23
29
  echo -e "\n\033[0;32mrvm\033[0m is a shell script that allows a user to manage multiple ruby versions in their own account."
@@ -116,15 +122,6 @@ if [ -f ~/.rvm/bin/rvm ] ; then
116
122
  rm -f ~/.rvm/bin/rvm
117
123
  fi
118
124
 
119
- for dir in config scripts examples ; do
120
- mkdir -p $rvm_dir/$dir
121
- for file in `/bin/ls $source_dir/$dir/`; do
122
- cp $source_dir/$dir/$file $rvm_dir/$dir/$file
123
- done
124
- done
125
- cp $source_dir/scripts/rvm-prompt $rvm_dir/bin/
126
- cp $source_dir/VERSION.yml $rvm_dir/
127
-
128
125
  system=`uname`
129
126
  if [ "$system" = "Linux" ] ; then
130
127
  rvm_apt_get_binary=`which apt-get 2> /dev/null`
@@ -136,7 +133,7 @@ if [ "$system" = "Linux" ] ; then
136
133
  echo -e "\033[0;33m <w> \033[0mFor jRuby (if you wish to use it) you will need:"
137
134
  echo -e "\033[0;32m <i> \033[0msudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk"
138
135
  echo -e "\033[0;33m <w> \033[0mFor ree (if you wish to use it) you will need:"
139
- echo -e "\033[0;32m <i> \033[0msudo apt-get install libreadline5-dev libssl-dev "
136
+ echo -e "\033[0;32m <i> \033[0msudo apt-get install libreadline5-dev libssl-dev bison"
140
137
 
141
138
  elif [ ! -z "$rvm_emerge_binary" ] ; then
142
139
  echo -e "\033[0;33m <w> \033[0mFor jRuby (if you wish to use it) you will need:"
@@ -52,11 +52,11 @@ function __rvm_debug {
52
52
  function __rvm_log {
53
53
 
54
54
  case "$1" in
55
- debug) shift ; echo -e "\n\033[0;35m <d> \033[0m $*" ;;
56
- info) shift ; echo -e "\n\033[0;32m <i> \033[0m $*" ;;
57
- warn) shift ; echo -e "\n\033[0;33m <w> \033[0m $*" ;;
58
- error) shift ; echo -e "\n\033[0;31m <e> \033[0m $*" ;;
59
- fail) shift ; echo -e "\n\033[0;31m <e> \033[0m $*" ; popd 2> /dev/null ; return 1 ;;
55
+ debug) shift ; echo -e "\033[0;35m <d> \033[0m $*" ;;
56
+ info) shift ; echo -e "\033[0;32m <i> \033[0m $*" ;;
57
+ warn) shift ; echo -e "\033[0;33m <w> \033[0m $*" ;;
58
+ error) shift ; echo -e "\033[0;31m <e> \033[0m $*" ;;
59
+ fail) shift ; echo -e "\033[0;31m <e> \033[0m $*" ; popd 2> /dev/null ; return 1 ;;
60
60
  *) echo -e "$*"
61
61
  esac
62
62
  }
@@ -78,7 +78,7 @@ function __rvm_run {
78
78
  command="$*"
79
79
  rvm_ruby_log_path=${rvm_ruby_log_path:-$rvm_path/log}
80
80
  mkdir -p $rvm_ruby_log_path
81
- if [ $rvm_debug ] ; then __rvm_log "debug" "Executing: $command" ; fi
81
+ if [ ! -z "$rvm_debug_flag" ] ; then __rvm_log "debug" "Executing: $command" ; fi
82
82
  touch $rvm_ruby_log_path/$log_file_name.log $rvm_ruby_log_path/$log_file_name.error.log # for zsh :(
83
83
  echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | tee $rvm_ruby_log_path/$log_file_name.log > $rvm_ruby_log_path/$log_file_name.error.log
84
84
  if [ -z "$rvm_niceness" -o "$rvm_niceness" = "0" ] ; then
@@ -91,7 +91,7 @@ function __rvm_run {
91
91
  }
92
92
 
93
93
  function __rvm_cleanup-variables {
94
- unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_path rvm_debug rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_delete_flag rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_make_install rvm_config_path rvm_bin_path rvm_force rvm_all rvm_re_configure rvm_summary rvm_ruby_string rvm_make_flags rvm_bin_flag
94
+ unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_path rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_configure rvm_ruby_make_install rvm_config_path rvm_ruby_string rvm_bin_path rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_load_flag rvm_dump_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_install_on_use
95
95
  }
96
96
 
97
97
  # TODO: root user loadng of /etc/rvmrc
@@ -133,16 +133,16 @@ function __rvm_fetch {
133
133
 
134
134
  pushd $rvm_archives_path > /dev/null
135
135
  eval $rvm_fetch "$1"
136
- status=$?
137
- if [ $status -gt 0 ] ; then
138
- if [ $status -eq 78 ] ; then
136
+ result=$?
137
+ if [ $result -gt 0 ] ; then
138
+ if [ $result -eq 78 ] ; then
139
139
  __rvm_log "error" "The requested url does not exist: '$1'"
140
140
  else
141
141
  __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
142
142
  fi
143
143
  fi
144
144
  popd 2> /dev/null
145
- return $status
145
+ return $result
146
146
  }
147
147
 
148
148
  function __rvm_load-defaults {
@@ -204,7 +204,7 @@ function __rvm_reset {
204
204
  for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do unset $variable ; done
205
205
 
206
206
  for file in system default ; do
207
- if [ -f $rvm_path/$file ] ; then rm -f $rvm_path/file ; fi
207
+ if [ -f $rvm_path/$file ] ; then rm -f $rvm_path/$file ; fi
208
208
  done
209
209
  __rvm_select "system"
210
210
 
@@ -326,7 +326,7 @@ function __rvm_symlinks {
326
326
 
327
327
  function __rvm_list {
328
328
 
329
- if [ "$rvm_all" ] ; then
329
+ if [ "$rvm_all_flag" ] ; then
330
330
  svn list http://svn.ruby-lang.org/repos/ruby/tags/ | grep 'v1_[8|9]' | sed 's/^v1_//' | sed 's/\/$//' | awk -F'_' '{print "1."$1"."$2 " -l "$3}' | sed 's/p$//'
331
331
 
332
332
  echo "jruby 1.2.0"
@@ -407,10 +407,10 @@ function __rvm_initialize {
407
407
  if [ $? -ne 0 ] ; then
408
408
  __rvm_log "fail" "rvm expects either curl or wget, neither seem to be in your path :("
409
409
  else
410
- rvm_fetch="wget -q -c "
410
+ rvm_fetch="wget -c " # -q for quiet
411
411
  fi
412
412
  else
413
- rvm_fetch="$rvm_fetch -O -L -s --create-dirs -C - "
413
+ rvm_fetch="$rvm_fetch -O -L --create-dirs -C - " # -s for silent
414
414
  fi
415
415
 
416
416
  # TODO: Sanitize user input, ensure that there is a / a the end...
@@ -435,8 +435,6 @@ function __rvm_initialize {
435
435
  rvm_ruby_repo_url="${rvm_ruby_repo_url:-"http://svn.ruby-lang.org/repos/ruby"}"
436
436
  # Rubinius sha1's will be available after RC1.
437
437
  rvm_rubinius_repo_url="${rvm_rubinius_repo_url:-"git://github.com/evanphx/rubinius.git"}"
438
- #rvm_macruby_repo_url="${rvm_macruby_repo_url:-"http://svn.macosforge.org/repository/ruby/MacRuby"}"
439
- rvm_macruby_repo_url="${rvm_macruby_repo_url:-"git://github.com/masterkain/macruby.git"}"
440
438
  rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
441
439
  rvm_ruby_load_path="."
442
440
  rvm_ruby_require=""
@@ -447,17 +445,18 @@ function __rvm_initialize {
447
445
  PATH=$rvm_bin_path:$PATH ; export PATH
448
446
  fi
449
447
 
450
- mkdir -p $rvm_source_path $rvm_bin_path $rvm_archives_path
448
+ mkdir -p $rvm_source_path $rvm_bin_path $rvm_archives_path $rvm_path/tmp
451
449
  }
452
450
 
453
451
  function __rvm_update {
454
- if [ "$rvm_ruby_rev" = "head" -o "$rvm_update_flag" ] ; then
452
+ if [ "$rvm_ruby_rev" = "head" -o ! -z "$rvm_self_flag" -o ! -z "$rvm_update_flag" ] ; then
455
453
  __rvm_version
456
454
  __rvm_update_rvm
457
455
  __rvm_version
458
456
  fi
459
457
  __rvm_reload
460
458
  __rvm_select
459
+ # if [ "$rvm_gem_flag" ] ; then __rvm_gem_scripts ; fi
461
460
  if [ "$rvm_bin_flag" ] ; then __rvm_bin_scripts ; fi
462
461
  if [ "$rvm_rubygems_flag" ] ; then __rvm_rubygems_setup ; fi
463
462
  }
@@ -512,12 +511,39 @@ function __rvm_reload {
512
511
  source $rvm_path/scripts/rvm
513
512
  }
514
513
 
514
+ function __rvm_ruby_do {
515
+ __rvm_select
516
+ __rvm_use
517
+ binary=`echo $rvm_action | sed 's/do$//'`
518
+ if [ -x $rvm_ruby_home/bin/$binary ] ; then
519
+ load_path="$rvm_ruby_home/bin:$rvm_ruby_load_path"
520
+ if [ "$binary" = "ruby" ] ; then
521
+ rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_require -I$load_path -S $rvm_ruby_args"
522
+ else
523
+ rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_args"
524
+ fi
525
+ echo -e "\n$rvm_ruby_string: $($rvm_ruby_home/bin/$binary -v)"
526
+ eval $rvm_command
527
+ result=$?
528
+ if [ $result -eq 0 ]; then
529
+ eval "successes=(${successes[*]} $rvm_ruby_string)"
530
+ else
531
+ eval "errors=(${errors[*]} $rvm_ruby_string)"
532
+ fi
533
+ eval "all=(${all[*]} $rvm_ruby_string)"
534
+ eval "results=(${results[*]} $result)"
535
+ # TODO: keep track of and re-set the previous selected ruby ;)
536
+ else
537
+ __rvm_log "warn" "'$rvm_ruby_home/bin/$binary' either does not exist or is not executable? :("
538
+ fi
539
+ unset rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install rvm_ruby_rev rvm_ruby_tag rvm_major_version rvm_minor_version rvm_gem_set_name rvm_gem_home rvm_ruby_binary rvm_ruby_package_name rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_selected
540
+ }
541
+
515
542
  function __rvm_do {
516
- all=() ; successes=() ; errors=() ; statuses=()
543
+ all=() ; successes=() ; errors=() ; results=()
517
544
  # TODO: Extract the common functionality out of the if below
518
545
  if [ ! -z "$rvm_ruby_version" ] ; then
519
- rvm_ruby_selectors=$(echo $rvm_ruby_version | tr ',' ' ')
520
- for rvm_ruby_selector in $rvm_ruby_selectors ; do
546
+ for rvm_ruby_selector in `echo $rvm_ruby_version | tr ',' ' '` ; do
521
547
  temp=$(echo $rvm_ruby_selector | awk '{print substr($1, 0, 1)}')
522
548
  if [ ! -z "$(echo $temp | grep '[0-9]')" ] ; then
523
549
  rvm_ruby_interpreter="ruby"
@@ -527,118 +553,49 @@ function __rvm_do {
527
553
  unset rvm_ruby_version
528
554
  fi
529
555
  unset temp
530
- __rvm_select
531
- __rvm_use
532
- #__rvm_
533
- binary=`echo $rvm_action | sed 's/do$//'`
534
- lp="$rvm_ruby_home/bin:$rvm_ruby_load_path"
535
- if [ "$binary" = "ruby" ] ; then
536
- rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_require -I$lp -S $rvm_ruby_args"
537
- else
538
- rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_args"
539
- fi
540
- echo "$rvm_ruby_string: $($rvm_ruby_home/bin/$binary -v)"
541
- eval $rvm_command
542
- status=$?
543
- if [ $status -eq 0 ]; then
544
- successes[${#successes[*]}]=$rvm_ruby_string
545
- else
546
- errors[${#errors[*]}]=$rvm_ruby_string
547
- fi
548
- all[${#all[*]}]=$rvm_ruby_string
549
- statuses[${#statuses[*]}]=$status
550
- # TODO: keep track of and re-set the previous selected ruby ;)
551
- unset rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_ruby_package_name rvm_ruby_home rvm_ruby_irbrc rvm_ruby_binary rvm_ruby_string lp
556
+ __rvm_ruby_do
552
557
  done
553
558
  else # all
554
- rvm_ruby_binaries=`/bin/ls $rvm_path/*/bin/ruby`
555
- for rvm_ruby_binary in $rvm_ruby_binaries ; do
556
- if [ -x $rvm_ruby_binary ] ; then
557
- rvm_ruby_string=`dirname $rvm_ruby_binary | xargs dirname | xargs basename`
558
- __rvm_select
559
- __rvm_use
560
- rvm_ruby_string="$(dirname $rvm_ruby_home/bin/$binary | xargs dirname | xargs basename)"
561
- lp="$rvm_ruby_home/bin:$rvm_ruby_load_path"
562
- if [ "$binary" = "ruby" ] ; then
563
- rvm_command="$rvm_ruby_binary $rvm_ruby_require -I$lp -S $rvm_ruby_args"
564
- else
565
- rvm_command="$rvm_ruby_binary $rvm_ruby_args"
566
- fi
567
- echo "$(basename $rvm_ruby_binary):"
568
- eval $rvm_command
569
- status=$?
570
- if [ $status -eq 0 ]; then
571
- successes[${#successes[*]}]=$rvm_ruby_string
572
- else
573
- errors[${#errors[*]}]=$rvm_ruby_string
574
- fi
575
- all[${#all[*]}]=$rvm_ruby_string
576
- statuses[${#statuses[*]}]=$status
577
- unset rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_ruby_package_name rvm_ruby_home rvm_ruby_irbrc rvm_ruby_binary rvm_ruby_string lp
559
+ while read bin_line
560
+ do # Keep this on second line damnit!
561
+ if [ -x $bin_line ] ; then
562
+ rvm_ruby_string="`dirname $bin_line | xargs dirname | xargs basename`"
563
+ __rvm_ruby_do
578
564
  fi
579
- done
565
+ done < <(/bin/ls $rvm_path/*/bin/ruby 2> /dev/null)
580
566
  fi
581
567
 
582
- export successes errors statuses
583
-
584
- if [ ! -z "$rvm_summary" ] ; then
585
- echo -e "\n\033[0;32msuccessful (${#successes[*]}) : [ $(echo "${successes[*]}" | sed 's/ /, /g') ]\033[0m"
586
- echo -e "\n\033[0;31merrors (${#errors[*]}) : [ $(echo "${errors[*]}" | sed 's/ /, /g') ]\033[0m"
568
+ if [ ! -z "$rvm_summary_flag" ] ; then
569
+ export successes errors results
570
+ echo -e "\nSummary:"
571
+ echo -e "\033[0;32msuccessful (${#successes[*]}) : [ $(echo "${successes[*]}" | sed 's/ /, /g') ]\033[0m"
572
+ echo -e "\033[0;31merrors (${#errors[*]}) : [ $(echo "${errors[*]}" | sed 's/ /, /g') ]\033[0m"
587
573
  echo -e "all (${#all[*]}) : [ $(echo "${all[*]}" | sed 's/ /, /g') ]"
588
- echo -e "exit statuses: [ $(echo "${statuses[*]}" | sed 's/ /, /g') ]\n"
589
- # unset binary successes errors rvm_summary
574
+ echo -e "exit results: [ $(echo "${results[*]}" | sed 's/ /, /g') ]\n"
590
575
  else
591
- unset binary successes errors rvm_summary
576
+ unset bin_line rvm_summary_flag
577
+ # successes errors
592
578
  fi
593
579
  return ${#errors[*]}
594
580
  }
595
581
 
596
- function __rvm_irbrc {
597
- if [ ! -s "$rvm_ruby_irbrc" ] ; then
598
- rvm_irbrc_file=`cat <<-Config
599
- load '$HOME/.irbrc' if File.exists?('$HOME/.irbrc') rescue nil
600
-
601
- require "irb/completion" rescue nil
602
-
603
- @prompt = {
604
- :PROMPT_I => "${rvm_ruby_package_name} > ", # default prompt
605
- :PROMPT_S => "${rvm_ruby_package_name}%l> ", # known continuation
606
- :PROMPT_C => "${rvm_ruby_package_name} > ",
607
- :PROMPT_N => "${rvm_ruby_package_name} ?> ", # unknown continuation
608
- :RETURN => " => %s \n",
609
- :AUTO_INDENT => true
610
- }
611
- @prompt_mode = :DEFAULT
612
- IRB.conf[:PROMPT][@prompt_mode] = @prompt
613
- IRB.conf[:PROMPT_MODE] = @prompt_mode
614
- Config
615
- `
616
- touch $rvm_ruby_home/.irbrc
617
- echo -e "\n$rvm_irbrc_file" > $rvm_ruby_home/.irbrc
618
- fi
619
-
620
- }
621
-
622
582
  function __rvm_ruby_string {
623
583
  if [ "$rvm_ruby_interpreter" = "system" ] ; then
624
- rvm_ruby_string=""
584
+ rvm_ruby_string="system"
625
585
  elif [ ! -z "$rvm_ruby_string" ] ; then
626
- echo $rvm_ruby_string | grep "enterprise" > /dev/null
627
- if [ $? -eq 0 ] ; then
628
- rvm_ruby_interpreter="ruby-enterprise"
629
- else
630
- rvm_ruby_interpreter=`echo $rvm_ruby_string | tr '-' ' ' | awk '{print $1}'`
631
- fi
632
- rvm_ruby_vesion=`echo $rvm_ruby_string | awk -F'-' '{print $(NF-1)}'`
633
- revision=`echo $rvm_ruby_string | awk '{print $NF}'`
586
+ rvm_ruby_string=`echo "$rvm_ruby_string" | sed 's/ruby-enterprise/ree/g'` # dash-antics :)
587
+ rvm_ruby_interpreter=`echo $rvm_ruby_string | tr '-' ' ' | awk '{print $1}'`
588
+ rvm_ruby_version=`echo $rvm_ruby_string | awk -F'-' '{print $2}'`
589
+ revision=`echo $rvm_ruby_string | awk -F'-' '{print $3}'`
590
+
634
591
  if [ "$revision" = "head" -o "$revision" = "preview" ] ; then
635
592
  rvm_ruby_revision="$revision"
636
593
  else
637
- echo $revision | grep 'p[0-9]\+' > /dev/null
594
+ echo $revision | grep '^p[0-9]\+' > /dev/null
638
595
  if [ $? -eq 0 ] ; then
639
596
  rvm_ruby_patch_level=`echo $revision | awk -F'p' '{print $2}'`
640
597
  else
641
- echo $revision | grep '[0-9]\+' > /dev/null
598
+ echo $revision | grep '^[0-9]\+' > /dev/null
642
599
  if [ $? -eq 0 ] ; then
643
600
  rvm_ruby_rev="$revision"
644
601
  else
@@ -646,6 +603,8 @@ function __rvm_ruby_string {
646
603
  fi
647
604
  fi
648
605
  fi
606
+
607
+ if [ "rvm_ruby_interpreter" = "ree" ] ; then rvm_ruby_interpreter="ruby-enterprise" ; fi
649
608
  fi
650
609
  return 0
651
610
  }
@@ -662,7 +621,7 @@ function __rvm_gemset_dump {
662
621
  gems="`gem list | sed 's/[\(|\)]//g' | sed 's/, /,/g' | tr ' ' ';'`"
663
622
  for gem in $gems ; do
664
623
  name=`echo $gem | awk -F';' '{print $1}'`
665
- if [ -z "$rvm_gem_latest" ] ; then
624
+ if [ -z "$rvm_latest_flag" ] ; then
666
625
  versions=`echo $gem | awk -F';' '{print $2}' | sed 's/,/ /g'`
667
626
  for version in $versions ; do
668
627
  echo "$name -v$version" >> $file_name.gemset
@@ -678,38 +637,86 @@ function __rvm_gemset_dump {
678
637
 
679
638
  function __rvm_gemset_load {
680
639
  echo "Loading $rvm_load_file file..."
681
- while read line < `cat "$rvm_load_file" | awk '/^[a-zA-Z]/{print}'` ; do
640
+ rvm_ruby_gem_list=`/bin/ls $rvm_gem_home/specifications/ | sed 's/\.gemspec$//' 2> /dev/null`
641
+ while read line
642
+ do # Keep this on 2nd line :( bash fail.
682
643
  # TODO: Switch to a different field separator than ; to allow for evals
683
644
  gem=`echo $line | awk -F';' '{print $1}'`
684
645
  gem_prefix=`echo $line | awk -F';' '{print $2}'`
685
646
  gem_name=`echo $gem | awk '{print $1}'`
686
647
  gem_version=`echo $gem | sed 's/^.*-v[=]*[ ]*//' | awk '{print $1}'`
687
648
  gem_postfix=`echo $gem | sed "s/$gem_name//" | sed "s/-v[=]*[ ]*$gem_version//"`
688
- gem_file="$gem_name-$gem_version.gem"
689
649
 
690
650
  if [ -z "$gem_version" ] ; then # no version
691
- file=`/bin/ls -t $rvm_gem_home/cache/${gem_name}* | head -n 1`
651
+ gem_file_name="${gem_name}*.gem"
692
652
  else # version
693
- file=`/bin/ls $rvm_gem_home/cache/$gem_file`
653
+ gem_file_name="$gem_name-$gem_version.gem"
694
654
  fi
695
-
696
- if [ -z "$file" ] ; then # not cached
697
- gem="$gem_name-$gem_version"
655
+ cache_file=`/bin/ls -t $rvm_gem_path/*/*/cache/${gem_file_name}* | head -n1 2> /dev/null`
656
+ if [ -z "$cache_file" ] ; then
657
+ if [ -z "$gem_version" ] ; then
658
+ gem="$gem_name"
659
+ else
660
+ gem="$gem_name -v $gem_version"
661
+ fi
698
662
  else # cached
699
- gem="$file -l" # install as a named local gem
663
+ gem_file_name=`basename $cache_file`
664
+ gem_string=`echo "$gem_file_name" | sed 's/\.gem$//'`
665
+ if [ ! -z "`echo "$rvm_ruby_gem_list" | awk "/$gem_string/{print}"`" ] ; then
666
+ if [ ! -z "$rvm_force_flag" ] ; then
667
+ cp $cache_file $rvm_path/tmp/$gem_file_name
668
+ gem="$rvm_path/tmp/$gem_file_name" # install as a named local gem
669
+ else
670
+ unset gem
671
+ __rvm_log "info" "$gem_name $gem_version is already installed, skipping. (use --force to force these to install regardless)"
672
+ fi
673
+ else
674
+ gem="$cache_file"
675
+ fi
700
676
  fi
701
677
 
702
- # TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line.
703
- if [ -z "$vars" ] ; then
704
- GEM_HOME="$rvm_gem_home" GEM_PATH="$rvm_gem_home" $gem_prefix $rvm_ruby_home/bin/gem install --no-rdoc --no-ri -q $gem $gem_postfix
705
- else
706
- eval "GEM_HOME='$rvm_gem_home' GEM_PATH='$rvm_gem_home' $gem_prefix $rvm_ruby_home/bin/gem install --no-rdoc --no-ri -q $gem $gem_postfix"
678
+ if [ ! -z "$gem" ] ; then
679
+ # TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line.
680
+ if [ -z "$vars" ] ; then
681
+ GEM_HOME="$rvm_gem_home" GEM_PATH="$rvm_gem_home" $gem_prefix $rvm_ruby_home/bin/gem install --no-rdoc --no-ri -q $gem $gem_postfix
682
+ else
683
+ eval "GEM_HOME='$rvm_gem_home' GEM_PATH='$rvm_gem_home' $gem_prefix $rvm_ruby_home/bin/gem install --no-rdoc --no-ri -q $gem $gem_postfix"
684
+ fi
707
685
  fi
708
- unset gem gem_prefix gem_name gem_version gem_file gem_postfix file
709
- done
686
+ unset gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string
687
+ done < <(awk '/^[a-zA-Z]/{print}' "$rvm_load_file")
688
+ }
689
+
690
+ function __rvm_irbrc {
691
+ if [ -d $rvm_ruby_home -a ! -s $rvm_ruby_irbrc ] ; then
692
+ rvm_irbrc_file=`cat <<-Config
693
+ load '$HOME/.irbrc' if File.exists?('$HOME/.irbrc') rescue nil
694
+
695
+ require "irb/completion" rescue nil
696
+
697
+ @prompt = {
698
+ :PROMPT_I => "${rvm_ruby_package_name} > ", # default prompt
699
+ :PROMPT_S => "${rvm_ruby_package_name}%l> ", # known continuation
700
+ :PROMPT_C => "${rvm_ruby_package_name} > ",
701
+ :PROMPT_N => "${rvm_ruby_package_name} ?> ", # unknown continuation
702
+ :RETURN => " => %s \n",
703
+ :AUTO_INDENT => true
704
+ }
705
+ @prompt_mode = :DEFAULT
706
+ IRB.conf[:PROMPT][@prompt_mode] = @prompt
707
+ IRB.conf[:PROMPT_MODE] = @prompt_mode
708
+ Config
709
+ `
710
+ touch $rvm_ruby_irbrc
711
+ echo -e "\n$rvm_irbrc_file" > $rvm_ruby_home/.irbrc
712
+ fi
713
+
710
714
  }
711
715
 
712
- # -C --with-readline-dir=$rvm_path/usr
716
+
717
+ #
718
+ # ruby supporting libraries:
719
+ #
713
720
  function __rvm_readline_install {
714
721
  pushd $rvm_path/src > /dev/null
715
722
  package=readline
@@ -732,7 +739,6 @@ function __rvm_readline_install {
732
739
  popd > /dev/null
733
740
  }
734
741
 
735
- # -C --with-iconv-dir=$rvm_path/usr
736
742
  function __rvm_iconv_install {
737
743
  pushd $rvm_path/src > /dev/null
738
744
  package=libiconv
@@ -746,3 +752,4 @@ function __rvm_iconv_install {
746
752
 
747
753
  popd > /dev/null
748
754
  }
755
+