Module: Webgen::PathHandler::Base

Included in:
Api, Copy, Directory, Feed, MetaInfo, Page, Sitemap, Template, Virtual
Defined in:
lib/webgen/path_handler/base.rb

Overview

This module provides the helper methods needed by most, if not all, path handlers.

About

It provides default implementations of all methods expected by Webgen::PathHandler except #create_nodes, namely #initialize, #parse_meta_info! and #content.

The most important method used when implementing a path handler is probably #create_node which should be used in #create_nodes to create an actual Webgen::Node object from a Webgen::Path object.

The following utility methods are also provided:

  • #parent_node

  • #dest_path

  • #node_exists?

Defined Under Namespace

Classes: Node

Constant Summary collapse

DEST_PATH_SEGMENTS =

:nodoc:

/<.*?>|\(.*?\)/
DEST_PATH_PARENT_SEGMENTS =
/<parent(-?\d+)(?:..(-?\d+))?>/

Instance Method Summary collapse

Instance Method Details

#initialize(website) ⇒ Object

Initialize the path handler with the given Website object.



73
74
75
# File 'lib/webgen/path_handler/base.rb', line 73

def initialize(website)
  @website = website
end

#parse_meta_info!(path) ⇒ Object

Update path.meta_info with meta information found in the content of the path.

This default parse_meta_info! method does nothing and should be overridden in path handlers that know that additional meta information can be found in the content of the path itself.

Note that the return values of this method are given as extra parameters to the #create_nodes method. If you don’t handle extra parameters, return an empty array.



85
86
87
# File 'lib/webgen/path_handler/base.rb', line 85

def parse_meta_info!(path)
  []
end