Parent

Methods

Class Index [+]

Quicksearch

Webgen::Source::Stacked

This source class is used to stack several sources together.

It serves two purposes:

Also be aware that when a path is returned by a source that has already be returned by a prior source, it is discarded and not used.

Attributes

stack[R]

Return the stack of mount point to Webgen::Source object maps.

cache_paths[RW]

Specifies whether the result of # calls should be cached (default: false). If caching is activated, new maps cannot be added to the stacked source anymore!

Public Class Methods

new(map = {}, cache_paths = false) click to toggle source

Create a new stack. The optional map parameter can be used to provide initial mappings of mount points to source objects (see # for details). You cannot add other maps after a call to # if cache_paths is true

    # File lib/webgen/source/stacked.rb, line 30
30:     def initialize(map = {}, cache_paths = false)
31:       @stack = []
32:       @cache_paths = cache_paths
33:       add(map)
34:     end

Public Instance Methods

add(maps) click to toggle source

Add all mappings found in maps to the stack. The parameter maps should be an array of two-element arrays which contain an absolute directory (ie. starting and ending with a slash) and a source object.

    # File lib/webgen/source/stacked.rb, line 39
39:     def add(maps)
40:       raise "Cannot add new maps since caching is activated for this source" if defined?(@paths) && @cache_paths
41:       maps.each do |mp, source|
42:         raise "Invalid mount point specified: #{mp}" unless mp =~ /^\//
43:         @stack << [mp, source]
44:       end
45:     end
paths() click to toggle source

Return all paths returned by the sources in the stack. Since the stack is ordered, paths returned by later source objects are not used if a prior source object has returned the same path.

    # File lib/webgen/source/stacked.rb, line 50
50:     def paths
51:       return @paths if defined?(@paths) && @cache_paths
52:       @paths = Set.new
53:       @stack.each do |mp, source|
54:         source.paths.each do |path|
55:           @paths.add?(path.mount_at(mp))
56:         end
57:       end
58:       @paths
59:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.