This is the driver class for processing a series of directories, looking for configuration files. It relies on visitor objects to do the actual configuration processing—all this class does is recurse through the requested directories.

Methods
Attributes
[R] loaders This is the array of visitor objects that will be employed by this driver.
[R] search_paths This is the array of search paths that the loader will descend.
Public Class methods
new( search_paths=[] )

Create a new Loader object that will search the given paths. Regardless, the ‘copland/impl’ directory will always be processed.

    # File lib/copland/configuration/loader.rb, line 52
52:       def initialize( search_paths=[] )
53:         @search_paths = []
54:         use_library "copland"
55:         add_search_path *search_paths
56:         @loaders = []
57:       end
Public Instance methods
add_loader( loader )

Add a new visitor loader to be used while processing directories.

    # File lib/copland/configuration/loader.rb, line 65
65:       def add_loader( loader )
66:         @loaders.push loader
67:       end
add_search_path( *paths )

Add new search paths to be searched.

    # File lib/copland/configuration/loader.rb, line 60
60:       def add_search_path( *paths )
61:         @search_paths.concat( paths ).uniq!
62:       end
load( options={} )

Processes each search path in turn, and finishes by calling finalize! on each of the visitors. The options parameter is passed to each loader.

    # File lib/copland/configuration/loader.rb, line 72
72:       def load( options={} )
73:         @search_paths.each { |path| load_path path, options }
74:         @loaders.each { |loader| loader.finalize! }
75:       end
load_path( path, options )

Processes a single path (recursively). Each loader gets a turn at the directory, and then any subdirectories are processed by recursively calling this method on that directory.

If the given path does not exist, this does nothing.

    # File lib/copland/configuration/loader.rb, line 82
82:       def load_path( path, options )
83:         return unless File.directory?( path ) 
84: 
85:         @loaders.each do |loader|
86:           options = loader.process_dir( path, options )
87:         end
88: 
89:         Dir.foreach( path ) do |entry|
90:           next if entry == "." || entry == ".."
91: 
92:           file_name = File.join( path, entry )
93:           load_path( file_name, options ) if File.directory?( file_name )
94:         end
95:       end
use_library( name )

Adds the use of the given library to the registry that is being constructed. The name parameter must be the string that would be require‘d (i.e., "copland/lib"). That file must then (at least) add a value to the Copland::LIBRARIES hash: the key must be the library name (i.e., "copland/lib"), and the value must be an array of paths that should be searched for this library, for package descriptors.

     # File lib/copland/configuration/loader.rb, line 104
104:       def use_library( name )
105:         require( name )
106:         # add_search_path does a uniq! on the result, so we can always just
107:         # add the whole thing in and not worry about duplication.
108:         add_search_path *Copland::LIBRARIES[ name ]
109:       end