Skip to content

Commit

Permalink
Introduce rbenv cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
hiremaga committed Sep 14, 2013
0 parents commit b6d6cd1
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sprout-osx-ruby
===============
Recipes to install ruby related tools on OS X Mountain Lion.
9 changes: 9 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node.default['sprout']['rbenv'] = {
'home' => "#{node['sprout']['home']}/.rbenv",
'command' => '/usr/local/bin/rbenv',
'rubies' => {
'1.9.3-p448' => {},
'2.0.0-p247' => {},
},
'default_ruby' => '1.9.3-p448',
}
22 changes: 22 additions & 0 deletions definitions/ruby_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
define :ruby_install do
ruby_version = params[:version] || params[:name]
options = params[:options] || {}

include_recipe "sprout-osx-rbenv"

rbenv_cmd = node['sprout']['rbenv']['command']
install_cmd = "#{rbenv_cmd} install #{ruby_version} #{options[:command_line_options]}"

execute "installing #{ruby_version} with RBENV: #{install_cmd}" do
command install_cmd
user params[:user] || node['current_user']
only_if params[:only_if] if params[:only_if]
not_if params[:not_if] || "#{rbenv_cmd} versions | grep #{ruby_version}"
env params[:options][:env]
end

execute "check #{ruby_version}" do
command "#{rbenv_cmd} versions | grep #{ruby_version}"
user params[:user] || node['current_user']
end
end
9 changes: 9 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name 'sprout-osx-rbenv'
maintainer 'Pivotal Labs'
maintainer_email 'accounts@pivotallabs.com'
license 'MIT'
description 'Installs/Configures sprout-osx-rbenv'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
supports 'mac_os_x'
depends 'sprout-osx-base'
19 changes: 19 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rubies = node['sprout']['rbenv']['rubies']
default_ruby = node['sprout']['rbenv']['default_ruby']

brew 'rbenv'
brew 'ruby-build'

sprout_osx_base_bash_it_enable_feature 'plugins/rbenv'

rubies.each do |version, options|
ruby_install version do
options options
end
end

execute "making #{default_ruby} with rbenv the default" do
command "rbenv global #{default_ruby}"
user node['current_user']
not_if { default_ruby.nil? }
end

0 comments on commit b6d6cd1

Please sign in to comment.