Class: Paratrooper::HerokuWrapper
- Inherits:
-
Object
- Object
- Paratrooper::HerokuWrapper
- Defined in:
- lib/paratrooper/heroku_wrapper.rb
Defined Under Namespace
Classes: ErrorNoAccess
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
-
#initialize(app_name, options = {}) ⇒ HerokuWrapper
constructor
A new instance of HerokuWrapper.
- #last_deploy_commit ⇒ Object
- #last_release_with_slug ⇒ Object
- #releases ⇒ Object
- #run_migrations ⇒ Object
- #run_task(task) ⇒ Object
Constructor Details
#initialize(app_name, options = {}) ⇒ HerokuWrapper
Returns a new instance of HerokuWrapper.
17 18 19 20 21 22 23 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 17 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] || PlatformAPI.connect_oauth(api_key) @rendezvous = [:rendezvous] || Rendezvous end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
15 16 17 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 15 def api_key @api_key end |
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
15 16 17 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 15 def app_name @app_name end |
#heroku_api ⇒ Object (readonly)
Returns the value of attribute heroku_api.
15 16 17 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 15 def heroku_api @heroku_api end |
#key_extractor ⇒ Object (readonly)
Returns the value of attribute key_extractor.
15 16 17 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 15 def key_extractor @key_extractor end |
#rendezvous ⇒ Object (readonly)
Returns the value of attribute rendezvous.
15 16 17 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 15 def rendezvous @rendezvous end |
Instance Method Details
#app_maintenance_off ⇒ Object
29 30 31 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 29 def app_maintenance_off client(:app, :update, app_name, 'maintenance' => 'false') end |
#app_maintenance_on ⇒ Object
33 34 35 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 33 def app_maintenance_on client(:app, :update, app_name, 'maintenance' => 'true') end |
#app_restart ⇒ Object
25 26 27 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 25 def app_restart client(:dyno, :restart_all, app_name) end |
#last_deploy_commit ⇒ Object
51 52 53 54 55 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 51 def last_deploy_commit return nil if last_release_with_slug.nil? slug_data = client(:slug, :info, app_name, get_slug_id(last_release_with_slug)) slug_data['commit'] end |
#last_release_with_slug ⇒ Object
57 58 59 60 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 57 def last_release_with_slug # releases is an enumerator releases.to_a.reverse.detect { |release| not release['slug'].nil? } end |
#releases ⇒ Object
37 38 39 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 37 def releases @releases ||= client(:release, :list, app_name) end |
#run_migrations ⇒ Object
41 42 43 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 41 def run_migrations run_task('rake db:migrate') end |
#run_task(task) ⇒ Object
45 46 47 48 49 |
# File 'lib/paratrooper/heroku_wrapper.rb', line 45 def run_task(task) payload = { 'command' => task, 'attach' => 'true' } data = client(:dyno, :create, app_name, payload) rendezvous.start(url: data['attach_url']) end |