Permalink
Browse files

Initial rake/gem code.

  • Loading branch information...
1 parent 9228d21 commit 0e880df7b56d088ebf8c28fd62de2affbfb92305 @wayneeseguin wayneeseguin committed Sep 17, 2009
Showing with 47 additions and 34 deletions.
  1. +3 −0 examples/rvmrc
  2. +13 −4 scripts/rvm-cli
  3. +2 −3 scripts/rvm-selector
  4. +29 −27 scripts/rvm-utility
View
3 examples/rvmrc
@@ -30,3 +30,6 @@
# Default gems directory
# rvm_gem_path="$HOME/.gem"
+
+# Install rubies on use when they are not installed
+#ruby_install_on_use=1
View
17 scripts/rvm-cli
@@ -91,9 +91,7 @@ function __rvm_usage {
--summary - Used with rubydo to print out a summary of the commands run.
--jit - Used with rubinius install to build with JIT
--latest - with gemset --dump skips version strings for latest gem.
- --reconfigure -
- --spec -
- --test -
+ --reconfigure - Force ./configure on install even if Makefile already exists.
Resources:
@@ -268,6 +266,17 @@ function __rvm_parse-args {
shift
;;
+ specs|tests)
+ rvm_action="rubydo"
+ rvm_ruby_args="rake $rvm_token"
+ ;;
+
+ rake|gem)
+ rvm_action="rubydo"
+ rvm_ruby_args="$rvm_token $@"
+ rvm_parse_break=1
+ ;;
+
-S|--script|-e|--execute)
rvm_action="rubydo"
rvm_ruby_args="$@"
@@ -304,7 +313,7 @@ function __rvm_parse-args {
--rm-gem-set) rvm_gem_set_name_rm="$1" ; shift ;;
tests|specs) rvm_action="tests" ;;
- --self|--gem|--rubygems|--reconfigure|--default|--debug|debug|--force|--all|--dump|--summary|--jit|--latest|--spec|--test)
+ --self|--gem|--rubygems|--reconfigure|--default|--debug|debug|--force|--all|--dump|--summary|--jit|--latest)
eval "rvm_$(echo $rvm_token | sed 's/-//g')_flag=1"
;;
View
5 scripts/rvm-selector
@@ -3,7 +3,7 @@
# __rvm_select implementation version patch_level
function __rvm_select {
- __rvm_ruby_string
+ if [ ! -z "$rvm_ruby_string" ] ; then __rvm_ruby_string ; fi
rvm_ruby_interpreter="${1:-$rvm_ruby_interpreter}"
rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}" # Default is standard ruby
@@ -178,8 +178,7 @@ function __rvm_use {
IRBRC="$rvm_ruby_irbrc" ; export IRBRC
if [ -z "$IRBRC" ] ; then unset IRBRC ; fi
- # Install if not installed
- if [ ! -d $MY_RUBY_HOME ] ; then
+ if [ ! -d $MY_RUBY_HOME -a ! -z "$rvm_install_on_use" ] ; then
__rvm_log "warn" "$rvm_ruby_interpreter $rvm_ruby_version is not installed."
echo -n -e "Would you like rvm to install $rvm_ruby_interpreter $rvm_ruby_version for you now?\n(Y/n) ? "
read response
View
56 scripts/rvm-utility
@@ -91,7 +91,7 @@ function __rvm_run {
}
function __rvm_cleanup-variables {
- 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
+ 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
}
# TODO: root user loadng of /etc/rvmrc
@@ -516,34 +516,36 @@ function __rvm_reload {
function __rvm_ruby_do {
__rvm_select
__rvm_use
- #__rvm_
binary=`echo $rvm_action | sed 's/do$//'`
- load_path="$rvm_ruby_home/bin:$rvm_ruby_load_path"
- if [ "$binary" = "ruby" ] ; then
- rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_require -I$load_path -S $rvm_ruby_args"
- else
- rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_args"
- fi
- echo "$rvm_ruby_string: $($rvm_ruby_home/bin/$binary -v)"
- eval $rvm_command
- result=$?
- if [ $result -eq 0 ]; then
- eval "successes=(${successes[*]} $rvm_ruby_string)"
+ if [ -x $rvm_ruby_home/bin/$binary ] ; then
+ load_path="$rvm_ruby_home/bin:$rvm_ruby_load_path"
+ if [ "$binary" = "ruby" ] ; then
+ rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_require -I$load_path -S $rvm_ruby_args"
+ else
+ rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_args"
+ fi
+ echo -e "\n$rvm_ruby_string: $($rvm_ruby_home/bin/$binary -v)"
+ eval $rvm_command
+ result=$?
+ if [ $result -eq 0 ]; then
+ eval "successes=(${successes[*]} $rvm_ruby_string)"
+ else
+ eval "errors=(${errors[*]} $rvm_ruby_string)"
+ fi
+ eval "all=(${all[*]} $rvm_ruby_string)"
+ eval "results=(${results[*]} $rvm_ruby_string)"
+ # TODO: keep track of and re-set the previous selected ruby ;)
else
- eval "errors=(${errors[*]} $rvm_ruby_string)"
+ __rvm_log "warn" "'$rvm_ruby_home/bin/$binary' either does not exist or is not executable? :("
fi
- eval "all=(${all[*]} $rvm_ruby_string)"
- eval "results=(${results[*]} $rvm_ruby_string)"
- # TODO: keep track of and re-set the previous selected ruby ;)
unset rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_ruby_package_name rvm_ruby_tag rvm_ruby_home rvm_ruby_irbrc rvm_ruby_binary rvm_ruby_string rvm_ruby_rev load_path
}
function __rvm_do {
all=() ; successes=() ; errors=() ; results=()
# TODO: Extract the common functionality out of the if below
if [ ! -z "$rvm_ruby_version" ] ; then
- rvm_ruby_selectors=$(echo $rvm_ruby_version | tr ',' ' ')
- for rvm_ruby_selector in $rvm_ruby_selectors ; do
+ for rvm_ruby_selector in `echo $rvm_ruby_version | tr ',' ' '` ; do
temp=$(echo $rvm_ruby_selector | awk '{print substr($1, 0, 1)}')
if [ ! -z "$(echo $temp | grep '[0-9]')" ] ; then
rvm_ruby_interpreter="ruby"
@@ -556,20 +558,20 @@ function __rvm_do {
__rvm_ruby_do
done
else # all
- set -x
- while read line
+ while read binary
do
- if [ -x $line ] ; then
- rvm_ruby_string=`dirname $line | xargs dirname | xargs basename`
+ if [ -x $binary ] ; then
+ rvm_ruby_string="`dirname $binary | xargs dirname | xargs basename`"
__rvm_ruby_do
fi
done < <(/bin/ls $rvm_path/*/bin/ruby 2> /dev/null)
fi
if [ ! -z "$rvm_summary_flag" ] ; then
export successes errors results
- echo -e "\n\033[0;32msuccessful (${#successes[*]}) : [ $(echo "${successes[*]}" | sed 's/ /, /g') ]\033[0m"
- echo -e "\n\033[0;31merrors (${#errors[*]}) : [ $(echo "${errors[*]}" | sed 's/ /, /g') ]\033[0m"
+ echo -e "\nSummary:"
+ echo -e "\033[0;32msuccessful (${#successes[*]}) : [ $(echo "${successes[*]}" | sed 's/ /, /g') ]\033[0m"
+ echo -e "\033[0;31merrors (${#errors[*]}) : [ $(echo "${errors[*]}" | sed 's/ /, /g') ]\033[0m"
echo -e "all (${#all[*]}) : [ $(echo "${all[*]}" | sed 's/ /, /g') ]"
echo -e "exit results: [ $(echo "${results[*]}" | sed 's/ /, /g') ]\n"
else
@@ -687,7 +689,7 @@ function __rvm_gemset_load {
}
function __rvm_irbrc {
- if [ ! -s "$rvm_ruby_irbrc" ] ; then
+ if [ -d $rvm_ruby_home -a ! -s $rvm_ruby_irbrc ] ; then
rvm_irbrc_file=`cat <<-Config
load '$HOME/.irbrc' if File.exists?('$HOME/.irbrc') rescue nil
@@ -706,7 +708,7 @@ IRB.conf[:PROMPT][@prompt_mode] = @prompt
IRB.conf[:PROMPT_MODE] = @prompt_mode
Config
`
- touch $rvm_ruby_home/.irbrc
+ touch $rvm_ruby_irbrc
echo -e "\n$rvm_irbrc_file" > $rvm_ruby_home/.irbrc
fi

0 comments on commit 0e880df

Please sign in to comment.