class Hu::Cli::Scale

Heroku Scale

Constants

DYNO_TYPES

Public Instance Methods

h() click to toggle source
# File lib/hu/scale.rb, line 195
def h
  @h ||= PlatformAPI.connect_oauth(Hu::API_TOKEN)
end
heroku_state(force_refresh = false) click to toggle source
# File lib/hu/scale.rb, line 174
def heroku_state(force_refresh = false)
  return @heroku_state unless force_refresh || @heroku_state.nil?
  data = {}
  app_names = h.app.list.map { |e| e['name'] }.reject { |e| ignored_app?(e) }
  threads = []
  app_names.each_with_index do |app_name, _i|
    threads << Thread.new do
      h.formation.list(app_name).each do |dyno|
        dyno_size = dyno['size'].downcase
        data[app_name] ||= {}
        data[app_name][dyno_size] ||= []
        data[app_name][dyno_size] << { type: dyno['type'], quantity: dyno['quantity'] }
      end
    end
  end
  threads.each_with_index do |t, _i|
    t.join
  end
  @heroku_state = data
end
ignored_app?(app_name) click to toggle source
# File lib/hu/scale.rb, line 167
def ignored_app?(app_name)
  ENV.fetch('HU_IGNORE_APPS', '').split(' ').each do |p|
    return true if File.fnmatch(p, app_name)
  end
  false
end
print_state(state) click to toggle source
print_types() click to toggle source
scale(_cmd, _opts, _args) click to toggle source
# File lib/hu/scale.rb, line 97
def scale(_cmd, _opts, _args)
  print_types
  puts
  print_state heroku_state
end