Class: HerokuAppInfo::Fetcher
- Inherits:
-
Object
- Object
- HerokuAppInfo::Fetcher
- Defined in:
- lib/heroku_app_info/fetcher.rb
Instance Method Summary collapse
- #addons(app) ⇒ String
- #all_apps ⇒ String
- #app(app) ⇒ String
- #cache_file(app: nil, sort: nil) ⇒ String, false
-
#initialize(options = nil) ⇒ Fetcher
constructor
A new instance of Fetcher.
- #pg(app) ⇒ String
Constructor Details
#initialize(options = nil) ⇒ Fetcher
Returns a new instance of Fetcher.
13 14 15 16 |
# File 'lib/heroku_app_info/fetcher.rb', line 13 def initialize( = nil) @options = raise HerokuCliNotFound if TTY::Which.which("heroku").nil? end |
Instance Method Details
#addons(app) ⇒ String
46 47 48 49 50 51 52 |
# File 'lib/heroku_app_info/fetcher.rb', line 46 def addons(app) if (path = cache_file(app: app)) File.read(path) else `heroku addons -a #{app}` end end |
#all_apps ⇒ String
57 58 59 60 61 62 63 |
# File 'lib/heroku_app_info/fetcher.rb', line 57 def all_apps if (path = cache_file) File.read(path) else `heroku apps -A` end end |
#app(app) ⇒ String
22 23 24 25 26 27 28 |
# File 'lib/heroku_app_info/fetcher.rb', line 22 def app(app) if (path = cache_file(app: app)) File.read(path) else `heroku apps:info #{app}` end end |
#cache_file(app: nil, sort: nil) ⇒ String, false
70 71 72 73 74 75 76 77 |
# File 'lib/heroku_app_info/fetcher.rb', line 70 def cache_file(app: nil, sort: nil) return false if @options.no_cache? filename, = ContentResolver.resolve(app || "apps", "", sort: sort) path = File.join(@options.out_dir, filename) (File.exist?(path) && File.readable?(path)) ? path : false end |
#pg(app) ⇒ String
34 35 36 37 38 39 40 |
# File 'lib/heroku_app_info/fetcher.rb', line 34 def pg(app) if (path = cache_file(app: app, sort: "pg")) File.read(path) else `heroku pg -a #{app}` end end |