Sha256: fa213b5d2fd1159b76e7683ba34ecf9685e5f88df2ab77e4ed3acaddde046e3d
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
# -*- encoding: utf-8 -*- module Webgen::SourceHandler # Simple source handler for copying files from the source tree, either verbatim or by applying a # content processor. class Copy include Webgen::WebsiteAccess include Base # Create the node for +parent+ and +path+. If the +path+ has the name of a content processor as # the first part in the extension, it is preprocessed. def create_node(parent, path) if path.ext.index('.') processor, *rest = path.ext.split('.') if website.blackboard.invoke(:content_processor_names).include?(processor) path.ext = rest.join('.') else processor = nil end end super(parent, path) do |node| node.node_info[:preprocessor] = processor end end # Return either the preprocessed content of the +node+ or the IO object for the node's source # path depending on the node type. def content(node) io = website.blackboard.invoke(:source_paths)[node.node_info[:src]].io if node.node_info[:preprocessor] context = Webgen::Context.new(:content => io.data, :chain => [node]) website.blackboard.invoke(:content_processor, node.node_info[:preprocessor]).call(context) context.content else io end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
gettalong-webgen-0.5.8.20090507 | lib/webgen/sourcehandler/copy.rb |
webgen-0.5.8 | lib/webgen/sourcehandler/copy.rb |