main
1#!/usr/bin/env bash
2
3# This is an RVM Project .rvmrc file, used to automatically load the ruby
4# development environment upon cd'ing into the directory
5
6# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7environment_id="ruby-2.0.0@domain.cs"
8
9#
10# Uncomment the following lines if you want to verify rvm version per project
11#
12# rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
13# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15# return 1
16# }
17#
18
19#
20# Uncomment following line if you want options to be set only for given project.
21#
22# PROJECT_JRUBY_OPTS=( --1.9 )
23#
24# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
25#
26# chmod +x ${rvm_path}/hooks/after_use_jruby_opts
27#
28
29#
30# First we attempt to load the desired environment directly from the environment
31# file. This is very fast and efficient compared to running through the entire
32# CLI and selector. If you want feedback on which environment was used then
33# insert the word 'use' after --create as this triggers verbose mode.
34#
35if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
36 && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
37then
38 \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
39
40 if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
41 then
42 . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
43 fi
44else
45 # If the environment file has not yet been created, use the RVM CLI to select.
46 if ! rvm --create "$environment_id"
47 then
48 echo "Failed to create RVM environment '${environment_id}'."
49 return 1
50 fi
51fi
52
53#
54# If you use an RVM gemset file to install a list of gems (*.gems), you can have
55# it be automatically loaded. Uncomment the following and adjust the filename if
56# necessary.
57#
58# filename=".gems"
59# if [[ -s "$filename" ]]
60# then
61# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
62# fi
63
64# If you use bundler, this might be useful to you:
65# if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
66# then
67# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
68# gem install bundler
69# fi
70# if [[ -s Gemfile ]] && command -v bundle
71# then
72# bundle install
73# fi
74
75if [[ $- == *i* ]] # check for interactive shells
76then
77 echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
78else
79 echo "Using: $GEM_HOME" # don't use colors in interactive shells
80fi
81