Class: GTA::Deploy

Inherits:
Object
  • Object
show all
Includes:
Sh
Defined in:
lib/gta/deploy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sh

#commander, #sh, #sh!

Constructor Details

#initialize(stage_name, gta_config_path = nil) ⇒ Deploy

Returns a new instance of Deploy.



7
8
9
10
# File 'lib/gta/deploy.rb', line 7

def initialize(stage_name, gta_config_path=nil)
  @stage_name = stage_name
  @gta_config_path = gta_config_path
end

Instance Attribute Details

#gta_config_pathObject (readonly)

Returns the value of attribute gta_config_path.



5
6
7
# File 'lib/gta/deploy.rb', line 5

def gta_config_path
  @gta_config_path
end

#stage_nameObject (readonly)

Returns the value of attribute stage_name.



5
6
7
# File 'lib/gta/deploy.rb', line 5

def stage_name
  @stage_name
end

Instance Method Details

#deploy(forced = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gta/deploy.rb', line 24

def deploy(forced=nil)
  destination.fetch!
  source.fetch!

  source.checkout! # so the tracking branch exists
  sh("git checkout master") # in case the latest deploy code is not on that branch

  forced == :force ? destination.force_push : destination.push

  sh('git checkout master')
end

#destinationObject



16
17
18
# File 'lib/gta/deploy.rb', line 16

def destination
  @destination ||= manager.stage!(stage_name)
end

#managerObject



12
13
14
# File 'lib/gta/deploy.rb', line 12

def manager
  @manager ||= Manager.new(gta_config_path)
end

#sourceObject



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

def source
  @source ||= destination.source
end