-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_rubies
executable file
·70 lines (62 loc) · 1.4 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
67
68
69
70
#!/bin/bash
versions=('2.6.9' '2.7.5' '3.0.3' '3.1.0')
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)
for version in ${versions[@]}
do
echo "Bundle for Ruby $version"
eval "$switcher $verb $version"
rm Gemfile.lock
if [[ -f "Gemfile.lock.$version" ]]; then
eval "cp Gemfile.lock.$version Gemfile.lock"
fi
gem list --local bundler | grep bundler || gem install bundler --no-ri --no-rdoc
gem update bundler
bundle install --path vendor/bundle
bundle update
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