Permalink
Browse files

Update rvm_environment_identifier to respect system and the current s…

…tate of ruby
  • Loading branch information...
1 parent 57f90b9 commit 996646a79e344824a481e24f20b6fdac538a90a3 @Sutto Sutto committed May 30, 2010
Showing with 45 additions and 12 deletions.
  1. +1 −0 README
  2. +1 −1 scripts/cli
  3. +26 −9 scripts/docs
  4. +9 −0 scripts/manage
  5. +8 −2 scripts/utility
View
1 README
@@ -15,6 +15,7 @@ Flags
--jit - Used with rubinius install to build with JIT
--latest - with gemset --dump skips version strings for latest gem.
--gems - with uninstall/remove removes gems with the interpreter.
+ --docs - with install, attempt to generate ri after installation.
--reconfigure - Force ./configure on install even if Makefile already exists.
View
2 scripts/cli
@@ -326,7 +326,7 @@ __rvm_parse_args() {
reboot|damnit|wtf|argh|BOOM|boom|wth) $rvm_action="reboot" ;;
- --self|--gem|--rubygems|--reconfigure|--default|--debug|--force|--export|--summary|--latest|--yaml|--json|--archive|--shebang|--env|--path|--tail|--delete|--verbose|--import|--rvmrc|--sticky|--create|--rvmrc|--gems)
+ --self|--gem|--rubygems|--reconfigure|--default|--debug|--force|--export|--summary|--latest|--yaml|--json|--archive|--shebang|--env|--path|--tail|--delete|--verbose|--import|--rvmrc|--sticky|--create|--rvmrc|--gems|--docs)
export rvm_$(echo $rvm_token | sed 's#-##g')_flag=1
if [[ "--debug" = "$rvm_token" ]] ; then rvm_debug_flag ; fi
;;
View
35 scripts/docs
@@ -5,6 +5,7 @@ if [[ ! -z "$rvm_trace_flag" ]] ; then set -x ; export rvm_trace_flag ; fi
trap "if [[ -d $rvm_tmp_path/ ]] && [[ -f $rvm_tmp_path/$$ ]] ; then rm -f $rvm_tmp_path/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15
source $rvm_scripts_path/initialize
+source $rvm_scripts_path/utility
rvm_ruby_string="$(basename $GEM_HOME 2>/dev/null | awk -F'@' '{print $1}')"
if [[ -z "$rvm_ruby_string" ]] && echo $GEM_HOME | grep -v 'rvm/' > /dev/null 2>&1 ; then
@@ -31,26 +32,42 @@ open_docs() {
fi
}
-generate_docs() {
- builtin cd "$rvm_src_path/$rvm_ruby_string/"
- rm -rf $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type/
- $rvm_scripts_path/log "info" "Generating documentation, be aware that this could take a *long* time, and depends heavily on your system resources..."
+generate_ri() {
+ # Generate ri docs
+ __rvm_pushpop "$rvm_src_path/$rvm_ruby_string/"
+ $rvm_scripts_path/log "info" "Generating ri documentation, be aware that this could take a *long* time, and depends heavily on your system resources..."
+ $rvm_scripts_path/log "info" "( Errors will be logged to $rvm_log_path/$rvm_ruby_string/docs.error.log )"
+ rdoc -a --ri --ri-site > /dev/null 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log
+ __rvm_pushpop
+}
+
+generate_rdoc() {
+ __rvm_pushpop "$rvm_src_path/$rvm_ruby_string/"
+ rm -rf "$rvm_docs_path/$rvm_ruby_string/$rvm_docs_type/"
+ $rvm_scripts_path/log "info" "Generating rdoc documentation, be aware that this could take a *long* time, and depends heavily on your system resources..."
$rvm_scripts_path/log "info" "( Errors will be logged to $rvm_log_path/$rvm_ruby_string/docs.error.log )"
if gem list | grep ^hanna >/dev/null 2>&1 ; then
- hanna -o $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type --inline-source --line-numbers --fmt=html 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log
+ hanna -o $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type --inline-source --line-numbers --fmt=html > /dev/null 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log
else
- rdoc -a -o $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log
+ rdoc -a -o $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type > /dev/null 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log
fi
- rdoc -a --ri-site 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log
+ __rvm_pushpop
}
if [[ "open" = "$action" ]] ; then
open_docs
elif [[ "generate" = "$action" ]] ; then
- generate_docs
+ generate_rdoc
+ generate_ri
+elif [[ "generate-ri" = "$action" ]]; then
+ generate_ri
+elif [[ "generate-rdoc" = "$action" ]]; then
+ generate_rdoc
else
- $rvm_scripts_path/log "error" ""
+ $rvm_scripts_path/log "error" "No action provided."
exit 1
fi
+printf "\n"
+
exit $result
View
9 scripts/manage
@@ -911,6 +911,15 @@ __rvm_post_install() {
__rvm_irbrc
__rvm_load_gemsets
+
+ __rvm_generate_default_docs
+}
+
+__rvm_generate_default_docs() {
+ if [[ "$rvm_docs_flag" = "1" && "$rvm_ruby_interpreter" != "macruby" ]]; then
+ $rvm_scripts_path/log "info" "Attempting to generate ri docs..."
+ $rvm_scripts_path/docs "generate-ri"
+ fi
}
__rvm_load_gemsets() {
View
10 scripts/utility
@@ -115,7 +115,7 @@ __rvm_cleanup_variables() {
if [[ "$rvm_sticky_flag" = "1" ]] ; then export rvm_gemset_name ; else unset rvm_gemset_name ; fi
- unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_url 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_ruby_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_ruby_patch rvm_sticky_flagrvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag
+ unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_url 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_ruby_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_ruby_patch rvm_sticky_flagrvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag
}
# Unset ruby-specific variables
@@ -549,7 +549,13 @@ __rvm_mono_env() {
}
__rvm_environment_identifier() {
- echo "$GEM_HOME" | xargs basename
+ ruby_string="$(command -v ruby)"
+ if [ -n "$ruby_string" ] && echo "$ruby_string" | grep -q -F "$rvm_rubies_path"; then
+ echo "$GEM_HOME" | xargs basename
+ else
+ echo "system"
+ fi
+ unset ruby_string
}
__rvm_ensure_has_enviroment_files() {

0 comments on commit 996646a

Please sign in to comment.