script/bootstrap
#!/bin/bash
# script/bootstrap: Resolve all dependencies that the application requires to
# run.
set -e
cd "$(dirname "$0")/.."
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
}
fi
echo "==> Checking ruby version..."
current_ruby=`grep '^ruby' Gemfile | tr -cd '[[:digit:]].'`
if [[ $(ruby -v) =~ $current_ruby ]]; then
true
else
cat <<"RUBY"
You need to install ruby ${current_ruby}
I'd strongly suggest to use 'chruby' or 'rbenv' to manage rubies and make your
development easier. I have a personal favor for 'chruby' so I'll explain that
one.
1. Install 'chruby' as described here: https://github.com/postmodern/chruby
2. Install 'ruby-install' https://github.com/postmodern/ruby-install#readme
3. ruby-install ruby ${current_ruby}
4. In a new shell navigat to this folder and do 'chruby 2.5.1'
5. 'ruby -v' should now output ruby-${current_ruby}
'rbenv' https://github.com/rbenv/rbenv has its own ruby installer etc, but chruby
does less and does it better.
Anyhoe, use the right ruby.
RUBY
exit 1
fi
# Install bundler if needed
which bundle >/dev/null 2>&1 || {
gem install bundler
}
# Install foreman if needed
which foreman >/dev/null 2>&1 || {
gem install foreman
}
if [ -f "Gemfile" ]; then
echo "==> Installing gem dependencies…"
bundle check >/dev/null 2>&1 || {
bundle install --quiet --without production
}
fi
bundle exec ruby -e 'require "hesabu"; File.file?(Hesabu::HESABUCLI) ? exit(0) : exit(1)' >/dev/null 2>&1 || {
cat <<HESABU
You don't seem to have a binary for the hesabu gem.
https://github.com/BLSQ/hesabu
The easiest way to fix this is to download a release for your platform at:
https://github.com/BLSQ/go-hesabu/releases
And install it at $(bundle exec ruby -e 'require "hesabu"; puts Hesabu::HESABUCLI')
HESABU
}