convert __rvm_gmeset to boolean parameter

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-11-15 17:47:06 +01:00
parent f834352e88
commit e6bf226036
3 changed files with 8 additions and 11 deletions

View file

@ -24,7 +24,6 @@ ruby="$(echo "$gemset" | cut -d '@' -f 1)"
gemsetname="$(echo "$gemset" | cut -d '@' -f 2)" gemsetname="$(echo "$gemset" | cut -d '@' -f 2)"
state_is="$(cat "$__object/explorer/state")" state_is="$(cat "$__object/explorer/state")"
user="$(cat "$__object/parameter/user")" user="$(cat "$__object/parameter/user")"
default="$(cat "$__object/parameter/default" 2>/dev/null || true)"
state_should="$(cat "$__object/parameter/state")" state_should="$(cat "$__object/parameter/state")"
[ "$state_is" = "$state_should" ] && exit 0 [ "$state_is" = "$state_should" ] && exit 0
@ -34,15 +33,12 @@ case "$state_should" in
cat << DONE cat << DONE
su - "$user" -c "source ~/.rvm/scripts/rvm; rvm $gemset --create" su - "$user" -c "source ~/.rvm/scripts/rvm; rvm $gemset --create"
DONE DONE
case "$default" in if -f "$__object/parameter/default"; then
no)
;;
*)
cat << DONE cat << DONE
su - "$user" -c "source ~/.rvm/scripts/rvm; rvm use --default $gemset" su - "$user" -c "source ~/.rvm/scripts/rvm; rvm use --default $gemset"
DONE DONE
;; fi
esac
;; ;;
absent) absent)
cat << DONE cat << DONE

View file

@ -20,10 +20,11 @@ user::
state:: state::
Either "present" or "absent". Either "present" or "absent".
OPTIONAL PARAMETERS BOOLEAN PARAMETERS
------------------- -------------------
default:: default::
If set to anything but "no" (the default), set the given gemset as default. If present, set the given gemset as default.
EXAMPLES EXAMPLES
-------- --------
@ -33,7 +34,7 @@ EXAMPLES
__rvm_gemset ruby-1.9.3-p0@myset --user charles --state present __rvm_gemset ruby-1.9.3-p0@myset --user charles --state present
# Do the same and make ruby-1.9.3-p0@myset the default gemset # Do the same and make ruby-1.9.3-p0@myset the default gemset
__rvm_gemset ruby-1.9.3-p0@myset --user charles --state present --default yes __rvm_gemset ruby-1.9.3-p0@myset --user charles --state present --default
# Remove the gemset @myset for user john # Remove the gemset @myset for user john
__rvm_ruby ruby-1.9.3-p0@myset --user john --state absent __rvm_ruby ruby-1.9.3-p0@myset --user john --state absent