Skip to content

Commit

Permalink
Standardizing on rvm_env_string for {rvm_ruby_string}[@{rvm_gemset_na…
Browse files Browse the repository at this point in the history
…me}]
  • Loading branch information
wayneeseguin committed Sep 13, 2011
1 parent b408bff commit 1664d04
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 62 deletions.
2 changes: 1 addition & 1 deletion scripts/alias
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ alias_create() {
return $result
fi

final_environment_identifier="${rvm_environment_identifier:-$(__rvm_environment_identifier)}"
final_environment_identifier="${rvm_environment_identifier:-$(__rvm_env_string)}"

rvm_log "Creating alias $alias_name for $final_environment_identifier."

Expand Down
2 changes: 1 addition & 1 deletion scripts/current
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi

source "$rvm_scripts_path/base"

printf "$(__rvm_environment_identifier)\n"
printf "$(__rvm_env_string)\n"
exit 0
2 changes: 1 addition & 1 deletion scripts/docs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ rvm_base_except="selector"

source "$rvm_scripts_path/base"

rvm_docs_ruby_string="$(__rvm_environment_identifier | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
rvm_docs_ruby_string="$(__rvm_env_string | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"

if [[ "$rvm_docs_ruby_string" = "system" || -z "$rvm_docs_ruby_string" ]]; then

Expand Down
2 changes: 1 addition & 1 deletion scripts/env
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ __rvm_become "$environment_name"

if [[ "$?" = 0 ]]; then
__rvm_use
environment_file_path="$rvm_environments_path/$(__rvm_environment_identifier)"
environment_file_path="$rvm_environments_path/$(__rvm_env_string)"
# Echo the path or environment file.
if [[ -n "$rvm_path_flag" ]]; then
echo "$environment_file_path"
Expand Down
6 changes: 3 additions & 3 deletions scripts/environment-convertor
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ convert_exports_to_fish()

contents_of_environment_file()
{
cat "$rvm_environments_path/$(__rvm_environment_identifier)"
cat "$rvm_environments_path/$(__rvm_env_string)"
}

convert_to_shell()
Expand All @@ -61,13 +61,13 @@ ensure_has_shell()

args=($*)
shell_name="${args[0]}"
environment_name="${args[1]:-"$(__rvm_environment_identifier)"}"
environment_name="${args[1]:-"$(__rvm_env_string)"}"
args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.

[[ -n "$shell_name" && -n "$environment_name" ]] || exit 1
ensure_has_shell "$shell_name" || exit 1
# Check we're loading a different shell.
if [[ "$(__rvm_environment_identifier)" != "$environment_name" ]]; then
if [[ "$(__rvm_env_string)" != "$environment_name" ]]; then
__rvm_become "$environment_name" || exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion scripts/functions/build
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ __rvm_mri_ruby()
{
local versions="${1:-"1.8.|ree|1.9."}"
_mri_rubies=( $( __rvm_mri_rubies "$versions" ) )
_current_ruby=$(__rvm_environment_identifier)
_current_ruby=$(__rvm_env_string)
if [[ " ${_mri_rubies[*]} " =~ " ${_current_ruby} " ]]
then
printf "${_current_ruby}\n"
Expand Down
4 changes: 2 additions & 2 deletions scripts/functions/env
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ __rvm_nuke_rvm_variables()
__rvm_unset_ruby_variables()
{
# unset rvm_ruby_flag $(env | awk -F= '/^rvm_ruby_/{printf $1" "}')
unset rvm_ruby_string rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_tag rvm_ruby_version rvm_ruby_load_path rvm_ruby_require rvm_head_flag rvm_ruby_package_file rvm_ruby_configure rvm_ruby_name rvm_ruby_url rvm_ruby_global_gems_path rvm_ruby_args rvm_ruby_name rvm_llvm_flag
unset rvm_env_string rvm_ruby_string rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_tag rvm_ruby_version rvm_ruby_load_path rvm_ruby_require rvm_head_flag rvm_ruby_package_file rvm_ruby_configure rvm_ruby_name rvm_ruby_url rvm_ruby_global_gems_path rvm_ruby_args rvm_ruby_name rvm_llvm_flag
}


Expand All @@ -36,7 +36,7 @@ __rvm_cleanse_variables()
unset rvm_gemset_name
fi

unset rvm_ruby_string rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_import_flag rvm_export_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_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_ruby_aliases rvm_patch_names rvm_clang_flag rvm_install_args rvm_dump_environment_flag rvm_ruby_alias rvm_static_flag rvm_archive_extension rvm_hook rvm_ruby_name
unset rvm_env_string rvm_ruby_string rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_import_flag rvm_export_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_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_ruby_aliases rvm_patch_names rvm_clang_flag rvm_install_args rvm_dump_environment_flag rvm_ruby_alias rvm_static_flag rvm_archive_extension rvm_hook rvm_ruby_name
# rvm_gemsets_path rvm_user_path rvm_wrappers_path rvm_patches_path rvm_docs_path rvm_examples_path rvm_rubies_path rvm_usr_path rvm_src_path rvm_tmp_path rvm_lib_path rvm_repos_path rvm_log_path rvm_help_path rvm_environments_path rvm_archives_path
}

Expand Down
30 changes: 15 additions & 15 deletions scripts/functions/environment
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env bash

__rvm_environment_identifier()
__rvm_env_string()
{
local path string
local _path _string

path="${GEM_HOME:-""}"
_path="${GEM_HOME:-""}"

string="${path//*gems\//}"
string="${string//\/*/}"
_string="${_path//*gems\//}"
_string="${_string//\/*/}"

printf "${string:-system}"
printf "${_string:-system}"
}

__rvm_expand_ruby_string()
Expand Down Expand Up @@ -43,15 +43,16 @@ __rvm_expand_ruby_string()
;;

current-ruby|gemsets)
current_ruby="$(__rvm_environment_identifier \
| awk -F"${rvm_gemset_separator:-"@"}" '{print $string}')"
current_ruby="$(
__rvm_env_string | awk -F"${rvm_gemset_separator:-"@"}" '{print $string}'
)"

rvm_silence_logging=1 "$rvm_scripts_path/gemsets" list \
| \sed "s/^/$current_ruby${rvm_gemset_separator:-"@"}/"
;;

current)
__rvm_environment_identifier
__rvm_env_string
;;

aliases)
Expand Down Expand Up @@ -80,7 +81,7 @@ __rvm_ensure_has_environment_files()
{
local environment_id file_name directory identifier variable value variables

environment_id="$(__rvm_environment_identifier)"
environment_id="$(__rvm_env_string)"

file_name="${rvm_path}/environments/$environment_id"

Expand All @@ -91,12 +92,11 @@ __rvm_ensure_has_environment_files()
printf "export PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path}:\$PATH\"\n" \
> "$file_name"

for variable in rvm_path RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC \
rvm_ruby_string rvm_gemset_name MAGLEV_HOME RBXOPT
for variable in rvm_env_string rvm_path rvm_ruby_string rvm_gemset_name \
RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC MAGLEV_HOME RBXOPT
do
eval "export $variable"
eval "value=\${${variable}:-""}"

if [[ -n "$value" ]]
then
printf "%s='%s' ; export %s\n" "${variable}" "${value}" "${variable}" \
Expand Down Expand Up @@ -149,7 +149,7 @@ __rvm_dump_environment()
&& ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1
else
"$rvm_scripts_path/environment-convertor" "$dump_environment_type" \
"$(__rvm_environment_identifier)" > "$dump_environment_file"
"$(__rvm_env_string)" > "$dump_environment_file"
if (( $? > 0 )) && [[ -f "$dump_environment_file" ]]
then
\rm -f "$dump_environment_file"
Expand Down Expand Up @@ -197,7 +197,7 @@ __rvm_run_with_env()
command="${3:-""}"
message="${4:-""}"

[[ -n "$environment" ]] || environment="$(__rvm_environment_identifier)"
[[ -n "$environment" ]] || environment="$(__rvm_env_string)"

if [[ -n "$message" ]] ; then rvm_log "$message" ; fi

Expand Down
4 changes: 2 additions & 2 deletions scripts/functions/rvmrc
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ __rvm_project_rvmrc()
local rvm_trustworthiness_result=$?
if (( $rvm_trustworthiness_result == 0 ))
then
rvm_previous_environment="$(__rvm_environment_identifier)"
rvm_previous_environment="$(__rvm_env_string)"
rvm_current_rvmrc="$working_dir/.rvmrc"
source "$working_dir/.rvmrc"
return 0
Expand Down Expand Up @@ -360,7 +360,7 @@ __rvm_set_rvmrc()
rvm_warn ".rvmrc is not empty, moving aside to preserve."
fi

local identifier=$(__rvm_environment_identifier)
local identifier=$(__rvm_env_string)

printf "#!/usr/bin/env bash
Expand Down
2 changes: 1 addition & 1 deletion scripts/functions/state
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ __rvm_state()
{
if [[ -z "$rvm_state" ]] ; then

rvm_state="$(__rvm_environment_identifier)"
rvm_state="$(__rvm_env_string)"

rvm_state="${rvm_state:-"system"}"

Expand Down
8 changes: 4 additions & 4 deletions scripts/gemsets
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ gemset_create()
gemsets=(${args[@]})
for gemset in "${gemsets[@]}"
do
if [[ "$(__rvm_environment_identifier)" == "system" ]]
if [[ "$(__rvm_env_string)" == "system" ]]
then
rvm_error "Can not create gemset before using a ruby. Try 'rvm use <some ruby>'."
return 1
Expand Down Expand Up @@ -872,7 +872,7 @@ gemset_initial()

true ${rvm_gemsets_path:="$rvm_path/gemsets"}

rvm_log "Importing initial gemsets for $(__rvm_environment_identifier)."
rvm_log "Importing initial gemsets for $(__rvm_env_string)."

if [[ ! -d "$rvm_gemsets_path/${rvm_ruby_string//-//}" ]]
then
Expand Down Expand Up @@ -907,7 +907,7 @@ gemset_initial()
fi
fi
done
rvm_log "Installation of gems for $(__rvm_environment_identifier) is complete."
rvm_log "Installation of gems for $(__rvm_env_string) is complete."
return 0
}

Expand Down Expand Up @@ -984,7 +984,7 @@ case "$action" in
then
gemset_import
else
original_env="$(__rvm_environment_identifier)"
original_env="$(__rvm_env_string)"
for rvm_ruby_string in $(echo "$rvm_ruby_strings" | tr "," " ")
do
__rvm_become
Expand Down
6 changes: 3 additions & 3 deletions scripts/info
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ info_rvm()

info_ruby()
{
[[ "$(__rvm_environment_identifier)" == "system" ]] && return
[[ "$(__rvm_env_string)" == "system" ]] && return
ruby=$(command -v ruby)
if [[ $? -eq 0 ]] && [[ -x "$ruby" ]] ; then full_version="$($ruby -v)" ; fi
rvm_info="
Expand Down Expand Up @@ -184,7 +184,7 @@ fi

if [[ -z "$ruby_strings" ]] ; then

printf "\n$(__rvm_environment_identifier):\n"
printf "\n$(__rvm_env_string):\n"

info_sections

Expand All @@ -194,7 +194,7 @@ else

__rvm_become "$ruby_string"

printf "\n$(__rvm_environment_identifier):\n"
printf "\n$(__rvm_env_string):\n"

info_sections

Expand Down
5 changes: 2 additions & 3 deletions scripts/list
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ list_gemsets()
return 0
fi

current_ruby="$(__rvm_environment_identifier)"
current_ruby="$(__rvm_env_string)"

all_rubies="$(list_strings)"

Expand Down Expand Up @@ -256,8 +256,7 @@ list_rubies()
fi

current_ruby="$(
__rvm_environment_identifier | \
awk -F"${rvm_gemset_separator:-"@"}" '{print $1}'
__rvm_env_string | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}'
)"

printf "\nrvm rubies\n"
Expand Down
14 changes: 12 additions & 2 deletions scripts/selector
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__rvm_select()
{
true ${rvm_gemset_name:=}
local _original_env_string=${rvm_env_string}

# Set Variable Defaults
export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION
Expand Down Expand Up @@ -311,6 +312,8 @@ __rvm_select()
esac
fi

rvm_env_string=${rvm_ruby_string}

if [[ -n "$rvm_ruby_version" ]]
then
case "$rvm_ruby_version" in
Expand Down Expand Up @@ -356,9 +359,16 @@ __rvm_select()
\mkdir -p "${rvm_log_path}/$rvm_ruby_string"
fi

export rvm_action rvm_alias_expanded rvm_archflags rvm_archive_extension rvm_bin_flag rvm_bin_path rvm_clang_flag rvm_configure_flags rvm_debug_flag rvm_default_flag rvm_delete_flag rvm_docs_type rvm_dump_environment_flag rvm_error_message rvm_expanding_aliases rvm_file_name rvm_gemdir_flag rvm_gemset_name rvm_gemstone_package_file rvm_gemstone_url rvm_head_flag rvm_hook rvm_install_args rvm_install_on_use_flag rvm_llvm_flag rvm_loaded_flag rvm_make_flags rvm_niceness rvm_nightly_flag rvm_only_path_flag rvm_parse_break rvm_patch_names rvm_patch_original_pwd rvm_pretty_print_flag rvm_prior_cc rvm_proxy rvm_quiet_flag rvm_ree_options rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_aliases rvm_ruby_args rvm_ruby_binary rvm_ruby_bits rvm_ruby_configure rvm_ruby_file rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_global_gems_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_load_path rvm_ruby_major_version rvm_ruby_make rvm_ruby_make_install rvm_ruby_minor_version rvm_ruby_mode rvm_ruby_name rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_patch rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_require rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_sha rvm_ruby_string rvm_ruby_strings rvm_ruby_tag rvm_ruby_url rvm_ruby_user_tag rvm_ruby_version rvm_script_name rvm_sdk rvm_silent_flag rvm_sticky_flag rvm_system_flag rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_wrapper_name
export rvm_env_string rvm_action rvm_alias_expanded rvm_archflags rvm_archive_extension rvm_bin_flag rvm_bin_path rvm_clang_flag rvm_configure_flags rvm_debug_flag rvm_default_flag rvm_delete_flag rvm_docs_type rvm_dump_environment_flag rvm_error_message rvm_expanding_aliases rvm_file_name rvm_gemdir_flag rvm_gemset_name rvm_gemstone_package_file rvm_gemstone_url rvm_head_flag rvm_hook rvm_install_args rvm_install_on_use_flag rvm_llvm_flag rvm_loaded_flag rvm_make_flags rvm_niceness rvm_nightly_flag rvm_only_path_flag rvm_parse_break rvm_patch_names rvm_patch_original_pwd rvm_pretty_print_flag rvm_prior_cc rvm_proxy rvm_quiet_flag rvm_ree_options rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_aliases rvm_ruby_args rvm_ruby_binary rvm_ruby_bits rvm_ruby_configure rvm_ruby_file rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_global_gems_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_load_path rvm_ruby_major_version rvm_ruby_make rvm_ruby_make_install rvm_ruby_minor_version rvm_ruby_mode rvm_ruby_name rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_patch rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_require rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_sha rvm_ruby_string rvm_ruby_strings rvm_ruby_tag rvm_ruby_url rvm_ruby_user_tag rvm_ruby_version rvm_script_name rvm_sdk rvm_silent_flag rvm_sticky_flag rvm_system_flag rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_wrapper_name

rvm_ruby_interpreter="${rvm_ruby_interpreter:-system}"

if [[ -n "${rvm_gemset_name}" ]]
then
rvm_env_string="${rvm_ruby_string}@${rvm_gemset_name}"
else
rvm_env_string=${rvm_ruby_string}
fi
}

__rvm_use_system() {
Expand Down Expand Up @@ -501,7 +511,7 @@ __rvm_use()
__rvm_set_rvmrc
fi

local environment_id="$(__rvm_environment_identifier)"
local environment_id="$(__rvm_env_string)"

if (( ${rvm_default_flag:=0} == 1 )) &&
[[ "default" != "${rvm_ruby_interpreter:-""}" ]]
Expand Down
26 changes: 7 additions & 19 deletions scripts/set
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,14 @@ __rvm_ruby_do()
eval "$command" >> "./log/$rvm_ruby_string/$action.log" 2>&1

else
if [[ ${rvm_verbose_flag:-0} -gt 0 ]] ; then

current_env="$(__rvm_environment_identifier)"

if [[ "$current_env" != "$current_set_ruby" ]]; then

if (( ${rvm_verbose_flag:-0} > 0 ))
then
current_env="$(__rvm_env_string)"
if [[ "$current_env" != "$current_set_ruby" ]]
then
current_env="$current_set_ruby ($current_env)"

fi

rvm_log "$current_env: $(ruby -v $rvm_ruby_mode | \tr "\n" ' ')\n"

unset current_env
fi
eval "$command"
Expand All @@ -125,24 +121,16 @@ __rvm_ruby_do()

string=$(basename $rvm_ruby_gem_home)

if [[ $result -eq 0 ]]; then

if (( result == 0 ))
then
eval "successes=(${successes[*]} $string)"

else

eval "errors=(${errors[*]} $string)"

fi

eval "rubies=(${rubies[*]} $string)"

eval "statuses=(${statuses[*]} $result)"

unset string

rvm_hook="after_do" ; source "$rvm_scripts_path/hook"

__rvm_unset_ruby_variables
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/tools
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ usage()
# Return the identifier that's current in use.
tools_identifier()
{
__rvm_environment_identifier
__rvm_env_string
}

tools_path_identifier()
Expand All @@ -25,7 +25,7 @@ tools_path_identifier()
builtin cd "$1"
rvm_promptless=1 __rvm_project_rvmrc >/dev/null 2>&1
rvmrc_result="$?"
__rvm_environment_identifier
__rvm_env_string
exit $rvmrc_result
}

Expand Down
Loading

0 comments on commit 1664d04

Please sign in to comment.