Skip to content

Commit

Permalink
Merge branch 'set_refactoring'
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin committed May 29, 2010
2 parents c9568ee + a8b2992 commit e29abcb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 39 deletions.
29 changes: 19 additions & 10 deletions scripts/cli
Expand Up @@ -52,6 +52,7 @@ __rvm_parse_args() {
if [[ "rubinius" = "$rvm_token" ]] ; then rvm_token="rbx"; fi
rvm_ruby_interpreter="$rvm_token"
rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
rvm_action="${rvm_action:-use}"
if $rvm_scripts_path/match "$1" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$1 ; shift ; fi
;;
Expand Down Expand Up @@ -129,7 +130,7 @@ __rvm_parse_args() {
rvm_action="error"
rvm_error_message="'rvm $rvm_action' must be followed by arguments."
elif [[ "ruby" = "$rvm_action" ]] ; then
if [[ -z "$(echo "$rvm_ruby_version" | awk '/,/')" ]] ; then
if [[ -z "$(echo "$rvm_ruby_strings" | awk '/,/')" ]] ; then
rvm_action="ruby"
rvm_ruby_args=""
else
Expand All @@ -151,16 +152,18 @@ __rvm_parse_args() {
fi
else
if $rvm_scripts_path/match "$1" "^-" ; then
unset rvm_ruby_version
unset rvm_ruby_strings
else
if $rvm_scripts_path/match "$1" "^[0-9]" ; then
rvm_ruby_version=$(echo "$1" | tr ',' ' ') ; shift
rvm_ruby_strings=$(echo "$1" | tr ',' ' ') ; shift
unset rvm_ruby_interpreter
else
if $rvm_scripts_path/match "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby" "$1" ; then
rvm_ruby_interpreter=$1 ; shift
rvm_ruby_strings=$1
rvm_ruby_interpreter=$1
shift
else
unset rvm_ruby_interpreter rvm_ruby_version
unset rvm_ruby_interpreter rvm_ruby_strings
fi
fi
fi
Expand Down Expand Up @@ -343,24 +346,28 @@ __rvm_parse_args() {
rvm_file_name="$rvm_gemset_name.gems"
fi
elif [[ ! -z "$(echo "$rvm_token" | awk '/,/')" ]] ; then
rvm_ruby_version="$rvm_token"
rvm_ruby_strings="$rvm_token" # Migrating to this from rvm_ruby_version
rvm_ruby_strings="$rvm_token"
if [[ -z "$rvm_action" ]] ; then
rvm_action="ruby" # Not sure if we really want to do this but we'll try it out.
fi
elif $rvm_scripts_path/match "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
rvm_gemset_name="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $2}')"
rvm_ruby_string="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $1}')"
rvm_ruby_strings="$rvm_token"
elif $rvm_scripts_path/match "$rvm_token" "-" ; then
rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
elif $rvm_scripts_path/match "$rvm_token" "^[0-9].[0-9]" ; then
rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
rvm_action="${rvm_action:-use}"
elif $rvm_scripts_path/match "$rvm_token" "^ree-" ; then
rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
rvm_action="${rvm_action:-use}"
elif [[ -L "$rvm_rubies_path/$rvm_token" ]] ; then # Alias
rvm_ruby_string=$rvm_token
rvm_ruby_strings="$rvm_token"
rvm_action="${rvm_action:-use}"
else
if $rvm_scripts_path/match "$rvm_token" "\.rb$" ; then # we have a specified ruby script
Expand Down Expand Up @@ -468,7 +475,9 @@ rvm() {
ruby|gem|rake)
old_rvm_ruby_string=$rvm_ruby_string
unset rvm_ruby_string
export rvm_ruby_strings
$rvm_scripts_path/set $rvm_action $rvm_ruby_args
# Restore the state pre-sets.
[[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
unset old_rvm_ruby_string
result=$?
Expand Down Expand Up @@ -500,7 +509,7 @@ rvm() {
;;

monitor)
export rvm_ruby_version rvm_ruby_string
export rvm_ruby_strings rvm_ruby_string
$rvm_scripts_path/monitor ; result=$?
;;
notes) $rvm_scripts_path/notes ; result=$? ;;
Expand All @@ -509,8 +518,8 @@ rvm() {
fetch|install|uninstall|remove)
if [[ ! -z "$rvm_ruby_string" ]] ; then
$rvm_scripts_path/manage "$rvm_action" "$rvm_ruby_string"
elif $rvm_scripts_path/match "$rvm_ruby_version" "," ; then
$rvm_scripts_path/manage "$rvm_action" "$rvm_ruby_version"
elif $rvm_scripts_path/match "$rvm_ruby_strings" "," ; then
$rvm_scripts_path/manage "$rvm_action" "$rvm_ruby_strings"
else
$rvm_scripts_path/manage "$rvm_action"
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/info
Expand Up @@ -131,7 +131,7 @@ fi
if [[ -z "$sections" ]] ; then sections="$all_sections" ; fi

if [[ -z "$ruby_strings" ]] ; then
printf "$(echo "$GEM_HOME" | xargs basename):\n"
printf "$(__rvm_environment_identifier):\n"
info_sections
else
for ruby_string in $(printf $ruby_strings | tr ',' ' ') ; do
Expand Down
6 changes: 3 additions & 3 deletions scripts/monitor
Expand Up @@ -2,7 +2,7 @@

if [[ -z "$rvm_trace_flag" ]] ; then set +x ; else set -x ; fi

original_ruby_version=$rvm_ruby_version
original_ruby_strings=$rvm_ruby_strings
original_ruby_string=$rvm_ruby_string

source $rvm_scripts_path/rvm
Expand Down Expand Up @@ -57,7 +57,7 @@ while : ; do
done

if [[ "$(array_length "changed_${framework}_files")" -gt 0 ]] ; then
rvm_ruby_version=$original_ruby_version
rvm_ruby_strings=$original_ruby_strings
rvm_ruby_string=$original_ruby_string
if [[ "spec" = "$framework" ]] ; then
rvm_action="spec"
Expand All @@ -72,7 +72,7 @@ while : ; do
fi

if [[ "$(array_length "changed_code_files")" -gt 0 ]] ; then
rvm_ruby_version=$original_ruby_version
rvm_ruby_strings=$original_ruby_strings
rvm_ruby_string=$original_ruby_string
if [[ "spec" = "$framework" ]] ; then
rvm_action="spec"
Expand Down
2 changes: 2 additions & 0 deletions scripts/selector
Expand Up @@ -255,6 +255,7 @@ __rvm_use() {

if [[ ! -z "$rvm_verbose_flag" ]] ; then
$rvm_scripts_path/log "info" "Now using system ruby."
printf "\n"
fi

export rvm_ruby_string="system"
Expand Down Expand Up @@ -286,6 +287,7 @@ __rvm_use() {

if [[ ! -z "$rvm_verbose_flag" ]] ; then
$rvm_scripts_path/log "info" "Using $(basename $GEM_HOME | tr '-' ' ' | sed 's/'${rvm_gemset_separator}'/ with gemset /')"
printf "\n"
fi

new_path="$(echo $PATH | tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)"
Expand Down
22 changes: 4 additions & 18 deletions scripts/set
Expand Up @@ -148,25 +148,11 @@ __rvm_json() {
# Record the results and report based on CLI selections.

rubies=() ; successes=() ; errors=() ; statuses=()
# TODO: Extract the common functionality out of the if below
if [[ ! -z "$rvm_ruby_string" ]] ; then
unset rvm_ruby_interpreter rvm_ruby_version

rvm_ruby_strings="${rvm_ruby_strings:-"$($rvm_scripts_path/list strings)"}"
for rvm_ruby_string in $(echo "$rvm_ruby_strings" | tr ',' ' ') ; do
__rvm_ruby_do
elif [[ ! -z "$rvm_ruby_version" ]] ;then
for rvm_ruby_string in $(echo $rvm_ruby_version | tr ',' ' ') ; do
__rvm_ruby_do
done
elif [[ ! -z "$rvm_ruby_interpreter" ]] ; then
unset rvm_ruby_string rvm_ruby_version
__rvm_ruby_do
else # all
for full_binary in $rvm_rubies_path/*/bin/ruby ; do
if [[ -x "$full_binary" ]] ; then
rvm_ruby_string="$(dirname $full_binary | xargs dirname | xargs basename)"
__rvm_ruby_do
fi
done ; unset full_binary
fi
done

if [[ ! -z "$rvm_summary_flag" ]] ; then __rvm_summary ; fi
if [[ ! -z "$rvm_yaml_flag" ]] ; then __rvm_yaml ; fi
Expand Down
13 changes: 6 additions & 7 deletions scripts/utility
Expand Up @@ -21,6 +21,10 @@ __rvm_teardown() {
else
:
fi
# Ruby strings are scoped to their action.
# Hence, we ensure we remove them at in
# the cleanup phase.
unset rvm_ruby_strings
}

# Query the rvm key-value database for a specific key
Expand Down Expand Up @@ -116,7 +120,7 @@ __rvm_cleanup_variables() {

# Unset ruby-specific variables
__rvm_unset_ruby_variables() {
unset rvm_ruby_interpreter rvm_ruby_version rvm_url rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_release_version rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_ruby_binary rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_src_path rvm_ruby_repo_url rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_head_flag rvm_ruby_configure rvm_ruby_mode rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_gem_path rvm_ruby_name rvm_ruby_alias
unset rvm_ruby_interpreter rvm_ruby_version rvm_url rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_release_version rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_ruby_binary rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_src_path rvm_ruby_repo_url rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_head_flag rvm_ruby_configure rvm_ruby_mode rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_gem_path rvm_ruby_name rvm_ruby_alias rvm_ruby_strings
}

__rvm_set_rvmrc() {
Expand Down Expand Up @@ -545,12 +549,7 @@ __rvm_mono_env() {
}

__rvm_environment_identifier() {
rvm_environment_identifier="${rvm_ruby_string}"
if [[ -n "${rvm_gemset_name}" ]]; then
rvm_environment_identifier="${rvm_environment_identifier}${rvm_gemset_separator}${rvm_gemset_name}"
fi
echo "$rvm_environment_identifier"
unset rvm_environment_identifier
echo "$GEM_HOME" | xargs basename
}

__rvm_ensure_has_enviroment_files() {
Expand Down

0 comments on commit e29abcb

Please sign in to comment.