class Paasmaker::Interface
An interface class for Paasmaker
. It can parse the Paasmaker
environment variables and supply them to your application. Alternately, it can load override configuration files to fill in missing values if it is not running on Paasmaker
.
Public Class Methods
Create a new instance of the interface class. Supply an array of override path names. For example, supply ['../project-name.json']
to load a configuration file one level above your project root.
# File lib/paasmaker.rb, line 28 def initialize(override_paths) @override_paths = override_paths @is_on_paasmaker = false @variables = {} @services = {} # It's over 9000. @port = 9001 parse_metadata() end
Public Instance Methods
Return all the services assigned to this application.
# File lib/paasmaker.rb, line 140 def get_all_services() return @services end
Get the application name.
# File lib/paasmaker.rb, line 145 def get_application_name() return @variables['application']['name'] end
Get the application version.
# File lib/paasmaker.rb, line 150 def get_application_version() return @variables['application']['version'] end
Get the port that you should be listening on.
# File lib/paasmaker.rb, line 175 def get_port() return @port end
Helper to fetch the rails environment. The way this works is that it looks for the RAILS_ENV
key on the workspace metadata, and uses that if found. If not, it uses the default supplied.
# File lib/paasmaker.rb, line 183 def get_rails_env(default) workspace_tags = get_workspace_tags() if workspace_tags.has_key?('RAILS_ENV') return workspace_tags['RAILS_ENV'] else return default end end
Get a named service from Paasmaker
. Raises an InterfaceException
if there is no such service.
# File lib/paasmaker.rb, line 131 def get_service(name) if @services.has_key?(name) return @services[name] else raise InterfaceException, "No such service #{name}." end end
Get the workspace name.
# File lib/paasmaker.rb, line 155 def get_workspace_name() return @variables['application']['workspace'] end
Get the workspace stub.
# File lib/paasmaker.rb, line 160 def get_workspace_stub() return @variables['application']['workspace_stub'] end
Return true if the application is running on Paasmaker
.
# File lib/paasmaker.rb, line 125 def is_on_paasmaker?() return @is_on_paasmaker end