#! /bin/sh

# install stable rvm
\curl -sSL https://get.rvm.io | bash -s stable --ruby
source ~/.rvm/scripts/rvm

# install ruby
rvm install ruby-2.2.0
gem install bundler

# install imagemagick
brew install imagemagick@6
echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
unset HOMEBREW_BUILD_FROM_SOURCE

# install mysql
brew install mysql
gem install mysql2

bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib —with-cppflags=-I/usr/local/opt/openssl/include"

# set package config path
# installing rmagick will look for dependencies
export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.*/lib/pkgconfig

# install rmagick
gem install rmagick
brew link --force imagemagick@6
bundle install
