Class: Escobar::Heroku::Dynos
- Inherits:
-
Object
- Object
- Escobar::Heroku::Dynos
- Defined in:
- lib/escobar/heroku/dynos.rb
Overview
Class representing an app’s dyno state
Constant Summary collapse
- ONE_OFF_TYPES =
%w{run scheduler}.freeze
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#command_id ⇒ Object
Returns the value of attribute command_id.
-
#github_url ⇒ Object
Returns the value of attribute github_url.
-
#pipeline_name ⇒ Object
Returns the value of attribute pipeline_name.
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(client, app_id) ⇒ Dynos
constructor
A new instance of Dynos.
- #newer_than?(epoch) ⇒ Boolean
- #non_one_off ⇒ Object
- #running?(release_id) ⇒ Boolean
- #running_at_least?(version) ⇒ Boolean
Constructor Details
#initialize(client, app_id) ⇒ Dynos
Returns a new instance of Dynos.
13 14 15 16 |
# File 'lib/escobar/heroku/dynos.rb', line 13 def initialize(client, app_id) @app_id = app_id @client = client end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
7 8 9 |
# File 'lib/escobar/heroku/dynos.rb', line 7 def app_id @app_id end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/escobar/heroku/dynos.rb', line 7 def client @client end |
#command_id ⇒ Object
Returns the value of attribute command_id.
9 10 11 |
# File 'lib/escobar/heroku/dynos.rb', line 9 def command_id @command_id end |
#github_url ⇒ Object
Returns the value of attribute github_url.
10 11 12 |
# File 'lib/escobar/heroku/dynos.rb', line 10 def github_url @github_url end |
#pipeline_name ⇒ Object
Returns the value of attribute pipeline_name.
11 12 13 |
# File 'lib/escobar/heroku/dynos.rb', line 11 def pipeline_name @pipeline_name end |
Instance Method Details
#info ⇒ Object
18 19 20 |
# File 'lib/escobar/heroku/dynos.rb', line 18 def info @info ||= client.heroku.get("/apps/#{app_id}/dynos") end |
#newer_than?(epoch) ⇒ Boolean
38 39 40 41 42 |
# File 'lib/escobar/heroku/dynos.rb', line 38 def newer_than?(epoch) non_one_off.all? do |dyno| epoch < Time.parse(dyno["created_at"]).utc end end |
#non_one_off ⇒ Object
22 23 24 |
# File 'lib/escobar/heroku/dynos.rb', line 22 def non_one_off info.reject { |dyno| ONE_OFF_TYPES.include?(dyno["type"]) } end |
#running?(release_id) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/escobar/heroku/dynos.rb', line 26 def running?(release_id) non_one_off.all? do |dyno| dyno["release"]["id"] == release_id && dyno["state"] == "up" end end |
#running_at_least?(version) ⇒ Boolean
32 33 34 35 36 |
# File 'lib/escobar/heroku/dynos.rb', line 32 def running_at_least?(version) non_one_off.all? do |dyno| dyno["release"]["version"] >= version && dyno["state"] == "up" end end |