Sha256: bdd948811dd61aec2a00c5a1492c3fe6e0358e2bb7a6f4a5d23180f522e8436e

Contents?: true

Size: 1.69 KB

Versions: 14

Compression:

Stored size: 1.69 KB

Contents

module Dandelion
  module Command
    class Deploy < Command::Base
      command :deploy

      def self.parser(options)
        OptionParser.new do |opts|
          opts.banner = 'Usage: dandelion deploy [options] [<revision>]'

          options[:dry] = false
          opts.on('--dry-run', 'Show what would have been deployed') do
            options[:dry] = true
          end
        end
      end

      def setup(args)
        config[:revision] = args.shift || nil
      end

      def execute!
        log.info("Connecting to #{adapter.to_s}")

        local_commit = workspace.local_commit
        remote_commit = workspace.remote_commit
        
        log.info("Remote revision:    #{remote_commit ? remote_commit.oid : '---'}")
        log.info("Deploying revision: #{local_commit.oid}")

        deploy_changeset!
        deploy_additional_files!        
      end

      def deployer_adapter
        if options[:dry]
          Adapter::NoOpAdapter.new(config)
        else
          adapter
        end
      end

      def deployer
        @deployer ||= Deployer.new(deployer_adapter, config)
      end

    private

      def deploy_changeset!
        changeset = workspace.changeset

        if changeset.empty?
          log.info("No changes to deploy")
        else
          log.info("Deploying changes...")
          deployer.deploy_changeset!(workspace.changeset)
          workspace.remote_commit = workspace.local_commit unless options[:dry]
        end
      end

      def deploy_additional_files!
        if config[:additional] && config[:additional].length > 0
          log.info("Deploying additional files...")
          deployer.deploy_files!(config[:additional])
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dandelion-0.4.15 lib/dandelion/command/deploy.rb
dandelion-0.4.14 lib/dandelion/command/deploy.rb
dandelion-0.4.10 lib/dandelion/command/deploy.rb
dandelion-0.4.9 lib/dandelion/command/deploy.rb
dandelion-0.4.8 lib/dandelion/command/deploy.rb
dandelion-0.4.7 lib/dandelion/command/deploy.rb
dandelion-0.4.6 lib/dandelion/command/deploy.rb
dandelion-0.4.5 lib/dandelion/command/deploy.rb
dandelion-0.4.4 lib/dandelion/command/deploy.rb
dandelion-0.4.3 lib/dandelion/command/deploy.rb
dandelion-0.4.2 lib/dandelion/command/deploy.rb
dandelion-0.4.1 lib/dandelion/command/deploy.rb
dandelion-0.4.0 lib/dandelion/command/deploy.rb
dandelion-0.4.0.beta2 lib/dandelion/command/deploy.rb