Sha256: 9fc7c04ae564f94fd94b3843713f1650366f5ed70725af606f4fc8788628d6e8

Contents?: true

Size: 1.05 KB

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
caravan-0.3.1 lib/caravan/deploy.rb