Module: Webgen::SourceHandler::Base::OutputPathHelpers
- Included in:
- Webgen::SourceHandler::Base
- Defined in:
- lib/webgen/sourcehandler/base.rb
Overview
This module is used for defining all methods that can be used for creating output paths.
All public methods of this module are considered to be output path creation methods and must have the following parameters:
parent
-
the parent node
path
-
the path for which the output name should be created
use_lang_part
-
controls whether the output path name has to include the language part
Instance Method Summary collapse
-
#standard_output_path(parent, path, use_lang_part, style = path.meta_info['output_path_style']) ⇒ Object
Default method for creating an output path for
parent
and sourcepath
.
Instance Method Details
#standard_output_path(parent, path, use_lang_part, style = path.meta_info['output_path_style']) ⇒ Object
Default method for creating an output path for parent
and source path
.
The automatically set parameter style
(which uses the meta information output_path_style
from the path’s meta information hash) defines how the output name should be built (more information about this in the user documentation).
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/webgen/sourcehandler/base.rb', line 144 def standard_output_path(parent, path, use_lang_part, style = path.['output_path_style']) result = style.collect do |part| case part when String then part when :lang then use_lang_part ? path.['lang'] : '' when :ext then path.ext.empty? ? '' : '.' + path.ext when :parent then temp = parent; temp = temp.parent while temp.is_fragment?; temp.path when :year, :month, :day ctime = path.['created_at'] if !ctime.kind_of?(Time) raise "Invalid meta info 'created_at' for #{path}, needed because of used output path style" end ctime.send(part).to_s.rjust(2, '0') when Symbol then path.send(part) when Array then part.include?(:lang) && !use_lang_part ? '' : standard_output_path(parent, path, use_lang_part, part) else '' end end result.join('') end |