Class: Phase::CLI::Deploy

Inherits:
Command
  • Object
show all
Defined in:
lib/phase/cli/deploy.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#args, #options

Instance Method Summary collapse

Methods included from Util::Console

#ask, #fail, #log

Constructor Details

#initialize(args, options) ⇒ Deploy

Returns a new instance of Deploy.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/phase/cli/deploy.rb', line 20

def initialize(args, options)
  super

  fail "must specify both environment and version number" unless args.count >= 2

  @env_name       = args[0]
  @version_number = args[1]

  fail "must specify environment"    unless env_name
  fail "must specify version number" unless version_number
end

Instance Attribute Details

#env_nameObject (readonly)

Returns the value of attribute env_name.



18
19
20
# File 'lib/phase/cli/deploy.rb', line 18

def env_name
  @env_name
end

#version_numberObject (readonly)

Returns the value of attribute version_number.



18
19
20
# File 'lib/phase/cli/deploy.rb', line 18

def version_number
  @version_number
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
# File 'lib/phase/cli/deploy.rb', line 32

def run
  environment = config.deploy.environments.find { |e| e.name == env_name }
  fail "unknown environment: '#{env_name}'" unless environment

  deployment = Deploy::Deployment.new(environment, version_tag: version_number)
  deployment.execute!
end