Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

Commit

Permalink
Added rvmrc
Browse files Browse the repository at this point in the history
  • Loading branch information
gsong committed Mar 18, 2012
1 parent 9cd9240 commit 8065c3d
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .rvmrc
@@ -0,0 +1,90 @@
#!/usr/bin/env bash

# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory

# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
environment_id="ruby-1.9.3-p125@jekyll"

#
# Uncomment the following lines if you want to verify rvm version per project
#
# rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
# return 1
# }
#

#
# Uncomment following line if you want options to be set only for given project.
#
# PROJECT_JRUBY_OPTS=( --1.9 )
#
# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
#
# chmod +x ${rvm_path}/hooks/after_use_jruby_opts
#

#
# First we attempt to load the desired environment directly from the environment
# file. This is very fast and efficient compared to running through the entire
# CLI and selector. If you want feedback on which environment was used then
# insert the word 'use' after --create as this triggers verbose mode.
#
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"

if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
then
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
if ! rvm --create "$environment_id"
then
echo "Failed to create RVM environment '${environment_id}'."
return 1
fi
fi

#
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
# it be automatically loaded. Uncomment the following and adjust the filename if
# necessary.
#
# filename=".gems"
# if [[ -s "$filename" ]]
# then
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
# fi

# If you use bundler, this might be useful to you:
if [[ "${TERM}" =~ "color" ]]; then
txtgrn=$(tput setaf 2)
txtylw=$(tput setaf 3)
txtrst=$(tput sgr0)
else
txtgrn=""
txtylw=""
txtrst=""
fi

export PATH=$PWD/bin:$PATH
echo "${txtgrn}✓ Using `rvm-prompt`.${txtrst}"

# Recommend rubygems 1.8.11
if ! [[ `gem -v` =~ 1.8.1[1-9] ]] ; then
echo "${txtylw}! Consider upgrading your rubygems installation by running \`gem update --system 1.8.11\`.${txtrst}"
fi

# Require bundler 1.1.rc.7
gem install bundler --version ">= 1.1.rc.7" --conservative --no-ri --no-rdoc

# Run "bundle install" only if necessary
if ! [[ `bundle check` =~ "dependencies are satisfied" ]] ; then
echo "${txtylw}… Your gemset is out of date; wait a minute while gems are installed.${txtrst}"
bundle install | grep -v '^Using' | grep -v '^Fetching source index' | grep -v 'is complete' | sed '/^$/d' && echo "${txtgrn}✓ Done.${txtrst}"
fi

0 comments on commit 8065c3d

Please sign in to comment.