Class: EY::Task

Inherits:
Object show all
Includes:
Dataflow
Defined in:
lib/ey-deploy/task.rb

Direct Known Subclasses

DeployBase, DeployHook

Constant Summary

Constants included from Dataflow

Dataflow::UnificationError, Dataflow::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dataflow

#barrier, #by_need, #flow, included, #local, #need_later, #unify

Constructor Details

#initialize(conf) ⇒ Task

Returns a new instance of Task.



8
9
10
11
# File 'lib/ey-deploy/task.rb', line 8

def initialize(conf)
  @config = conf
  @roles = :all
end

Instance Attribute Details

#configObject (readonly) Also known as: c

Returns the value of attribute config.



5
6
7
# File 'lib/ey-deploy/task.rb', line 5

def config
  @config
end

Instance Method Details

#require_custom_tasksObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ey-deploy/task.rb', line 13

def require_custom_tasks
  deploy_file = ["config/eydeploy.rb", "eydeploy.rb"].map do |short_file|
    File.join(c.repository_cache, short_file)
  end.detect do |file|
    File.exist?(file)
  end

  if deploy_file
    puts "~> Loading deployment task overrides from #{deploy_file}"
    instance_eval(File.read(deploy_file))
    true
  else
    false
  end
end

#roles(*task_roles) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/ey-deploy/task.rb', line 29

def roles(*task_roles)
  raise "Roles must be passed a block" unless block_given?

  begin
    @roles = task_roles
    yield
  ensure
    @roles = :all
  end
end

#run(cmd, &blk) ⇒ Object



40
41
42
# File 'lib/ey-deploy/task.rb', line 40

def run(cmd, &blk)
  run_on_roles(cmd, &blk)
end

#sudo(cmd, &blk) ⇒ Object



44
45
46
# File 'lib/ey-deploy/task.rb', line 44

def sudo(cmd, &blk)
  run_on_roles(cmd, %w[sudo sh -l -c], &blk)
end