Class: Geordi::CapistranoConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/geordi/capistrano_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stage) ⇒ CapistranoConfig

Returns a new instance of CapistranoConfig.



6
7
8
9
10
# File 'lib/geordi/capistrano_config.rb', line 6

def initialize(stage)
  self.stage = stage
  self.root = find_project_root!
  load_deploy_info
end

Instance Attribute Details

#rootObject

Returns the value of attribute root.



4
5
6
# File 'lib/geordi/capistrano_config.rb', line 4

def root
  @root
end

Instance Method Details

#envObject



32
33
34
# File 'lib/geordi/capistrano_config.rb', line 32

def env
  deploy_info[/^\s*set\s*:rails_env,\s*['"](.*?)['"]/, 1]
end

#primary_serverObject



21
22
23
24
25
26
# File 'lib/geordi/capistrano_config.rb', line 21

def primary_server
  # Actually, servers may have a :primary property. From Capistrano 3, the
  # first listed server is the primary one by default, which is a good-
  # enough default for us.
  servers.first
end

#remote_rootObject



28
29
30
# File 'lib/geordi/capistrano_config.rb', line 28

def remote_root
  File.join deploy_info[/^\s*set\s*:deploy_to,\s*['"](.*?)['"]/, 1], 'current'
end

#serversObject



17
18
19
# File 'lib/geordi/capistrano_config.rb', line 17

def servers
  deploy_info.scan(/^\s*server\s*['"](.*?)['"]/).flatten
end

#shellObject



36
37
38
# File 'lib/geordi/capistrano_config.rb', line 36

def shell
  'bash --login'
end

#user(server) ⇒ Object



12
13
14
15
# File 'lib/geordi/capistrano_config.rb', line 12

def user(server)
  cap2user = deploy_info[/^\s*set\s*:user,\s*['"](.*?)['"]/, 1]
  cap2user || deploy_info[/^\s*server\s*['"]#{server}['"],.*user.{1,4}['"](.*?)['"]/, 1]
end