env = YAML::load( `gem environment` )["RubyGems Environment"].detect { |x| x["EXECUTABLE DIRECTORY"] }
template "/etc/init.d/unicorn" do
  source "unicorn-init.sh.erb"
  owner "root"
  group "root"
  mode "755"
  variables( :gem_home => env["EXECUTABLE DIRECTORY"])
end

gem_package "unicorn" do
  path = node[:rvm][:gem_binary]
  gem_binary path if path
  action :upgrade
end

service "unicorn" do
  supports :start => true, :stop => true, :restart => true, :reload => true
  action :enable
end

directory "/etc/unicorn" do
  owner "root"
  group "root"
  mode "755"
  action :create
end

template "/etc/unicorn/app.rb" do
  source "unicorn.rb.erb"
  owner "root"
  group "root"
  mode "644"
  variables( :cow_friendly => node[:unicorn][:cow_friendly])
  #notifies :restart, resources(:service => "unicorn")
end
require 'rubygems'
template "/etc/init.d/unicorn" do
  source "unicorn-init.sh.erb"
  owner "root"
  group "root"
  mode "755"
  variables( :gem_home => Gem.bindir )
end

gem_package "unicorn" do
  path = node[:rvm][:gem_binary]
  gem_binary path if path
  action :upgrade
end

service "unicorn" do
  supports :start => true, :stop => true, :restart => true, :reload => true
  action :enable
end

directory "/etc/unicorn" do
  owner "root"
  group "root"
  mode "755"
  action :create
end

template "/etc/unicorn/app.rb" do
  source "unicorn.rb.erb"
  owner "root"
  group "root"
  mode "644"
  variables( :cow_friendly => node[:unicorn][:cow_friendly])
  #notifies :restart, resources(:service => "unicorn")
end
Use RubyGems class methods to get bindir instead of exec'ing out to the shell
Use RubyGems class methods to get bindir instead of exec'ing out to the shell
