module Capistrano::TaskEnhancements

Public Instance Methods

after(task, post_task, *args, &block) click to toggle source
# File lib/capistrano/dsl/task_enhancements.rb, line 10
def after(task, post_task, *args, &block)
  Rake::Task.define_task(post_task, *args, &block) if block_given?
  task = Rake::Task[task]
  task.enhance do
    post = Rake.application.lookup(post_task, task.scope)
    raise ArgumentError, "Task #{post_task.inspect} not found" unless post
    post.invoke
  end
end
before(task, prerequisite, *args, &block) click to toggle source
# File lib/capistrano/dsl/task_enhancements.rb, line 5
def before(task, prerequisite, *args, &block)
  prerequisite = Rake::Task.define_task(prerequisite, *args, &block) if block_given?
  Rake::Task[task].enhance [prerequisite]
end
default_tasks() click to toggle source
# File lib/capistrano/dsl/task_enhancements.rb, line 47
def default_tasks
  %w{install}
end
define_remote_file_task(task, target_roles) click to toggle source
# File lib/capistrano/dsl/task_enhancements.rb, line 20
def define_remote_file_task(task, target_roles)
  Capistrano::UploadTask.define_task(task) do |t|
    prerequisite_file = t.prerequisites.first
    file = shared_path.join(t.name)

    on roles(target_roles) do
      unless test "[ -f #{file.to_s.shellescape} ]"
        info "Uploading #{prerequisite_file} to #{file}"
        upload! File.open(prerequisite_file), file
      end
    end
  end
end
deploying?() click to toggle source
# File lib/capistrano/dsl/task_enhancements.rb, line 57
def deploying?
  fetch(:deploying, false)
end
ensure_stage() click to toggle source
# File lib/capistrano/dsl/task_enhancements.rb, line 34
def ensure_stage
  Rake::Task.define_task(:ensure_stage) do
    unless stage_set?
      puts t(:stage_not_set)
      exit 1
    end
  end
end
exit_deploy_because_of_exception(ex) click to toggle source
# File lib/capistrano/dsl/task_enhancements.rb, line 51
def exit_deploy_because_of_exception(ex)
  warn t(:deploy_failed, ex: ex.message)
  invoke "deploy:failed"
  exit(false)
end
tasks_without_stage_dependency() click to toggle source
# File lib/capistrano/dsl/task_enhancements.rb, line 43
def tasks_without_stage_dependency
  stages + default_tasks
end