Loading bin/rbenv-install +4 −3 Original line number Diff line number Diff line Loading @@ -96,11 +96,13 @@ for option in "${OPTIONS[@]}"; do exec ruby-build --version ;; * ) usage 1 usage 1 >&2 ;; esac done [ "${#ARGUMENTS[@]}" -le 1 ] || usage 1 >&2 unset VERSION_NAME # The first argument contains the definition to install. If the Loading @@ -109,8 +111,7 @@ unset VERSION_NAME # version is not specified. DEFINITION="${ARGUMENTS[0]}" [ -n "$DEFINITION" ] || DEFINITION="$(rbenv-local 2>/dev/null || true)" [ -n "$DEFINITION" ] || usage 1 [ -n "$DEFINITION" ] || usage 1 >&2 # Define `before_install` and `after_install` functions that allow # plugin hooks to register a string of code for execution before or Loading bin/rbenv-uninstall +13 −5 Original line number Diff line number Diff line Loading @@ -17,24 +17,32 @@ if [ "$1" = "--complete" ]; then exec rbenv versions --bare fi usage() { # We can remove the sed fallback once rbenv 0.4.0 is widely available. rbenv-help uninstall 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0" [ -z "$1" ] || exit "$1" } if [ -z "$RBENV_ROOT" ]; then RBENV_ROOT="${HOME}/.rbenv" fi if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then usage 0 fi unset FORCE if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then FORCE=true shift fi [ "$#" -eq 1 ] || usage 1 >&2 DEFINITION="$1" case "$DEFINITION" in "" | -* ) # We can remove the sed fallback once rbenv 0.4.0 is widely available. { rbenv-help uninstall 2>/dev/null || sed -ne '/^#/!q;s/.\{1,2\}//;1,4d;p' < "$0" } >&2 exit 1 usage 1 >&2 ;; esac Loading bin/ruby-build +18 −19 Original line number Diff line number Diff line #!/usr/bin/env bash # # Usage: ruby-build [-kvp] <definition> <prefix> # ruby-build --definitions # # -k/--keep Do not remove source tree after installation # -v/--verbose Verbose mode: print compilation status to stdout # -p/--patch Apply a patch from stdin before building # --definitions List all built-in definitions # RUBY_BUILD_VERSION="20141113" Loading Loading @@ -954,14 +963,8 @@ version() { } usage() { { version echo "usage: ruby-build [-k|--keep] [-v|--verbose] [-p|--patch] definition prefix" echo " ruby-build --definitions" } >&2 if [ -z "$1" ]; then exit 1 fi sed -ne '/^#/!q;s/.\{1,2\}//;1,2d;p' < "$0" [ -z "$1" ] || exit "$1" } list_definitions() { Loading Loading @@ -992,15 +995,9 @@ parse_options "$@" for option in "${OPTIONS[@]}"; do case "$option" in "h" | "help" ) usage without_exiting { echo echo " -k/--keep Do not remove source tree after installation" echo " -v/--verbose Verbose mode: print compilation status to stdout" echo " -p/--patch Apply a patch from stdin before building" echo " --definitions List all built-in definitions" version echo } >&2 exit 0 usage 0 ;; "definitions" ) list_definitions Loading @@ -1022,9 +1019,11 @@ for option in "${OPTIONS[@]}"; do esac done [ "${#ARGUMENTS[@]}" -eq 2 ] || usage 1 >&2 DEFINITION_PATH="${ARGUMENTS[0]}" if [ -z "$DEFINITION_PATH" ]; then usage usage 1 >&2 elif [ ! -f "$DEFINITION_PATH" ]; then for DEFINITION_DIR in "${RUBY_BUILD_DEFINITIONS[@]}"; do if [ -f "${DEFINITION_DIR}/${DEFINITION_PATH}" ]; then Loading @@ -1041,7 +1040,7 @@ fi PREFIX_PATH="${ARGUMENTS[1]}" if [ -z "$PREFIX_PATH" ]; then usage usage 1 >&2 elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then PREFIX_PATH="${PWD}/${PREFIX_PATH}" fi Loading test/arguments.bats 0 → 100644 +23 −0 Original line number Diff line number Diff line #!/usr/bin/env bats load test_helper @test "not enought arguments for ruby-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" run ruby-build "$definition" assert_failure assert_output_contains 'Usage: ruby-build' } @test "extra arguments for ruby-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" run ruby-build "$definition" "${TMP}/install" "" assert_failure assert_output_contains 'Usage: ruby-build' } test/rbenv.bats +39 −0 Original line number Diff line number Diff line Loading @@ -146,3 +146,42 @@ ${RBENV_ROOT}/plugins/bar/share/ruby-build ${RBENV_ROOT}/plugins/foo/share/ruby-build OUT } @test "not enough arguments for rbenv-install" { stub_ruby_build run rbenv-install assert_failure assert_output_contains 'Usage: rbenv install' } @test "too many arguments for rbenv-install" { stub_ruby_build run rbenv-install 2.1.1 2.1.2 assert_failure assert_output_contains 'Usage: rbenv install' } @test "show help for rbenv-install" { stub_ruby_build run rbenv-install -h assert_success assert_output_contains 'Usage: rbenv install' } @test "not enough arguments rbenv-uninstall" { run rbenv-uninstall assert_failure assert_output_contains 'Usage: rbenv uninstall' } @test "too many arguments for rbenv-uninstall" { run rbenv-uninstall 2.1.1 2.1.2 assert_failure assert_output_contains 'Usage: rbenv uninstall' } @test "show help for rbenv-uninstall" { run rbenv-uninstall -h assert_success assert_output_contains 'Usage: rbenv uninstall' } Loading
bin/rbenv-install +4 −3 Original line number Diff line number Diff line Loading @@ -96,11 +96,13 @@ for option in "${OPTIONS[@]}"; do exec ruby-build --version ;; * ) usage 1 usage 1 >&2 ;; esac done [ "${#ARGUMENTS[@]}" -le 1 ] || usage 1 >&2 unset VERSION_NAME # The first argument contains the definition to install. If the Loading @@ -109,8 +111,7 @@ unset VERSION_NAME # version is not specified. DEFINITION="${ARGUMENTS[0]}" [ -n "$DEFINITION" ] || DEFINITION="$(rbenv-local 2>/dev/null || true)" [ -n "$DEFINITION" ] || usage 1 [ -n "$DEFINITION" ] || usage 1 >&2 # Define `before_install` and `after_install` functions that allow # plugin hooks to register a string of code for execution before or Loading
bin/rbenv-uninstall +13 −5 Original line number Diff line number Diff line Loading @@ -17,24 +17,32 @@ if [ "$1" = "--complete" ]; then exec rbenv versions --bare fi usage() { # We can remove the sed fallback once rbenv 0.4.0 is widely available. rbenv-help uninstall 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0" [ -z "$1" ] || exit "$1" } if [ -z "$RBENV_ROOT" ]; then RBENV_ROOT="${HOME}/.rbenv" fi if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then usage 0 fi unset FORCE if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then FORCE=true shift fi [ "$#" -eq 1 ] || usage 1 >&2 DEFINITION="$1" case "$DEFINITION" in "" | -* ) # We can remove the sed fallback once rbenv 0.4.0 is widely available. { rbenv-help uninstall 2>/dev/null || sed -ne '/^#/!q;s/.\{1,2\}//;1,4d;p' < "$0" } >&2 exit 1 usage 1 >&2 ;; esac Loading
bin/ruby-build +18 −19 Original line number Diff line number Diff line #!/usr/bin/env bash # # Usage: ruby-build [-kvp] <definition> <prefix> # ruby-build --definitions # # -k/--keep Do not remove source tree after installation # -v/--verbose Verbose mode: print compilation status to stdout # -p/--patch Apply a patch from stdin before building # --definitions List all built-in definitions # RUBY_BUILD_VERSION="20141113" Loading Loading @@ -954,14 +963,8 @@ version() { } usage() { { version echo "usage: ruby-build [-k|--keep] [-v|--verbose] [-p|--patch] definition prefix" echo " ruby-build --definitions" } >&2 if [ -z "$1" ]; then exit 1 fi sed -ne '/^#/!q;s/.\{1,2\}//;1,2d;p' < "$0" [ -z "$1" ] || exit "$1" } list_definitions() { Loading Loading @@ -992,15 +995,9 @@ parse_options "$@" for option in "${OPTIONS[@]}"; do case "$option" in "h" | "help" ) usage without_exiting { echo echo " -k/--keep Do not remove source tree after installation" echo " -v/--verbose Verbose mode: print compilation status to stdout" echo " -p/--patch Apply a patch from stdin before building" echo " --definitions List all built-in definitions" version echo } >&2 exit 0 usage 0 ;; "definitions" ) list_definitions Loading @@ -1022,9 +1019,11 @@ for option in "${OPTIONS[@]}"; do esac done [ "${#ARGUMENTS[@]}" -eq 2 ] || usage 1 >&2 DEFINITION_PATH="${ARGUMENTS[0]}" if [ -z "$DEFINITION_PATH" ]; then usage usage 1 >&2 elif [ ! -f "$DEFINITION_PATH" ]; then for DEFINITION_DIR in "${RUBY_BUILD_DEFINITIONS[@]}"; do if [ -f "${DEFINITION_DIR}/${DEFINITION_PATH}" ]; then Loading @@ -1041,7 +1040,7 @@ fi PREFIX_PATH="${ARGUMENTS[1]}" if [ -z "$PREFIX_PATH" ]; then usage usage 1 >&2 elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then PREFIX_PATH="${PWD}/${PREFIX_PATH}" fi Loading
test/arguments.bats 0 → 100644 +23 −0 Original line number Diff line number Diff line #!/usr/bin/env bats load test_helper @test "not enought arguments for ruby-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" run ruby-build "$definition" assert_failure assert_output_contains 'Usage: ruby-build' } @test "extra arguments for ruby-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" run ruby-build "$definition" "${TMP}/install" "" assert_failure assert_output_contains 'Usage: ruby-build' }
test/rbenv.bats +39 −0 Original line number Diff line number Diff line Loading @@ -146,3 +146,42 @@ ${RBENV_ROOT}/plugins/bar/share/ruby-build ${RBENV_ROOT}/plugins/foo/share/ruby-build OUT } @test "not enough arguments for rbenv-install" { stub_ruby_build run rbenv-install assert_failure assert_output_contains 'Usage: rbenv install' } @test "too many arguments for rbenv-install" { stub_ruby_build run rbenv-install 2.1.1 2.1.2 assert_failure assert_output_contains 'Usage: rbenv install' } @test "show help for rbenv-install" { stub_ruby_build run rbenv-install -h assert_success assert_output_contains 'Usage: rbenv install' } @test "not enough arguments rbenv-uninstall" { run rbenv-uninstall assert_failure assert_output_contains 'Usage: rbenv uninstall' } @test "too many arguments for rbenv-uninstall" { run rbenv-uninstall 2.1.1 2.1.2 assert_failure assert_output_contains 'Usage: rbenv uninstall' } @test "show help for rbenv-uninstall" { run rbenv-uninstall -h assert_success assert_output_contains 'Usage: rbenv uninstall' }