Class Webgen::Tree
In: lib/webgen/tree.rb
Parent: Object
Error RenderError CommandNotFoundError LoadError NodeCreationError ::Rake::TaskLib WebgenTask Helpers Configuration Node Context\n[lib/webgen/context.rb\nlib/webgen/context/nodes.rb\nlib/webgen/context/render.rb\nlib/webgen/context/tags.rb] Tree FileSystem Sitemap Copy Feed Virtual Sitemap Directory Page Fragment Template Metainfo Memory Coderay Sitemap IncludeFile BreadcrumbTrail Langbar TikZ Menu Tags Fragments Resource Website Tidy Head Kramdown Less Xmllint Blocks Comparable Language Path StandardError CmdParse::CommandParser CommandParser CmdParse::Command RunCommand WebguiCommand CreateCommand ApplyCommand WebsiteAccess Main Loggable OutputPathHelpers ExecuteCommand Link Date Relocatable Metainfo ::Kramdown::Converter::Html KramdownHtmlConverter Cache Blackboard WebsiteManager Logger Page ProxyNode Utils Scss RDoc Sass Erb RDiscount Erubis Haml Maruku Builder RedCloth AccessHash TarArchive Stacked FileSystem lib/webgen/cache.rb lib/webgen/error.rb lib/webgen/languages.rb lib/webgen/context/render.rb lib/webgen/website.rb lib/webgen/blackboard.rb lib/webgen/tree.rb lib/webgen/websitemanager.rb lib/webgen/logger.rb lib/webgen/configuration.rb lib/webgen/path.rb lib/webgen/webgentask.rb lib/webgen/page.rb lib/webgen/node.rb ClassMethods WebsiteAccess 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 LanguageManager lib/webgen/output/filesystem.rb Output lib/webgen/common/sitemap.rb Common 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/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/contentprocessor/less.rb lib/webgen/contentprocessor/scss.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 lib/webgen/source/tararchive.rb lib/webgen/source/stacked.rb lib/webgen/source/resource.rb lib/webgen/source/filesystem.rb Source Loggable Webgen dot/m_82_0.png

Represents a tree of nodes.

Methods

[]   delete_node   new   node   register_node   register_path   root  

Included Modules

WebsiteAccess

Attributes

dummy_root  [R]  The dummy root. This is the default node that gets created when the Tree is created sothat the real root node can be treated like any other node. It has only one child, namely the real root node of the tree.
node_access  [R]  Direct access to the hashes for node resolving. Only use this for reading purposes! If you just want to get a specific node for an alcn/acn/output path, use node instead.
node_info  [R]  The hash containing processing information for each node. This is normally not accessed directly but via the Node#node_info method.

Public Class methods

Create a new Tree object.

[Source]

    # File lib/webgen/tree.rb, line 27
27:     def initialize
28:       @node_access = {:alcn => {}, :acn => {}, :path => {}}
29:       @node_info = {}
30:       @dummy_root = Node.new(self, '', '')
31:     end

Public Instance methods

[](path, type = :alcn)

Alias for node

Delete the node identified by node_or_alcn and all of its children from the tree.

The message :before_node_deleted is sent with the to-be-deleted node before this node is actually deleted from the tree.

[Source]

    # File lib/webgen/tree.rb, line 73
73:     def delete_node(node_or_alcn)
74:       n = node_or_alcn.kind_of?(Node) ? node_or_alcn : @node_access[:alcn][node_or_alcn]
75:       return if n.nil? || n == @dummy_root
76: 
77:       n.children.dup.each {|child| delete_node(child)}
78: 
79:       website.blackboard.dispatch_msg(:before_node_deleted, n)
80:       n.parent.children.delete(n)
81:       @node_access[:alcn].delete(n.alcn)
82:       @node_access[:acn][n.acn].delete(n)
83:       @node_access[:path].delete(n.path)
84: 
85:       node_info.delete(n.alcn)
86:     end

Access a node via a path of a specific type. If type is alcn then path has to be an absolute localized canonical name, if type is acn then path has to be an absolute canonical name and if type is path then path needs to be an output path.

Returns the requested Node or nil if such a node does not exist.

[Source]

    # File lib/webgen/tree.rb, line 43
43:     def node(path, type = :alcn)
44:       (type == :acn ? @node_access[type][path] && @node_access[type][path].first : @node_access[type][path])
45:     end

A utility method called by Node#initialize. This method should not be used directly!

[Source]

    # File lib/webgen/tree.rb, line 49
49:     def register_node(node)
50:       if @node_access[:alcn].has_key?(node.alcn)
51:         raise "Can't have two nodes with same absolute lcn: #{node}"
52:       else
53:         @node_access[:alcn][node.alcn] = node
54:       end
55:       (@node_access[:acn][node.acn] ||= []) << node
56:       register_path(node)
57:     end

A utility method called by Node#reinit. This method should not be used directly!

[Source]

    # File lib/webgen/tree.rb, line 60
60:     def register_path(node)
61:       return if node['no_output']
62:       if @node_access[:path].has_key?(node.path)
63:         raise "Can't have two nodes with same output path: #{node.path}"
64:       else
65:         @node_access[:path][node.path] = node
66:       end
67:     end

The real root node of the tree.

[Source]

    # File lib/webgen/tree.rb, line 34
34:     def root
35:       @dummy_root.children.first
36:     end

[Validate]