From 0eac132b83fe4ea44517fe9f051412cbd1552c8d Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@brief.schottelius.org>
Date: Fri, 2 Nov 2012 21:46:08 +0100
Subject: [PATCH] adjust gemset explorer to work with new rvm version (fixes
 #108)

See https://github.com/wayneeseguin/rvm/issues/1285

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
---
 cdist/conf/type/__rvm_gemset/explorer/state | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/cdist/conf/type/__rvm_gemset/explorer/state b/cdist/conf/type/__rvm_gemset/explorer/state
index c8d573b5..fa643a6e 100755
--- a/cdist/conf/type/__rvm_gemset/explorer/state
+++ b/cdist/conf/type/__rvm_gemset/explorer/state
@@ -22,14 +22,14 @@ gemset="$__object_id"
 ruby="$(echo "$gemset" | cut -d '@' -f 1)"
 gemsetname="$(echo "$gemset" | cut -d '@' -f2)"
 user="$(cat "$__object/parameter/user")"
-if su - "$user" -c "[ ! -d ~/.rvm ]" ; then
+
+if [ ! -e "~$user/.rvm/scripts/rvm" ] ; then
    echo "absent"
    exit 0
 fi
-if su - "$user" -c "source ~/.rvm/scripts/rvm
-rvm list | grep -q $ruby"; then
-   if su - "$user" -c "source ~/.rvm/scripts/rvm
-rvm use $ruby > /dev/null; rvm gemset list | grep -q $gemsetname"; then
+
+if su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm list strings | grep -q "^$ruby\$"'; then
+    if su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm use "$ruby" > /dev/null; rvm gemset list strings | cut -f 1 -d " " | grep -q "^$gemsetname\$"'; then
       echo "present"
       exit 0
   fi