Skip to content

Instantly share code, notes, and snippets.

@benevolent0505
Last active July 2, 2016 04:35
Show Gist options
  • Save benevolent0505/31d775a89f3a61708bea to your computer and use it in GitHub Desktop.
Save benevolent0505/31d775a89f3a61708bea to your computer and use it in GitHub Desktop.
# coding: utf-8-hfs
# install-ruby.rb
execute "sudo apt-get update"
package "git-core" do
action :install
end
%w(
autoconf
bison
build-essential
libssl-dev
libyaml-dev
libreadline6-dev
zlib1g-dev
libncurses5-dev
libffi-dev
libgdbm3
libgdbm-dev
).each do |pkg|
package pkg do
action :install
end
end
execute 'install rbenv' do
command "git clone https://github.com/sstephenson/rbenv.git ~/.rbenv"
not_if "test -d ~/.rbenv"
end
# execute 'create rbenv path' do
# command %Q(echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc)
# not_if "cat ~/.bashrc | grep '$HOME/.rbenv/bin:$PATH'"
# end
# execute 'init rbenv' do
# command %q(echo 'eval "$(rbenv init -)"' >> ~/.bashrc)
# not_if "cat ~/.bashrc | grep 'rbenv init'"
# end
# execute 'restart shell' do
# command "exec ${SHELL} -l"
# end
# fish版を考える必要あり
# execute 'create rbenv path' do
# command %Q(echo 'set PATH $PATH $HOME/.rbenv/bin' >> ~/.config/fish/config.fish)
# not_if "cat ~/.config/fish/config.fish | grep 'set PATH $PATH $HOME/.rbenv/bin'"
# end
# execute 'init rbenv' do
# command %q(echo 'eval "$(rbenv init -)"' >> ~/.config/fish/config.fish)
# not_if "cat ~/.config/fish/config.fish | grep 'rbenv init'"
# end
execute 'install ruby-build' do
command "git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build"
not_if 'test -d ~/.rbenv/plugins/ruby-build'
end
execute 'update rbenv' do
command "cd ~/.rbenv; git pull"
only_if 'test -d ~/.rbenv'
end
execute 'update ruby-build' do
command "cd ~/.rbenv/plugins/ruby-build; git pull"
only_if 'test -d ~/.rbenv/plugins/ruby-build'
end
execute 'install ruby 2.2.2' do
command 'rbenv install 2.2.2'
not_if 'ruby -v | grep 2.2.2'
end
execute 'set global ruby 2.2.2' do
command 'rbenv rehash; rbenv global 2.2.2'
end
execute 'update rubygems' do
command 'gem update --system'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment