-
Notifications
You must be signed in to change notification settings - Fork 1
/
ruby.sh
72 lines (57 loc) · 1.9 KB
/
ruby.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
source './homebrew.sh'
function clone_or_pull_repo {
local plugin_dir="$1"; shift 1;
local plugin_repo="$1"; shift 1;
if [ -d $plugin_dir/.git ]; then
current_dir="$PWD"
cd $plugin_dir
git pull
cd "$current_dir"
else
git clone $plugin_repo $plugin_dir
fi
}
function install_rbenv_plugin {
mkdir -p $RBENV_ROOT/plugins 2> /dev/null
local user="$1"; shift 1;
local plugin_name="$1"; shift 1;
local plugin_repo="https://github.com/$user/$plugin_name"
local plugin_dir="$RBENV_ROOT/plugins/$plugin_name"
clone_or_pull_repo $plugin_dir $plugin_repo
}
function install_or_upgrade_gem {
local gem_name="$1"; shift 1;
if [ -z "`$RBENV_ROOT/shims/gem list | /usr/bin/grep -e \"^$gem_name\s\"`" ]; then
$RBENV_ROOT/shims/gem install --no-ri --no-rdoc $gem_name
else
$RBENV_ROOT/shims/gem update --no-ri --no-rdoc $gem_name
fi
gem cleanup $gem_name
}
function install_ruby {
export RBENV_ROOT=/usr/local/var/rbenv
clone_or_pull_repo "$RBENV_ROOT" "https://github.com/sstephenson/rbenv.git"
ln -sf $RBENV_ROOT/bin/rbenv /usr/local/bin/
install_rbenv_plugin "sstephenson" "ruby-build"
install_rbenv_plugin "tpope" "rbenv-readline"
install_rbenv_plugin "tpope" "rbenv-aliases"
if ! [ -d "/usr/local/var/rbenv/versions/2.1.4" ]; then
$RBENV_ROOT/bin/rbenv install 2.1.4
$RBENV_ROOT/bin/rbenv global 2.1.4
fi
install_or_upgrade_gem awesome_print
install_or_upgrade_gem bundler
install_or_upgrade_gem gem-browse
install_or_upgrade_gem hash_syntax
install_or_upgrade_gem heroku
install_or_upgrade_gem overcommit
install_or_upgrade_gem pygmentize
install_or_upgrade_gem pygments.rb
install_or_upgrade_gem redcarpet
install_or_upgrade_gem rubocop
install_or_upgrade_gem rubygems-update
install_or_upgrade_gem scss-lint
install_or_upgrade_gem travis
install_or_upgrade_gem travis-lint
$RBENV_ROOT/bin/rbenv alias --auto
}