diff --git a/doc/man/ruby-install.1.md b/doc/man/ruby-install.1.md index f8e0a7be..618c89d0 100644 --- a/doc/man/ruby-install.1.md +++ b/doc/man/ruby-install.1.md @@ -182,6 +182,14 @@ Uninstall a Ruby version: *~/.rubies/$ruby-$version* Default non-root user installation directory. +## ENVIRONMENT + +*RUBY_INSTALL_SRC_DIR* + Overrides the default source directory. + +*RUBY_INSTALL_RUBIES_DIR* + Overrides the default installation directory. + ## AUTHOR Postmodern diff --git a/share/man/man1/ruby-install.1 b/share/man/man1/ruby-install.1 index d76bf1c0..323077dd 100644 --- a/share/man/man1/ruby-install.1 +++ b/share/man/man1/ruby-install.1 @@ -1,4 +1,4 @@ -.\" Generated by kramdown-man 0.1.7 +.\" Generated by kramdown-man 0.1.8 .\" https://github.com/postmodern/kramdown-man#readme .TH ruby-install 1 "Aug 2018" ruby-install "User Manuals" .LP @@ -265,6 +265,16 @@ Default root user installation directory\. \fI\[ti]\[sl]\.rubies\[sl]\[Do]ruby\-\[Do]version\fP Default non\-root user installation directory\. .LP +.SH ENVIRONMENT +.LP +.TP +\fIRUBY\[ru]INSTALL\[ru]SRC\[ru]DIR\fP +Overrides the default source directory\. +.LP +.TP +\fIRUBY\[ru]INSTALL\[ru]RUBIES\[ru]DIR\fP +Overrides the default installation directory\. +.LP .SH AUTHOR .LP .PP diff --git a/share/ruby-install/ruby-install.sh b/share/ruby-install/ruby-install.sh index cc4df76b..dfbf32c6 100644 --- a/share/ruby-install/ruby-install.sh +++ b/share/ruby-install/ruby-install.sh @@ -14,11 +14,11 @@ make_opts=() system_dir="/usr/local" if (( UID == 0 )); then - src_dir="$system_dir/src" - rubies_dir="/opt/rubies" + src_dir="${RUBY_INSTALL_SRC_DIR:-$system_dir/src}" + rubies_dir="${RUBY_INSTALL_RUBIES_DIR:-/opt/rubies}" else - src_dir="$HOME/src" - rubies_dir="$HOME/.rubies" + src_dir="${RUBY_INSTALL_SRC_DIR:-$HOME/src}" + rubies_dir="${RUBY_INSTALL_RUBIES_DIR:-$HOME/.rubies}" fi source "$ruby_install_dir/logging.sh" diff --git a/test/ruby-install-tests/variables_test.sh b/test/ruby-install-tests/variables_test.sh index 6b49ecd9..c28e9018 100755 --- a/test/ruby-install-tests/variables_test.sh +++ b/test/ruby-install-tests/variables_test.sh @@ -73,4 +73,26 @@ function test_rubies_dir() fi } +function test_src_dir_with_RUBY_INSTALL_SRC_DIR() +{ + export RUBY_INSTALL_SRC_DIR="/path/to/src/dir" + . ./share/ruby-install/ruby-install.sh + + assertEquals "did not set \$src_dir to \$RUBY_INSTALL_SRC_DIR" \ + "$RUBY_INSTALL_SRC_DIR" "$src_dir" + + unset RUBY_INSTALL_SRC_DIR +} + +function test_rubies_dir_with_RUBY_INSTALL_SRC_DIR() +{ + export RUBY_INSTALL_RUBIES_DIR="/path/to/rubies/dir" + . ./share/ruby-install/ruby-install.sh + + assertEquals "did not set \$rubies_dir to \$RUBY_INSTALL_RUBIES_DIR" \ + "$RUBY_INSTALL_RUBIES_DIR" "$rubies_dir" + + unset RUBY_INSTALL_RUBIES_DIR +} + SHUNIT_PARENT=$0 . $SHUNIT2