Class: Dandelion::Command::Deploy

Inherits:
Base
  • Object
show all
Defined in:
lib/dandelion/command/deploy.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #options, #workspace

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#adapter, command, commands, #initialize, #log, lookup

Constructor Details

This class inherits a constructor from Dandelion::Command::Base

Class Method Details

.parser(options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/dandelion/command/deploy.rb', line 6

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

Instance Method Details

#deployerObject



42
43
44
# File 'lib/dandelion/command/deploy.rb', line 42

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

#deployer_adapterObject



34
35
36
37
38
39
40
# File 'lib/dandelion/command/deploy.rb', line 34

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

#execute!Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dandelion/command/deploy.rb', line 21

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

#setup(args) ⇒ Object



17
18
19
# File 'lib/dandelion/command/deploy.rb', line 17

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