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

new(override_paths) click to toggle source

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

get_all_services() click to toggle source

Return all the services assigned to this application.

# File lib/paasmaker.rb, line 140
def get_all_services()
    return @services
end
get_application_name() click to toggle source

Get the application name.

# File lib/paasmaker.rb, line 145
def get_application_name()
    return @variables['application']['name']
end
get_application_version() click to toggle source

Get the application version.

# File lib/paasmaker.rb, line 150
def get_application_version()
    return @variables['application']['version']
end
get_node_tags() click to toggle source

Get the node tags. Returns a Hash of the tags.

# File lib/paasmaker.rb, line 165
def get_node_tags()
    return @variables['node']
end
get_port() click to toggle source

Get the port that you should be listening on.

# File lib/paasmaker.rb, line 175
def get_port()
    return @port
end
get_rails_env(default) click to toggle source

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_service(name) click to toggle source

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_workspace_name() click to toggle source

Get the workspace name.

# File lib/paasmaker.rb, line 155
def get_workspace_name()
    return @variables['application']['workspace']
end
get_workspace_stub() click to toggle source

Get the workspace stub.

# File lib/paasmaker.rb, line 160
def get_workspace_stub()
    return @variables['application']['workspace_stub']
end
get_workspace_tags() click to toggle source

Get the workspace tags. Returns a Hash of the tags.

# File lib/paasmaker.rb, line 170
def get_workspace_tags()
    return @variables['workspace']
end
is_on_paasmaker?() click to toggle source

Return true if the application is running on Paasmaker.

# File lib/paasmaker.rb, line 125
def is_on_paasmaker?()
    return @is_on_paasmaker
end