Class: Renuo::Cli::Services::Heroku
- Inherits:
-
Object
- Object
- Renuo::Cli::Services::Heroku
- Defined in:
- lib/renuo/cli/services/heroku.rb
Constant Summary collapse
- TEAMS =
%w[staff renuo-legacy].freeze
Class Method Summary collapse
Class Method Details
.fetch_app_names(team = nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/renuo/cli/services/heroku.rb', line 19 def fetch_app_names(team = nil) fetch_app_names_cmd = %(heroku apps --json #{"--team=#{team}" if team} | jq -r '.[] | "\\(.name)"') stdout, stderr, status = Open3.capture3 fetch_app_names_cmd raise "Error fetching Heroku app list: #{stderr}" unless status.success? stdout.force_encoding("UTF-8").split("\n").map(&:strip) end |
.fetch_apps ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/renuo/cli/services/heroku.rb', line 7 def fetch_apps all_app_names = TEAMS.flat_map { |team| fetch_app_names(team) } all_app_names += fetch_app_names # fetch apps from personal account (e.g. as collaborator) apps = [] iterator = respond_to?(:progress) ? progress(all_app_names) : all_app_names iterator.each do |app_name| apps << { name: app_name, domains: fetch_domains(app_name) } end apps end |
.fetch_domains(app_name) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/renuo/cli/services/heroku.rb', line 27 def fetch_domains(app_name) fetch_domains_cmd = %(heroku domains --app #{app_name} --json | jq -r '.[] | "\\(.hostname)"') stdout, stderr, status = Open3.capture3 fetch_domains_cmd raise "Error fetching Heroku domains information: #{stderr}" unless status.success? stdout.force_encoding("UTF-8").split("\n").map(&:strip) end |