Sha256: 36b601ca0dcc8c1aedd70f5615fd3c2bf80cf0347f2e8531c10dd6bdd3ddd918

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require "colorize"

module Caravan
  module Deploy
    class << self
      def create_deployer(method = "shell")
        case method
        when "shell"
          return Caravan::DeployMethods::Shell.new
        when "scp"
          return Caravan::DeployMethods::Scp.new
        when "rsync"
          return Caravan::DeployMethods::Rsync.new
        when "rsync_local"
          return Caravan::DeployMethods::RsyncLocal.new
        else
          Message.error("Unknown deploy method \"#{method}\"")
          return nil
        end
      end
    end

    class Base
      attr_accessor :debug

      def initialize
        Message.info("Creating #{self.class.name}...")
        @debug = false
      end

      def run(src, dst)
        time_str = Time.now.strftime("%H:%M:%S").green
        Message.info("#{time_str} Deploying #{src} to #{dst}...")

        status = 0
        if block_given?
          status, output = yield src, dst
        end

        Message.error("deploying block returned false") unless status == 0
        return status
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caravan-0.4.0 lib/caravan/deploy.rb
caravan-0.4.0.beta lib/caravan/deploy.rb