Class Webgen::Source::Stacked
In: lib/webgen/source/stacked.rb
Parent: Object
Error RenderError CommandNotFoundError LoadError NodeCreationError ::Rake::TaskLib WebgenTask Context\n[lib/webgen/context.rb\nlib/webgen/context/nodes.rb\nlib/webgen/context/render.rb\nlib/webgen/context/tags.rb] Node Tree FileSystem Sitemap Coderay Sitemap IncludeFile Langbar BreadcrumbTrail TikZ Menu Feed Copy Virtual Sitemap Directory Page Fragment Template Metainfo Memory Resource Tags Fragments Website Tidy Head Kramdown Less Xmllint Blocks Helpers Configuration Comparable Language Path StandardError CmdParse::CommandParser CommandParser CmdParse::Command RunCommand WebguiCommand CreateCommand ApplyCommand ExecuteCommand Link Date Relocatable Metainfo WebsiteAccess Main Loggable OutputPathHelpers ::Kramdown::Converter::Html KramdownHtmlConverter Cache Blackboard WebsiteManager Logger Page ProxyNode Utils TarArchive Stacked FileSystem RDoc Sass Erb RDiscount Erubis Haml Maruku Builder RedCloth AccessHash lib/webgen/cache.rb lib/webgen/error.rb lib/webgen/languages.rb lib/webgen/blackboard.rb lib/webgen/website.rb lib/webgen/tree.rb lib/webgen/websitemanager.rb lib/webgen/logger.rb lib/webgen/configuration.rb lib/webgen/context/tags.rb lib/webgen/path.rb lib/webgen/webgentask.rb lib/webgen/page.rb lib/webgen/node.rb lib/webgen/cli/run_command.rb lib/webgen/cli/utils.rb lib/webgen/cli/apply_command.rb lib/webgen/cli/webgui_command.rb lib/webgen/cli.rb lib/webgen/cli/create_command.rb Color CLI ClassMethods WebsiteAccess LanguageManager lib/webgen/output/filesystem.rb Output lib/webgen/common/sitemap.rb Common lib/webgen/tag/coderay.rb lib/webgen/tag/relocatable.rb lib/webgen/tag/menu.rb lib/webgen/tag/langbar.rb lib/webgen/tag/executecommand.rb lib/webgen/tag/breadcrumbtrail.rb lib/webgen/tag/metainfo.rb lib/webgen/tag/includefile.rb lib/webgen/tag/link.rb lib/webgen/tag/date.rb lib/webgen/tag/tikz.rb lib/webgen/tag/sitemap.rb Base Tag lib/webgen/sourcehandler/memory.rb lib/webgen/sourcehandler/metainfo.rb lib/webgen/sourcehandler/copy.rb lib/webgen/sourcehandler/directory.rb lib/webgen/sourcehandler.rb lib/webgen/sourcehandler/page.rb lib/webgen/sourcehandler/template.rb lib/webgen/sourcehandler/fragment.rb lib/webgen/sourcehandler/sitemap.rb lib/webgen/sourcehandler/virtual.rb lib/webgen/sourcehandler/feed.rb OutputPathHelpers Base SourceHandler lib/webgen/source/tararchive.rb lib/webgen/source/stacked.rb lib/webgen/source/resource.rb lib/webgen/source/filesystem.rb Source lib/webgen/contentprocessor/less.rb lib/webgen/contentprocessor/blocks.rb lib/webgen/contentprocessor/rdoc.rb lib/webgen/contentprocessor/sass.rb lib/webgen/contentprocessor/erb.rb lib/webgen/contentprocessor/rdiscount.rb lib/webgen/contentprocessor/tags.rb lib/webgen/contentprocessor/erubis.rb lib/webgen/contentprocessor/kramdown/html.rb lib/webgen/contentprocessor/haml.rb lib/webgen/contentprocessor/maruku.rb lib/webgen/contentprocessor/xmllint.rb lib/webgen/contentprocessor/kramdown.rb lib/webgen/contentprocessor/head.rb lib/webgen/contentprocessor/builder.rb lib/webgen/contentprocessor/tidy.rb lib/webgen/contentprocessor/redcloth.rb lib/webgen/contentprocessor/fragments.rb lib/webgen/contentprocessor.rb ContentProcessor Loggable Webgen dot/m_81_0.png

This source class is used to stack several sources together.

It serves two purposes:

  • First, it can be used to access more than one source. This is useful when your website consists of more than one source directory and you want to use all of them.
  • Second, sources can be mounted on specific directories. For example, a folder with images that you don‘t want to copy to the website source directory can be mounted under /images sothat they are available nonetheless.

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.

Methods

add   new   paths  

Attributes

cache_paths  [RW]  Specifies whether the result of paths calls should be cached (default: false). If caching is activated, new maps cannot be added to the stacked source anymore!
stack  [R]  Return the stack of mount point to Webgen::Source object maps.

Public Class methods

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

[Source]

    # 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 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.

[Source]

    # 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

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.

[Source]

    # 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

[Validate]