Created
June 1, 2010 13:43
-
-
Save nragaz/420952 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rails_gems | |
gemrc = { | |
:verbose => true, | |
:gem => '--no-ri --no-rdoc', | |
:update_sources => true, | |
:sources => [ | |
'http://rubygems.org' | |
] | |
} | |
gemrc.merge!(configuration[:rubygems]) if configuration[:rubygems] | |
file '/etc/gemrc', | |
:ensure => :present, | |
:mode => '744', | |
:owner => 'root', | |
:group => 'root', | |
:content => gemrc.to_yaml | |
# stub for puppet dependencies | |
exec 'rails_gems', :command => 'true' | |
gemfile_path = rails_root.join('Gemfile') | |
gemfile_lock_path = rails_root.join('Gemfile.lock') | |
if gemfile_path.exist? | |
# Bundler is initially installed by deploy:setup in the ruby:install_moonshine_deps task | |
configure(:bundler => {}) | |
package 'bundler', | |
:ensure => (configuration[:bundler][:version] || :latest), | |
:provider => :gem, | |
:before => exec("bundle install") | |
exec 'bundle install', | |
:command => "bundle install | tee #{rails_root.join("..", "..", "shared", "log", "bundle.log")}", | |
:cwd => rails_root, | |
:before => [exec('rails_gems'), exec('bundle lock')], | |
:require => file('/etc/gemrc'), | |
:user => configuration[:user] | |
exec 'bundle lock', | |
:command => 'bundle lock', | |
:cwd => rails_root, | |
:creates => gemfile_lock_path.to_s, | |
:user => configuration[:user] | |
else | |
return unless configuration[:gems] | |
configuration[:gems].each do |gem| | |
gem.delete(:source) if gem[:source] && gemrc[:sources].include?(gem[:source]) | |
gem(gem[:name], { | |
:version => gem[:version], | |
:source => gem[:source] | |
}) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment