Arborist

module
Extended With
Loggability
Configurability
Arborist::MethodUtilities

Arborist namespace

Arborist namespace

A collection of generically-useful mixins

Constants

CONFIG_ENV

The name of the environment variable which can be used to set the config path

DEFAULT_CONFIG_FILE

The name of the config file that's loaded if none is specified.

LOCAL_CONFIG_FILE

The name of the config file for local overrides.

REVISION

Version control revision

VERSION

Package version

Public Instance Methods

anchor
arborist()

Set up a logger for the Arborist namespace

# File lib/arborist.rb, line 34
log_as :arborist

Configuration API

↑ top

Public Class Methods

anchor
add_dsl_constructor( subclass, &method_body )

Add a constructor function to the Arborist namespace called name with the specified method_body.

# File lib/arborist.rb, line 89
def self::add_dsl_constructor( subclass, &method_body )
        name = subclass.name

        if name
                name.sub!( /.*::/, '' )
                self.log.debug "Adding factory method for %p: %p" % [ name, method_body ]
                singleton_class.instance_exec( name, method_body ) do |name, body|
                        define_method( name, &body )
                end
        else
                self.log.info "Skipping DSL constructor for anonymous class."
        end
end
anchor
client()

Return a new Arborist::Client.

# File lib/arborist.rb, line 140
def self::client
        return Arborist::Client.new
end
anchor
config()

Get the loaded config (a Configurability::Config object)

# File lib/arborist.rb, line 59
def self::config
        Configurability.loaded_config
end
anchor
config_loaded?()

Returns true if the configuration has been loaded at least once.

# File lib/arborist.rb, line 65
def self::config_loaded?
        return self.config ? true : false
end
anchor
load_all()

Load all node and event types

# File lib/arborist.rb, line 146
def self::load_all
        Arborist::Node.load_all
end
anchor
load_config( config_file=nil, defaults=nil )

Load the specified config_file, install the config in all objects with Configurability, and call any callbacks registered via after_configure.

# File lib/arborist.rb, line 72
def self::load_config( config_file=nil, defaults=nil )
        config_file ||= ENV[ CONFIG_ENV ]
        config_file ||= LOCAL_CONFIG_FILE if LOCAL_CONFIG_FILE.exist?
        config_file ||= DEFAULT_CONFIG_FILE

        defaults    ||= Configurability.gather_defaults

        self.log.info "Loading config from %p with defaults for sections: %p." %
                [ config_file, defaults.keys ]
        config = Configurability::Config.load( config_file, defaults )

        config.install
end
anchor
manager_for( loader )

Return a new Arborist::Manager for the nodes loaded by the specified loader.

# File lib/arborist.rb, line 105
def self::manager_for( loader )
        self.load_all
        nodes = Arborist::Node.each_in( loader )
        manager = Arborist::Manager.new
        manager.load_tree( nodes )

        return manager
end
anchor
monitor_runner_for( loader )

Return a new Arborist::MonitorRunner for the monitors described in files under the specified loader.

# File lib/arborist.rb, line 117
def self::monitor_runner_for( loader )
        self.load_all
        monitors = Arborist::Monitor.each_in( loader )
        runner = Arborist::MonitorRunner.new
        runner.load_monitors( monitors )

        return runner
end
anchor
observer_runner_for( loader )

Return a new Arborist::ObserverRunner for the observers described in files under the specified loader.

# File lib/arborist.rb, line 129
def self::observer_runner_for( loader )
        self.load_all
        observers = Arborist::Observer.each_in( loader )
        runner = Arborist::ObserverRunner.new
        runner.load_observers( observers )

        return runner
end