Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#gem_listObject

THANKS: dev.animoto.com/articles/capistrano-gem-management

CAP GEMS

Author: Stevie Clifton



18
19
20
# File 'lib/railslove/recipes/helpers.rb', line 18

def gem_list
  fetch(:dependencies, {})[:remote][:gem] rescue {}
end

#generate_logrotate_configurationObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/railslove/recipes/logrotate.rb', line 19

def generate_logrotate_configuration
  config = []    
  fetch(:logrotate_options, []).each do |option|            
    if option.is_a?(Hash)
      option.each do |key, value|
        config << "#{key} #{value}"
      end
    else
      config << option.to_s
    end
  end    
  %Q{
#{logrotate_directory}/*.log {
  #{config.join("\n  ")}
}
  }
end

#render(template, bind = binding) ⇒ Object



10
11
12
# File 'lib/railslove/recipes/helpers.rb', line 10

def render(template,bind=binding)
  ERB.new(open(template).read).result(bind) 
end

#run_rake(task, args = {}) ⇒ Object

run a rake task



2
3
4
5
6
7
8
# File 'lib/railslove/recipes/helpers.rb', line 2

def run_rake(task, args={})
  rails_env = args[:rails_env] || fetch(:rails_env, "production")
  rake_env = args[:rake_env] || fetch(:rake_env, "")
  rake = fetch(:rake, "rake")
  directory = args[:directory] || release_path
  run "sh -c 'cd #{directory}; #{rake} #{task} RAILS_ENV=#{rails_env} #{rake_env}'"
end

#with_gem_dependencies(&block) ⇒ Object

Passes the Deploy::Dependency after running a check, the gem, and version to a block. Deploy::Dependency does not have any internal awareness of which gem it is, which make doing this a PITA. Probably would be wiser to extend Deploy::Dependency to save the gem name and args so that we could query them directly



28
29
30
31
32
33
34
35
# File 'lib/railslove/recipes/helpers.rb', line 28

def with_gem_dependencies &block
  Deploy::Dependencies.new(strategy.configuration) do |d|
    gem_list.each do |gem, version|
      dep = d.remote.gem(gem, version, {})
      yield dep, gem, version
    end
  end
end