forked from NUBIC/surveyor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch.sh
executable file
·53 lines (48 loc) · 1.41 KB
/
switch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
echo ""
# Set the prompt for the select command
PS3="Choose a surveyor stack or 'q' to quit: "
export SPEC_OPTS="--format Fuubar --color spec"
export BUNDLER_VERSION=1.6.1
options=""
rubies=(2.0.0 2.1.1)
rails_versions=(3.2.17 4.0.0)
for i in "${rubies[@]}"
do
for j in "${rails_versions[@]}"
do
options+="$i@$j "
done
done
# Show a menu and ask for input.
select combo in $options; do
case $combo in
*)
arr=(${combo//@/ })
export RUBY_VERSION=${arr[0]}
export RAILS_VERSION=${arr[1]}
echo "$RUBY_VERSION" > .ruby-version
echo "surveyor-rails_$RAILS_VERSION" > .ruby-gemset
source ~/.rvm/scripts/rvm
rvm use $RUBY_VERSION@surveyor-rails_$RAILS_VERSION --create
read -p "Press [Enter] to remove and regenerate testbed for $RUBY_VERSION@surveyor-rails_$RAILS_VERSION..."
gem list -i bundler -v $BUNDLER_VERSION
if [ $? -ne 0 ]; then
gem install bundler -v $BUNDLER_VERSION
fi
bundle _${BUNDLER_VERSION}_ update
bundle _${BUNDLER_VERSION}_ exec rake testbed
echo 'if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".ruby-gemset" ]; then
rvm use `cat .ruby-version`@`cat .ruby-gemset`
else
rvm use `cat .ruby-version`
fi
fi' > testbed/.powrc
echo "$RUBY_VERSION" > testbed/.ruby-version
echo "surveyor-rails_$RAILS_VERSION" > testbed/.ruby-gemset
;;
esac
break
done