Class: Paratrooper::HerokuWrapper
- Inherits:
-
Object
- Object
- Paratrooper::HerokuWrapper
- Defined in:
- lib/paratrooper/heroku_wrapper.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#heroku_api ⇒ Object
readonly
Returns the value of attribute heroku_api.
-
#key_extractor ⇒ Object
readonly
Returns the value of attribute key_extractor.
-
#rendezvous ⇒ Object
readonly
Returns the value of attribute rendezvous.
Instance Method Summary collapse
- #app_maintenance_off ⇒ Object
- #app_maintenance_on ⇒ Object
- #app_restart ⇒ Object
- #app_url ⇒ Object
-
#initialize(app_name, options = {}) ⇒ HerokuWrapper
constructor
A new instance of HerokuWrapper.
- #last_deploy_commit ⇒ Object
- #run_migrations ⇒ Object
- #run_task(task_name) ⇒ Object
Constructor Details
#initialize(app_name, options = {}) ⇒ HerokuWrapper
Returns a new instance of HerokuWrapper.
9 10 11 12 13 14 15 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 9 def initialize(app_name, = {}) @app_name = app_name @key_extractor = [:key_extractor] || LocalApiKeyExtractor @api_key = [:api_key] || key_extractor.get_credentials @heroku_api = [:heroku_api] || Heroku::API.new(api_key: api_key) @rendezvous = [:rendezvous] || Rendezvous end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 7 def api_key @api_key end |
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
7 8 9 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 7 def app_name @app_name end |
#heroku_api ⇒ Object (readonly)
Returns the value of attribute heroku_api.
7 8 9 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 7 def heroku_api @heroku_api end |
#key_extractor ⇒ Object (readonly)
Returns the value of attribute key_extractor.
7 8 9 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 7 def key_extractor @key_extractor end |
#rendezvous ⇒ Object (readonly)
Returns the value of attribute rendezvous.
7 8 9 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 7 def rendezvous @rendezvous end |
Instance Method Details
#app_maintenance_off ⇒ Object
21 22 23 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 21 def app_maintenance_off app_maintenance('0') end |
#app_maintenance_on ⇒ Object
25 26 27 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 25 def app_maintenance_on app_maintenance('1') end |
#app_restart ⇒ Object
17 18 19 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 17 def app_restart heroku_api.post_ps_restart(app_name) end |
#app_url ⇒ Object
29 30 31 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 29 def app_url app_domain_name end |
#last_deploy_commit ⇒ Object
42 43 44 45 46 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 42 def last_deploy_commit data = heroku_api.get_releases(app_name).body return nil if data.empty? data.last['commit'] end |
#run_migrations ⇒ Object
33 34 35 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 33 def run_migrations run_task('rake db:migrate') end |
#run_task(task_name) ⇒ Object
37 38 39 40 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 37 def run_task(task_name) data = heroku_api.post_ps(app_name, task_name, attach: 'true').body rendezvous.start(url: data['rendezvous_url']) end |