scripts/gemsets in rvm-1.0.11 vs scripts/gemsets in rvm-1.0.13

- old
+ new

@@ -4,11 +4,12 @@ rvm_ruby_gem_home="${rvm_ruby_gem_home:-$GEM_HOME}" if [[ ! -d "$rvm_ruby_gem_home" ]] && command -v gem > /dev/null 2>&1; then rvm_ruby_gem_home="$(gem env home)" ; fi -usage() { +usage() +{ printf " Usage: rvm gemset [action] @@ -21,11 +22,12 @@ Commands for working with and manipulating gemsets within RVM. " } -gemset_update() { +gemset_update() +{ if [[ -z "$rvm_ruby_strings" ]]; then "$rvm_path/scripts/log" "info" "Running gem update for all rubies and gemsets." @@ -44,12 +46,12 @@ "$rvm_path/scripts/set" "gem" "update" return $? } -gemset_globalcache() { - +gemset_globalcache() +{ local gc_status globalcache_enabled directories directory_name full_directory_path directory_name if [[ "$1" == "enabled" ]]; then __rvm_using_gemset_globalcache @@ -133,34 +135,48 @@ " return 1 fi } -gemset_name() { +gemset_name() +{ gemset_dir | awk -F${rvm_gemset_separator:-"@"} '{print $2}' return $? } -gemset_dir() { +gemset_dir() +{ echo "$rvm_ruby_gem_home" return $? } -gemset_create() { +gemset_create() +{ local gem_home gemset gemsets prefix + if [[ -n "$rvm_ruby_string" ]] ; then + __rvm_select + fi + prefix=$(echo $rvm_ruby_gem_home | sed 's/'${rvm_gemset_separator:-"@"}'.*$//') gemsets=(${args[@]}) for gemset in "${gemsets[@]}" ; do if [[ "$gemset" == *"${rvm_gemset_separator:-"@"}"* ]]; then - "$rvm_path/scripts/log" "error" "Can't do that, it contains a \"${rvm_gemset_separator:-"@"}\"." + "$rvm_path/scripts/log" "error" \ + "Can not create gemset '$gemset', it contains a \"${rvm_gemset_separator:-"@"}\"." continue fi + if [[ -z "$gemset" || "$gemset" = *"${rvm_gemset_separator:-"@"}" ]] ; then + "$rvm_path/scripts/log" "error" \ + "Can not create gemset '$gemset', Missing name. " + continue + fi + gem_home="${prefix}${rvm_gemset_separator:-"@"}${gemset}" if [[ ! -d "$gem_home" ]] ; then mkdir -p "$gem_home" fi @@ -182,12 +198,12 @@ done return 0 } -gemset_list() { - +gemset_list() +{ if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi "$rvm_path/scripts/log" "info" \ "\ngemsets for $rvm_ruby_string (found in ${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string)" @@ -211,12 +227,12 @@ printf "\n" return 0 } -gemset_delete() { - +gemset_delete() +{ gemsets=(${args[@]}) if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi if [[ -n "${gemsets[__array_start]}" ]] ; then @@ -264,12 +280,12 @@ fi return 0 } -gemset_empty() { - +gemset_empty() +{ local gemdir if [[ -z "${rvm_ruby_gem_home:-""}" ]] ; then __rvm_select ; fi gemdir="$rvm_ruby_gem_home" @@ -303,11 +319,12 @@ return 0 } # Migrate gemsets from ruby X to ruby Y -gemset_copy() { +gemset_copy() +{ local source_ruby destination_ruby source_path destination_path source_ruby="${args[__array_start]:-""}" args[$__array_start]="" ; args=(${args[@]}) @@ -328,16 +345,18 @@ source_path="$(rvm_silence_logging=1 rvm "$source_ruby" gem env gemdir)" destination_path="$(rvm_silence_logging=1 rvm "$destination_ruby" gem env gemdir)" if [[ -z "$source_path" || ! -d "$source_path" ]]; then - "$rvm_path/scripts/log" "error" "Unable to expand '$source_ruby' or directory does not exist." + "$rvm_path/scripts/log" "error" \ + "Unable to expand '$source_ruby' or directory does not exist." return 1 fi if [[ -z "$destination_path" ]]; then - "$rvm_path/scripts/log" "error" "Unable to expand '$destination_ruby'" + "$rvm_path/scripts/log" "error" \ + "Unable to expand '$destination_ruby'" return 1 fi if [[ -d "$source_path" ]] ; then @@ -366,12 +385,12 @@ "Gems directory does not exist for $source_path ($source_path)" return 1 fi } -gemset_unpack() { - +gemset_unpack() +{ local gems name directory version versions directory="${args[$__array_start]}" if [[ -z "$directory" ]] ; then @@ -409,11 +428,12 @@ "Unpacking into ${directory} complete\n" return 0 } -gemset_export() { +gemset_export() +{ local gems name file_name version versions rvm_file_name="${rvm_file_name:-${gems_args// }}" if [[ -n "$rvm_ruby_gem_home" ]] ; then @@ -459,12 +479,12 @@ done return 0 } -gemset_import() { - +gemset_import() +{ unset -f gem if [[ -n "${rvm_ruby_gem_home:-""}" ]] ; then export GEM_HOME="$rvm_ruby_gem_home" export GEM_PATH="$rvm_ruby_gem_home" @@ -526,12 +546,12 @@ else "$rvm_path/scripts/log" "error" "${rvm_file_name} does not exist to import from." fi } -__rvm_parse_gems_args() { - +__rvm_parse_gems_args() +{ gem="${gems_args/;*}" ; gem_prefix="" if echo "$gems_args" | grep -q ';' ; then gem_prefix="${gems_args/*;}" fi @@ -570,12 +590,12 @@ gem_file_name="${gem_name/ /}-${gem_version/ /}.gem" fi } # Install a gem -gem_install() { - +gem_install() +{ local gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action result=0 # First we parse the gem args to pick apart the pieces. @@ -674,11 +694,12 @@ return $result } # Output the user's current gem directory. -gemset_info() { +gemset_info() +{ if [[ ${rvm_user_flag:-0} -eq 1 ]] ; then echo $(rvm system ; gem env | grep "\- $HOME" | awk '{print $NF}') elif [[ ${rvm_system_flag:-0} -eq 1 ]] ; then echo $(rvm system ; gem env $action system) @@ -694,11 +715,12 @@ fi return $? } -gemset_prune() { +gemset_prune() +{ local temporary_cache_path live_cache_path gemset_name version versions cached_gem_name cached_file_path temporary_cache_path="$GEM_HOME/temporary-cache" live_cache_path="$GEM_HOME/cache" @@ -735,11 +757,12 @@ mv "$temporary_cache_path" "$live_cache_path" return 0 } -gemset_pristine() { +gemset_pristine() +{ if ( unset -f gem ; command -v gem > /dev/null ) ; then gem pristine --all return $? @@ -752,20 +775,20 @@ return 1 fi } # Loads the default gemsets for the current interpreter and gemset. -gemset_initial() { - +gemset_initial() +{ local gemsets gemset path paths rvm_gemsets_path="${rvm_gemsets_path:-"$rvm_path/gemsets"}" "$rvm_path/scripts/log" "info" \ "Importing initial gemsets for $(__rvm_environment_identifier)." - if [[ ! -d "$rvm_gemsets_path/${rvm_ruby_string//-/\/}" ]] ; then - mkdir -p "$rvm_gemsets_path/${rvm_ruby_string//-/\/}" 2>/dev/null + if [[ ! -d "$rvm_gemsets_path/${rvm_ruby_string//-//}" ]] ; then + mkdir -p "$rvm_gemsets_path/${rvm_ruby_string//-//}" 2>/dev/null fi paths=($(__rvm_ruby_string_paths_under "$rvm_gemsets_path")) echo "paths: ${paths[@]}"