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

#fail, #log

Constructor Details

#initialize(args, options) ⇒ Deploy

Returns a new instance of Deploy.



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

def initialize(args, options)
  super

  @version_number = args.first

  fail "must specify environment with '-e'" unless options.env
  fail "must specify version number" unless version_number
end

Instance Attribute Details

#version_numberObject (readonly)

Returns the value of attribute version_number.



20
21
22
# File 'lib/phase/cli/deploy.rb', line 20

def version_number
  @version_number
end

Instance Method Details

#runObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/phase/cli/deploy.rb', line 31

def run
  opts = {
    version_tag: version_number
  }

  deployment = case options.env
  when "sandbox"
    ::Phase::Deploy::SandboxDeployment.new(opts)
  when "staging"
    ::Phase::Deploy::StagingDeployment.new(opts)
  when "production"
    ::Phase::Deploy::ProductionDeployment.new(opts)
  else
    fail "unknown environment: '#{environment}'"
  end

  deployment.execute!
end