Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ Ensure you set an explicit dependency on the `chruby` cookbook if you are using
- `node['chruby']['auto_switch']` - enable automatic switching between Ruby versions per https://github.com/postmodern/chruby#auto-switching
- `node['chruby']['rubies']` - an hash of Rubies / Booleans values to install using the `ruby-build` LWRP, and make available to chruby.
- `node['chruby']['default']` - specify the default Ruby version for every shell.

- `node['chruby']['user_rubies']` - an array of directories containing custom rubies

# Recipes

## Default
Expand All @@ -77,7 +78,7 @@ Builds and makes available the Ruby versions listed in the `node['chruby']['rubi

- Author: Stephen Nelson-Smith (LordCope) - Atalanta Systems Ltd (<[email protected]>)

Copyright 2013, Atalanta Systems Ltd
Copyright 2013, Atalanta Systems Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 3 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
default['chruby']['auto_switch'] = true
default['chruby']['rubies'] = {'1.9.3-p392' => true}
default['chruby']['default'] = 'embedded'
default['chruby']['user_rubies'] = {}
default['chruby']['user_rubies'] = []
default['chruby']['sh_dir'] = "/etc/profile.d"
default['chruby']['sh_name'] = 'chruby.sh'
13 changes: 9 additions & 4 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@

ark "chruby" do
url "https://github.com/postmodern/chruby/archive/v#{node['chruby']['version']}.tar.gz"
version node['chruby']['version']
action :install_with_make
end

# Workaround for Github issue 5 https://github.com/Atalanta/chef-chruby/issues/5

link "/usr/local/chruby" do
to "/usr/local/chruby-1"
end
to "/usr/local/chruby-#{node['chruby']['version']}"
end

sh_owner = node['chruby']['sh_owner']

directory "/etc/profile.d" do
directory node['chruby']['sh_dir'] do
recursive true
owner sh_owner if sh_owner
end

template "/etc/profile.d/chruby.sh" do
template File.join(node['chruby']['sh_dir'], node['chruby']['sh_name']) do
source "chruby.sh.erb"
mode "0644"
owner sh_owner if sh_owner
end
10 changes: 9 additions & 1 deletion templates/default/chruby.sh.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
source /usr/local/chruby/share/chruby/chruby.sh

<% if ::File.exists?("/opt/chefdk/embedded") -%>
RUBIES+=(/opt/chefdk/embedded)
<% end -%>

<% if ::File.exists?("/opt/chef/embedded") -%>
RUBIES+=(/opt/chef/embedded)
<% end -%>
Expand All @@ -12,7 +16,11 @@ RUBIES+=($HOME/.rvm/rubies/*)
RUBIES+=($HOME/.rbenv/rubies/*)
<% end -%>

<% if ::File.exists?("/opt/chef/embedded") and node['chruby']['default'] == "embedded" -%>
<% node['chruby']['user_rubies'].each do |directory| -%>
RUBIES+=(<%= directory.sub(/\/\z/, '') %>/*)
<% end -%>

<% if (::File.exists?("/opt/chef/embedded") or ::File.exists?("/opt/chefdk/embedded")) and node['chruby']['default'] == "embedded" -%>
chruby embedded
<% elsif node['chruby']['default'] -%>
chruby <%= node['chruby']['default'] %>
Expand Down