Module: Ferry::TaskEnhancements

Included in:
DSL
Defined in:
lib/ferry/dsl/task_enhancements.rb

Instance Method Summary collapse

Instance Method Details

#after(task, post_task, *args, &block) ⇒ Object



10
11
12
13
14
15
# File 'lib/ferry/dsl/task_enhancements.rb', line 10

def after(task, post_task, *args, &block)
  Rake::Task.define_task(post_task, *args, &block) if block_given?
  Rake::Task[task].enhance do
    Rake::Task[post_task].invoke
  end
end

#before(task, prerequisite, *args, &block) ⇒ Object



5
6
7
8
# File 'lib/ferry/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_tasksObject



50
51
52
# File 'lib/ferry/dsl/task_enhancements.rb', line 50

def default_tasks
  %w{install}
end

#define_remote_file_task(task, target_roles) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ferry/dsl/task_enhancements.rb', line 22

def define_remote_file_task(task, target_roles)
  Ferry::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?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/ferry/dsl/task_enhancements.rb', line 60

def deploying?
  fetch(:deploying, false)
end

#ensure_stageObject



37
38
39
40
41
42
43
44
# File 'lib/ferry/dsl/task_enhancements.rb', line 37

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) ⇒ Object



54
55
56
57
58
# File 'lib/ferry/dsl/task_enhancements.rb', line 54

def exit_deploy_because_of_exception(ex)
  warn t(:deploy_failed, ex: ex.message)
  invoke 'deploy:failed'
  exit(false)
end

#remote_file(task) ⇒ Object



17
18
19
20
# File 'lib/ferry/dsl/task_enhancements.rb', line 17

def remote_file(task)
  target_roles = task.delete(:roles) { :all }
  define_remote_file_task(task, target_roles)
end

#tasks_without_stage_dependencyObject



46
47
48
# File 'lib/ferry/dsl/task_enhancements.rb', line 46

def tasks_without_stage_dependency
  stages + default_tasks
end