Class: DeepThought::Deployer::Shell

Inherits:
Deployer
  • Object
show all
Defined in:
lib/deep_thought/deployer/shell.rb

Instance Method Summary collapse

Methods inherited from Deployer

#initialize, #setup?

Constructor Details

This class inherits a constructor from DeepThought::Deployer::Deployer

Instance Method Details

#execute?(deploy, config) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/deep_thought/deployer/shell.rb', line 6

def execute?(deploy, config)
  environment = deploy.environment || "development"

  root = config['root'] || "script/deploy"

  command = "#{root} #{environment} deploy"

  if deploy.actions
    actions = YAML.load(deploy.actions)
    actions.each do |action|
      command += ":#{action}"
    end
  end

  command += " branch=#{deploy.branch}"
  command += " box=#{deploy.box}" if deploy.box

  if deploy.variables
    variables = YAML.load(deploy.variables)
    variables.each do |k, v|
      command += " #{k}=#{v}"
    end
  end

  commands = []

  commands << "cd ./.projects/#{deploy.project.name}"
  commands << "#{command} 2>&1"

  executable = commands.join(" && ")

  log = `#{executable}`

  deploy.log = log

  $?.success?
end