Sha256: 04423cfdaf86f164179dcd231d03d2bc59f5235d136556bca64873a5fda910a5

Contents?: true

Size: 1021 Bytes

Versions: 1

Compression:

Stored size: 1021 Bytes

Contents

require 'deep_thought/deployer/deployer'

module DeepThought
  module Deployer
    class Capistrano2 < DeepThought::Deployer::Deployer
      def execute?(deploy, config)
        environment = deploy.environment || "development"

        cap_command = "cap #{environment} deploy"

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

        cap_command += " -s branch=#{deploy.branch}"
        cap_command += " -s box=#{deploy.box}" if deploy.box

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

        commands = []

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

        command = commands.join(" && ")

        log = `#{command}`

        deploy.log = log

        $?.success?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deep_thought-capistrano_2-0.1.0 lib/deep_thought-capistrano_2/deployer/capistrano2.rb