Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ruby-build
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ruby-build
Commits
aa1976b2
Commit
aa1976b2
authored
Nov 26, 2014
by
Mislav Marohnić
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'extra-arguments'
Fixes #667, closes #668
parents
63f6fa2e
34246f9f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
27 deletions
+97
-27
bin/rbenv-install
+4
-3
bin/rbenv-uninstall
+13
-5
bin/ruby-build
+18
-19
test/arguments.bats
+23
-0
test/rbenv.bats
+39
-0
No files found.
bin/rbenv-install
View file @
aa1976b2
...
@@ -96,11 +96,13 @@ for option in "${OPTIONS[@]}"; do
...
@@ -96,11 +96,13 @@ for option in "${OPTIONS[@]}"; do
exec
ruby-build
--version
exec
ruby-build
--version
;;
;;
*
)
*
)
usage 1
usage 1
>
&2
;;
;;
esac
esac
done
done
[
"
${#
ARGUMENTS
[@]
}
"
-le
1
]
||
usage 1
>
&2
unset
VERSION_NAME
unset
VERSION_NAME
# The first argument contains the definition to install. If the
# The first argument contains the definition to install. If the
...
@@ -109,8 +111,7 @@ unset VERSION_NAME
...
@@ -109,8 +111,7 @@ unset VERSION_NAME
# version is not specified.
# version is not specified.
DEFINITION
=
"
${
ARGUMENTS
[0]
}
"
DEFINITION
=
"
${
ARGUMENTS
[0]
}
"
[
-n
"
$DEFINITION
"
]
||
DEFINITION
=
"
$(
rbenv-local 2>/dev/null
||
true
)
"
[
-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
# Define `before_install` and `after_install` functions that allow
# plugin hooks to register a string of code for execution before or
# plugin hooks to register a string of code for execution before or
...
...
bin/rbenv-uninstall
View file @
aa1976b2
...
@@ -17,24 +17,32 @@ if [ "$1" = "--complete" ]; then
...
@@ -17,24 +17,32 @@ if [ "$1" = "--complete" ]; then
exec
rbenv versions
--bare
exec
rbenv versions
--bare
fi
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
if
[
-z
"
$RBENV_ROOT
"
]
;
then
RBENV_ROOT
=
"
${
HOME
}
/.rbenv"
RBENV_ROOT
=
"
${
HOME
}
/.rbenv"
fi
fi
if
[
"
$1
"
=
"-h"
]
||
[
"
$1
"
=
"--help"
]
;
then
usage 0
fi
unset
FORCE
unset
FORCE
if
[
"
$1
"
=
"-f"
]
||
[
"
$1
"
=
"--force"
]
;
then
if
[
"
$1
"
=
"-f"
]
||
[
"
$1
"
=
"--force"
]
;
then
FORCE
=
true
FORCE
=
true
shift
shift
fi
fi
[
"$#"
-eq
1
]
||
usage 1
>
&2
DEFINITION
=
"
$1
"
DEFINITION
=
"
$1
"
case
"
$DEFINITION
"
in
case
"
$DEFINITION
"
in
""
|
-
*
)
""
|
-
*
)
# We can remove the sed fallback once rbenv 0.4.0 is widely available.
usage 1
>
&2
{
rbenv-help uninstall 2>/dev/null
||
sed
-ne
'/^#/!q;s/.\{1,2\}//;1,4d;p'
<
"
$0
"
}
>
&2
exit
1
;;
;;
esac
esac
...
...
bin/ruby-build
View file @
aa1976b2
#!/usr/bin/env bash
#!/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"
RUBY_BUILD_VERSION
=
"20141113"
...
@@ -954,14 +963,8 @@ version() {
...
@@ -954,14 +963,8 @@ version() {
}
}
usage
()
{
usage
()
{
{
version
sed
-ne
'/^#/!q;s/.\{1,2\}//;1,2d;p'
<
"
$0
"
echo
"usage: ruby-build [-k|--keep] [-v|--verbose] [-p|--patch] definition prefix"
[
-z
"
$1
"
]
||
exit
"
$1
"
echo
" ruby-build --definitions"
}
>
&2
if
[
-z
"
$1
"
]
;
then
exit
1
fi
}
}
list_definitions
()
{
list_definitions
()
{
...
@@ -992,15 +995,9 @@ parse_options "$@"
...
@@ -992,15 +995,9 @@ parse_options "$@"
for
option
in
"
${
OPTIONS
[@]
}
"
;
do
for
option
in
"
${
OPTIONS
[@]
}
"
;
do
case
"
$option
"
in
case
"
$option
"
in
"h"
|
"help"
)
"h"
|
"help"
)
usage without_exiting
version
{
echo
echo
echo
" -k/--keep Do not remove source tree after installation"
usage 0
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"
echo
}
>
&2
exit
0
;;
;;
"definitions"
)
"definitions"
)
list_definitions
list_definitions
...
@@ -1022,9 +1019,11 @@ for option in "${OPTIONS[@]}"; do
...
@@ -1022,9 +1019,11 @@ for option in "${OPTIONS[@]}"; do
esac
esac
done
done
[
"
${#
ARGUMENTS
[@]
}
"
-eq
2
]
||
usage 1
>
&2
DEFINITION_PATH
=
"
${
ARGUMENTS
[0]
}
"
DEFINITION_PATH
=
"
${
ARGUMENTS
[0]
}
"
if
[
-z
"
$DEFINITION_PATH
"
]
;
then
if
[
-z
"
$DEFINITION_PATH
"
]
;
then
usage
usage
1
>
&2
elif
[
!
-f
"
$DEFINITION_PATH
"
]
;
then
elif
[
!
-f
"
$DEFINITION_PATH
"
]
;
then
for
DEFINITION_DIR
in
"
${
RUBY_BUILD_DEFINITIONS
[@]
}
"
;
do
for
DEFINITION_DIR
in
"
${
RUBY_BUILD_DEFINITIONS
[@]
}
"
;
do
if
[
-f
"
${
DEFINITION_DIR
}
/
${
DEFINITION_PATH
}
"
]
;
then
if
[
-f
"
${
DEFINITION_DIR
}
/
${
DEFINITION_PATH
}
"
]
;
then
...
@@ -1041,7 +1040,7 @@ fi
...
@@ -1041,7 +1040,7 @@ fi
PREFIX_PATH
=
"
${
ARGUMENTS
[1]
}
"
PREFIX_PATH
=
"
${
ARGUMENTS
[1]
}
"
if
[
-z
"
$PREFIX_PATH
"
]
;
then
if
[
-z
"
$PREFIX_PATH
"
]
;
then
usage
usage
1
>
&2
elif
[
"
${
PREFIX_PATH
#/
}
"
=
"
$PREFIX_PATH
"
]
;
then
elif
[
"
${
PREFIX_PATH
#/
}
"
=
"
$PREFIX_PATH
"
]
;
then
PREFIX_PATH
=
"
${
PWD
}
/
${
PREFIX_PATH
}
"
PREFIX_PATH
=
"
${
PWD
}
/
${
PREFIX_PATH
}
"
fi
fi
...
...
test/arguments.bats
0 → 100644
View file @
aa1976b2
#!/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
View file @
aa1976b2
...
@@ -146,3 +146,42 @@ ${RBENV_ROOT}/plugins/bar/share/ruby-build
...
@@ -146,3 +146,42 @@ ${RBENV_ROOT}/plugins/bar/share/ruby-build
${RBENV_ROOT}/plugins/foo/share/ruby-build
${RBENV_ROOT}/plugins/foo/share/ruby-build
OUT
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'
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment