Module: Capistrano::Novelys::Helpers

Defined in:
lib/capistrano/novelys/helpers.rb

Class Method Summary collapse

Class Method Details

.run_remote_rake(cap, rake_cmd) ⇒ Object

Run rake on the server. To be used in tasks.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/capistrano/novelys/helpers.rb', line 6

def run_remote_rake(cap, rake_cmd)
  rake_args = ENV['RAKE_ARGS'].to_s.split(',')
  release = cap.fetch(:latest_release)
  rake = cap.fetch(:rake, 'rake')
  env = cap.fetch(:rails_env, 'production')

  cmd = "cd #{release} && #{rake} RAILS_ENV=#{env} #{rake_cmd}"
  cmd += "['#{rake_args.join("','")}']" unless rake_args.empty?

  cap.run cmd

  cap.set :rakefile, nil if cap.exists?(:rakefile)
end