Class: Bookbinder::Configuration::CfCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/configuration.rb

Constant Summary collapse

REQUIRED_KEYS =
%w(api_endpoint organization app_name).freeze
OPTIONAL_KEYS =
%w(username password production_space production_host staging_space staging_host).freeze

Instance Method Summary collapse

Constructor Details

#initialize(cred_hash, is_production) ⇒ CfCredentials

Returns a new instance of CfCredentials.



42
43
44
45
# File 'lib/bookbinder/configuration.rb', line 42

def initialize(cred_hash, is_production)
  @creds = cred_hash
  @is_production = is_production
end

Instance Method Details

#flat_routesObject



64
65
66
67
68
69
# File 'lib/bookbinder/configuration.rb', line 64

def flat_routes
  routes.reduce([]) do |all_routes, domain_apps|
    domain, apps = domain_apps
    all_routes + apps.map { |app| [domain, app] }
  end
end

#routesObject



59
60
61
62
# File 'lib/bookbinder/configuration.rb', line 59

def routes
  key = is_production ? 'production_host' : 'staging_host'
  fetch(key) if correctly_formatted_domain_and_routes?(key)
end

#spaceObject



71
72
73
74
# File 'lib/bookbinder/configuration.rb', line 71

def space
  key = is_production ? 'production_space' : 'staging_space'
  fetch(key)
end