Class: Webgen::PathHandler::Copy
- Inherits:
-
Object
- Object
- Webgen::PathHandler::Copy
- Includes:
- Base
- Defined in:
- lib/webgen/path_handler/copy.rb
Overview
Simple path handler for copying files from the source to the destination, either without changing anything or by applying one or more content processors.
Constant Summary
Constants included from Base
Base::DEST_PATH_PARENT_SEGMENTS, Base::DEST_PATH_SEGMENTS
Instance Method Summary collapse
-
#content(node) ⇒ Object
Return the processed content of the
node
if the pipeline meta info key is specified or the IO object for the node’s source path. -
#create_nodes(path) ⇒ Object
Create the node for
path
.
Methods included from Base
#initialize, #parse_meta_info!
Instance Method Details
#content(node) ⇒ Object
Return the processed content of the node
if the pipeline meta info key is specified or the IO object for the node’s source path.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/webgen/path_handler/copy.rb', line 37 def content(node) if pipeline = node.['pipeline'] pipeline = @website.ext.content_processor.normalize_pipeline(pipeline) is_binary = @website.ext.content_processor.is_binary?(pipeline.first) context = Webgen::Context.new(@website, :chain => [node], :content => node.node_info[:path].data(is_binary ? 'rb' : 'r')) pipeline.each {|processor| @website.ext.content_processor.call(processor, context)} context.content else node.node_info[:path] end end |
#create_nodes(path) ⇒ Object
Create the node for path
.
See the user documentation for detailed information about how the content processor pipeline can be specified.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/webgen/path_handler/copy.rb', line 19 def create_nodes(path) if !path..has_key?('pipeline') pipeline = [] exts = path.ext.split('.') pipeline << exts.shift while exts.length > 1 && @website.ext.content_processor.registered?(exts.first) if (data = @website.ext.content_processor.map_extension(exts.last)) pipeline << data.first exts[-1] = data.last end path.['pipeline'] = pipeline unless pipeline.empty? path.ext = exts.join('.') end create_node(path) end |