Class: RooOnRails::Checks::Heroku::AppExists

Inherits:
EnvSpecific show all
Defined in:
lib/roo_on_rails/checks/heroku/app_exists.rb

Overview

Check if a corresponding app exists on Heroku (for a given environment)

Input context

  • git_repo: the name of the repository

  • heroku.api_client: a connected PlatformAPI client

  • app_name_stem (optional): a name override

Output context:

Constant Summary collapse

ACCEPTABLE_ENV_NAMES =
{
  'production' => %w(prd production),
  'staging'    => %w(stg staging)
}.freeze

Instance Attribute Summary

Attributes inherited from EnvSpecific

#env

Instance Method Summary collapse

Methods inherited from EnvSpecific

#initialize, #signature

Methods inherited from Base

#initialize, requires, #run

Methods included from RooOnRails::Checks::Helpers

#bold, included

Constructor Details

This class inherits a constructor from RooOnRails::Checks::EnvSpecific

Instance Method Details

#callObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/roo_on_rails/checks/heroku/app_exists.rb', line 29

def call
  all_apps = client.app.list.map { |a| a['name'] }
  matches = all_apps.select { |a| candidates.include?(a) }
  if matches.empty?
    fail! "no apps with matching names detected"
  end

  if matches.many?
    list = candidates.map { |c| bold c }.join(', ')
    final_fail! "multiple matching apps detected: #{list}"
  end

  context.heroku.app![env] = matches.first
  pass "found app #{bold matches.first}"
end

#introObject



25
26
27
# File 'lib/roo_on_rails/checks/heroku/app_exists.rb', line 25

def intro
  "Checking if #{bold env} app exist..."
end