Class: TidyReset::ApplicationManager
- Inherits:
-
Object
- Object
- TidyReset::ApplicationManager
- Defined in:
- lib/tidy_reset/application_manager.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #disable_maintenance_mode ⇒ Object
- #enable_maintenance_mode ⇒ Object
-
#initialize(options) ⇒ ApplicationManager
constructor
A new instance of ApplicationManager.
- #scale_dynos_to_configuration(dyno_config) ⇒ Object
- #shutdown_all_dynos ⇒ Object
Constructor Details
#initialize(options) ⇒ ApplicationManager
Returns a new instance of ApplicationManager.
7 8 9 10 11 |
# File 'lib/tidy_reset/application_manager.rb', line 7 def initialize() @name = .fetch(:name) @token = .fetch(:token) @heroku = PlatformAPI.connect_oauth(@token) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/tidy_reset/application_manager.rb', line 5 def name @name end |
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/tidy_reset/application_manager.rb', line 5 def token @token end |
Instance Method Details
#disable_maintenance_mode ⇒ Object
17 18 19 |
# File 'lib/tidy_reset/application_manager.rb', line 17 def disable_maintenance_mode @heroku.app.update(@name, { maintenance: false }) end |
#enable_maintenance_mode ⇒ Object
13 14 15 |
# File 'lib/tidy_reset/application_manager.rb', line 13 def enable_maintenance_mode @heroku.app.update(@name, { maintenance: true }) end |
#scale_dynos_to_configuration(dyno_config) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/tidy_reset/application_manager.rb', line 28 def scale_dynos_to_configuration(dyno_config) formation_list.keep_if do |formation| dyno_config.keys.include?(formation['type']) end.each do |formation| @heroku.formation.update(@name, formation['id'], { quantity: dyno_config[formation['type']] } ) end end |
#shutdown_all_dynos ⇒ Object
21 22 23 24 25 26 |
# File 'lib/tidy_reset/application_manager.rb', line 21 def shutdown_all_dynos live_formations = formation_list.select { |f| Integer(f['quantity']) > 0 } live_formations.each do |formation| @heroku.formation.update(@name, formation['id'], { quantity: 0 }) end end |