Class: Geordi::CapistranoConfig
- Inherits:
-
Object
- Object
- Geordi::CapistranoConfig
- Defined in:
- lib/geordi/capistrano_config.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #branch ⇒ Object
- #env ⇒ Object
-
#initialize(stage) ⇒ CapistranoConfig
constructor
A new instance of CapistranoConfig.
- #primary_server ⇒ Object
- #remote_root ⇒ Object
- #servers ⇒ Object
- #shell ⇒ Object
- #user(server) ⇒ Object
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
#root ⇒ Object
Returns the value of attribute root.
4 5 6 |
# File 'lib/geordi/capistrano_config.rb', line 4 def root @root end |
Class Method Details
.current_app_revisions(target_stage) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/geordi/capistrano_config.rb', line 54 def self.current_app_revisions(target_stage) return ['a76fdd46e5319a202f7daa3f0fbdadb0c6f44408'] if Util.testing? output = `cap #{target_stage} app:revision` # git revisions are in SHA-1 format => 40-byte hexadecimal string output.scan(/[a-f0-9]{40}/).uniq end |
Instance Method Details
#branch ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/geordi/capistrano_config.rb', line 21 def branch deploy_info[/ # Marker ^\s*set.:branch, # Might be followed by ENV['DEPLOY_BRANCH'] .* # Assume the last word in quotes will be the right branch # (\1 matches the opening quote character) (['"])(\w+)\1\s*$ /x, 2] end |
#env ⇒ Object
46 47 48 |
# File 'lib/geordi/capistrano_config.rb', line 46 def env deploy_info[/^\s*set\s*:rails_env,\s*['"](.*?)['"]/, 1] end |
#primary_server ⇒ Object
35 36 37 38 39 40 |
# File 'lib/geordi/capistrano_config.rb', line 35 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_root ⇒ Object
42 43 44 |
# File 'lib/geordi/capistrano_config.rb', line 42 def remote_root File.join deploy_info[/^\s*set\s*:deploy_to,\s*['"](.*?)['"]/, 1], 'current' end |
#servers ⇒ Object
17 18 19 |
# File 'lib/geordi/capistrano_config.rb', line 17 def servers deploy_info.scan(/^\s*server\s*['"](.*?)['"]/).flatten end |
#shell ⇒ Object
50 51 52 |
# File 'lib/geordi/capistrano_config.rb', line 50 def shell 'bash --login' end |