Class: CapistranoCloudfoundry::Application
- Inherits:
-
Object
- Object
- CapistranoCloudfoundry::Application
- Defined in:
- lib/capistrano-cloudfoundry/application.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(name, url, target) ⇒ Application
constructor
A new instance of Application.
- #push ⇒ Object
Constructor Details
#initialize(name, url, target) ⇒ Application
Returns a new instance of Application.
5 6 7 8 9 |
# File 'lib/capistrano-cloudfoundry/application.rb', line 5 def initialize(name, url, target) @name = name @url = url.match(%r/http[s]?:\/\/([^\/]+)/) ? url.match(%r/http[s]?:\/\/([^\/]+)/)[1] : url @target = target end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/capistrano-cloudfoundry/application.rb', line 4 def name @name end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'lib/capistrano-cloudfoundry/application.rb', line 4 def target @target end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/capistrano-cloudfoundry/application.rb', line 4 def url @url end |
Instance Method Details
#push ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/capistrano-cloudfoundry/application.rb', line 10 def push #deploy the app apps = `vmc apps` case when apps.match(%r/#{@name}-blue *\|[^\|]*\|[^\|]*\| .*#{@url}/) @old_deploy = "blue" @deploy = "green" when apps.match(%r/#{@name}-green *\|[^\|]*\|[^\|]*\| .*#{@url}/) @old_deploy = "green" @deploy = "blue" else @deploy = "blue" end if apps.include?(" #{@name}-#{@deploy} ") then puts `vmc update #{@name}-#{@deploy}` else puts `vmc push #{@name}-#{@deploy} -n` end apps = `vmc apps` if apps.match(%r/#{@name}-#{@deploy}[ ]*\|[^\|]*\| RUNNING/) then @old_deploy ? `vmc unmap #{@name}-#{@old_deploy} #{@url}` : nil `vmc map #{@name}-#{@deploy} #{@url}` end end |