Permalink
Browse files

Add recipe to use rbenv

  • Loading branch information...
1 parent aeabb6c commit 5854e4bdfc9939abc2b11a582b9c1e371f572bdd @nixterrimus committed Oct 27, 2011
Showing with 55 additions and 0 deletions.
  1. +8 −0 attributes/rbenv.rb
  2. +23 −0 libraries/rbenv_ruby_install.rb
  3. +22 −0 recipes/rbenv.rb
  4. +2 −0 templates/default/bash_profile-rbenv.sh.erb
View
@@ -0,0 +1,8 @@
+node.default["rbenv"]= {
+ "rubies" => {
+ "ree-1.8.7-2011.03" => "",
+ "1.8.7-p352" => "",
+ "1.9.2-p290" => ""
+ },
+ "default_ruby" => "ree-1.8.7-2011.03"
+ }
@@ -0,0 +1,23 @@
+class Chef::Recipe
+ def rbenv_ruby_install(ruby_version, env_override)
+ include_recipe "pivotal_workstation::rbenv"
+
+ #don't use the marker file system for this. we guess that people are likely to be installing rubies by hand using rbenv.
+ #...that guess might be wrong.
+ unless File.exists?("#{::RBENV_HOME}/#{ruby_version}/bin/ruby")
+
+ install_cmd = "#{env_override} #{RBENV_COMMAND} install #{ruby_version}"
+
+ execute "installing #{ruby_version} with RBENV: #{install_cmd}" do
+ command install_cmd
+ user WS_USER
+ end
+
+ execute "check #{ruby_version}" do
+ command "#{RBENV_COMMAND} versions | grep #{ruby_version}"
+ user WS_USER
+ end
+
+ end
+ end
+end
View
@@ -0,0 +1,22 @@
+include_recipe "pivotal_workstation::bash_profile"
+include_recipe "pivotal_workstation::git"
+
+::RBENV_HOME = "#{WS_HOME}/.rbenv"
+::RBENV_COMMAND = "/usr/local/bin/rbenv"
+
+
+brew_install("rbenv")
+brew_install("ruby-build")
+
+bash_profile_include("rbenv")
+
+node["rbenv"]["rubies"].each do |ruby_version_string, env_override|
+ rbenv_ruby_install(ruby_version_string,env_override)
+end
+
+if node["rbenv"]["default_ruby"]
+ execute "making #{node["rbenv"]["default_ruby"]} with rbenv the default" do
+ command "rbenv global #{node["rbenv"]["default_ruby"]}"
+ user WS_USER
+ end
+end
@@ -0,0 +1,2 @@
+eval "$(rbenv init -)"
+export PATH=$PATH:~/.rbenv/shims

0 comments on commit 5854e4b

Please sign in to comment.