scripts/utility in rvm-0.0.51 vs scripts/utility in rvm-0.0.52

- old
+ new

@@ -529,12 +529,19 @@ 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" + + if [ ! -z "$rvm_json_flag" -o ! -z "$rvm_yaml_flag" -o ! -z "$rvm_summary_flag" ] ; then + mkdir -p ./log/$rvm_ruby_string/ + touch ./log/$rvm_ruby_string/$rvm_action.log ./log/$rvm_ruby_string/$rvm_action.error.log + eval "$rvm_command" >> ./log/$rvm_ruby_string/$rvm_action.log 2>> ./log/$rvm_ruby_string/$rvm_action.error.log + else + echo -e "\n$rvm_ruby_string: $($rvm_ruby_home/bin/$binary -v)" + eval "$rvm_command" + fi result=$? if [ $result -eq 0 ]; then eval "successes=(${successes[*]} $rvm_ruby_string)" else eval "errors=(${errors[*]} $rvm_ruby_string)" @@ -582,36 +589,41 @@ return ${#errors[*]} } function __rvm_summary { export successes errors statuses - 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 "rubies (${#rubies[*]}) : [ $(echo "${rubies[*]}" | sed 's/ /, /g') ]" - echo -e "statuses: [ $(echo "${statuses[*]}" | sed 's/ /, /g') ]\n" + summary="\nSummary:\n" + summary="$summary \033[0;32m${#successes[*]} successful: $(echo "${successes[*]}" | sed 's/ /, /g')\033[0m\n" + summary="$summary \033[0;31m${#errors[*]} errors: $(echo "${errors[*]}" | sed 's/ /, /g')\033[0m\n" + total=${#rubies[*]} + if [ ! -z "$ZSH_VERSION" ] ; then array_start=1 ; else array_start=0 ; fi + for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do + __rvm_log "debug" "${rubies[$index]} returned ${statuses[$index]}" + summary="$summary ${rubies[$index]} returned ${statuses[$index]}" + if (( $index + 1 < $total + $array_start )) ; then summary="$summary\n" ; fi + done ; unset index array_start + echo -e "$summary" | tee -a log/summary.log return ${#errors[*]} } function __rvm_yaml { export successes errors statuses - yaml="\ntotals:\n rubies: ${#rubies[*]}\n successes: ${#successes[*]}\n errors: ${#errors[*]}\n successes:" + yaml="totals:\n rubies: ${#rubies[*]}\n successes: ${#successes[*]}\n errors: ${#errors[*]}\nsuccesses:" for var in ${successes[*]} ; do - yaml="$yaml\n - $var" + yaml="$yaml\n - $var" done - yaml="$yaml\n errors:" + yaml="$yaml\nerrors:" for var in ${errors[*]} ; do - yaml="$yaml\n - $var" + yaml="$yaml\n - $var" done - yaml="$yaml\n rubies:" + yaml="$yaml\nrubies:" total=${#rubies[*]} if [ ! -z "$ZSH_VERSION" ] ; then array_start=1 ; else array_start=0 ; fi for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do - echo "${rubies[$index]}: ${statuses[$index]}" - yaml="$yaml\n \"${rubies[$index]}\": ${statuses[$index]}" + __rvm_log "debug" "${rubies[$index]}: ${statuses[$index]}" + yaml="$yaml\n \"${rubies[$index]}\": ${statuses[$index]}" done ; unset index array_start - mkdir -p log echo -e "$yaml" | tee -a log/summary.yaml return ${#errors[*]} } @@ -624,10 +636,10 @@ json="$json\n \"rubies\": {" total=${#rubies[*]} if [ ! -z "$ZSH_VERSION" ] ; then array_start=1 ; else array_start=0 ; fi for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do - echo "${rubies[$index]}: ${statuses[$index]}" + __rvm_log "debug" "${rubies[$index]}: ${statuses[$index]}" json="$json\n {\"${rubies[$index]}\": ${statuses[$index]}}" if (( $index + 1 < $total + $array_start )) ; then json="$json, " ; fi done ; unset index array_start json="$json\n }\n}"