module Arborist
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
Set up a logger for the Arborist
namespace
# File lib/arborist.rb, line 34 log_as :arborist
Configuration API
↑ topPublic Class Methods
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.dup 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
Return a new Arborist::Client
.
# File lib/arborist.rb, line 140 def self::client return Arborist::Client.new end
Get the loaded config (a Configurability::Config object)
# File lib/arborist.rb, line 59 def self::config Configurability.loaded_config end
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
Load all node and event types
# File lib/arborist.rb, line 146 def self::load_all Arborist::Node.load_all end
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
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
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
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