-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_rubies
executable file
·66 lines (58 loc) · 1.27 KB
/
all_rubies
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
versions=('3.2.8' '3.3.8' '3.4.2')
switcher=`which asdf`
if [[ $switcher = *[!\ ]* ]]; then
verb="local ruby"
else
switcher=`which rbenv`
if [[ $switcher = *[!\ ]* ]]; then
verb="local"
else
switcher=`which rvm`
if [[ $switcher = *[!\ ]* ]]; then
verb="use"
else
echo "Please install asdf, rbenv, or rvm"
exit 1
fi
fi
fi
bundle_exec() {
local cmd="$1"
local version="$2"
echo "Run $cmd with Ruby $version"
eval "$switcher $verb $version"
if [[ -f "Gemfile.lock.$version" ]]; then
eval "cp Gemfile.lock.$version Gemfile.lock"
else
echo "Please run ./all_rubies bundle first"
fi
bundle exec $cmd
}
case "$1" in
bundle)
rm Gemfile.lock*
for version in ${versions[@]}
do
echo "Bundle for Ruby $version"
eval "$switcher $verb $version"
gem list --local bundler | grep bundler || gem install bundler --no-ri --no-rdoc
gem update bundler
bundle install --path vendor/bundle
eval "cp Gemfile.lock Gemfile.lock.$version"
done
;;
cop)
bundle_exec "rubocop" ${versions[0]}
;;
spec)
for version in ${versions[@]}
do
bundle_exec "rspec spec" $version
done
;;
*)
echo $"Usage: $0 {bundle|spec|cop}"
exit 1
esac
exit 0