Shell Scripting for rvm ruby listing

Continuing to find nice ways to use quick shell scripts as part of ruby test automation:

Wrote this today (Sunday) in prep for using it at work next week.

function make_sure_rvm_rubies_installed() {

rvm list > $TMP/local_ruby_versions.txt
local_ruby_versions=(1.8.7 1.9.3)

for version in “${local_ruby_versions[@]}”
do
cat $TMP/local_ruby_versions.txt | grep -q $version
version_search_result=$?
if [ $version_search_result = 0 ]
then
echo “Required RVM Ruby version $version confirmed as present on this machine”
else
echo “*** EXITING SMOKE TEST *** – not all required ruby versions are present in RVM”
echo “Please install RVM ruby version: $version and then re-run this program”
exit
fi
done
if [ $? = 0 ]
then
echo “All required Ruby Versions confirmed as present locally”
rm -f $TMP/local_ruby_versions.txt
fi
}

make_sure_rvm_rubies_installed

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s