class Falcon::Configuration

Manages environments which describes how to host a specific application.

Environments are key-value maps with lazy value resolution. An environment can inherit from a parent environment, which can provide defaults

A typical configuration file might look something like:

~~~ ruby
#!/usr/bin/env falcon-host
# frozen_string_literal: true

load :rack, :self_signed_tls, :supervisor

supervisor

rack 'hello.localhost', :self_signed_tls do
end
~~~

Attributes

environments[R]

The map of named environments. @attribute [Hash(String, Build::Environment)]

Public Class Methods

new() click to toggle source

Initialize an empty configuration.

# File lib/falcon/configuration.rb, line 46
def initialize
        @environments = {}
end

Public Instance Methods

add(environment) click to toggle source

Add the named environment to the configuration.

# File lib/falcon/configuration.rb, line 69
def add(environment)
        name = environment.name
        
        unless name
                raise ArgumentError, "Environment name is nil #{environment.inspect}"
        end
        
        environment = environment.flatten
        
        raise KeyError.new("#{name.inspect} is already set", key: name) if @environments.key?(name)
        
        @environments[name] = environment
end
each(key = :authority) { |environment| ... } click to toggle source

Enumerate all environments that have the specified key. @parameter key [Symbol] Filter environments that don't have this key.

# File lib/falcon/configuration.rb, line 56
def each(key = :authority)
        return to_enum(key) unless block_given?
        
        @environments.each do |name, environment|
                environment = environment.flatten
                
                if environment.include?(key)
                        yield environment
                end
        end
end
load_file(path) click to toggle source

Load the specified configuration file. See {Loader#load_file} for more details.

# File lib/falcon/configuration.rb, line 84
def load_file(path)
        Loader.load_file(self, path)
end