#!/usr/bin/env bash

function rake_not_found()
{
  printf "$(tput setaf 1)ERRRO: Gem rake is not installed, run \`gem install rake\` first.$(tput sgr0)\n"
  exit 127
}

# in rvm warn about missing gem
if [[ -n "${GEM_HOME:-}" ]]
then
  rake_not_found
else
  current_rake="$(which $0)"
  PATH=":${PATH}:"
  PATH="${PATH//:${current_rake}:/:}"
  PATH="${PATH#:}"
  PATH="${PATH%:}"
  if which rake >/dev/null 2>&1
  then
    rake "$@"
  else
    rake_not_found
  fi
fi
