Class: HipstaScale::Heroku
- Inherits:
-
Object
- Object
- HipstaScale::Heroku
- Defined in:
- lib/hipsta_scale/heroku.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #expire! ⇒ Object
- #fetch ⇒ Object
-
#initialize(app) ⇒ Heroku
constructor
A new instance of Heroku.
- #processes ⇒ Object
- #processes_other ⇒ Object
- #scale_processes(count) ⇒ Object
Constructor Details
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/hipsta_scale/heroku.rb', line 7 def app @app end |
Instance Method Details
#expire! ⇒ Object
13 14 15 |
# File 'lib/hipsta_scale/heroku.rb', line 13 def expire! @_cache = nil end |
#fetch ⇒ Object
17 18 19 20 21 22 |
# File 'lib/hipsta_scale/heroku.rb', line 17 def fetch return @_cache unless @_cache.nil? json = RestClient.get(url, accept: 'json') response = JSON.parse(json) @_cache = response.map {|ps| OpenStruct.new(ps) } end |
#processes ⇒ Object
24 25 26 |
# File 'lib/hipsta_scale/heroku.rb', line 24 def processes fetch.select {|ps| ps.process.match(app.heroku_ps) } end |
#processes_other ⇒ Object
28 29 30 |
# File 'lib/hipsta_scale/heroku.rb', line 28 def processes_other fetch - processes end |
#scale_processes(count) ⇒ Object
32 33 34 |
# File 'lib/hipsta_scale/heroku.rb', line 32 def scale_processes(count) RestClient.post("#{url}/scale?type=#{app.heroku_ps}&qty=#{count}", accept: 'json') end |