Sha256: f259c35ec8f8e5d6511dcf981bf8dfc67cd2c69eb2689de2fe8e0e160ae5cecf
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'awestruct/handlers/base_handler' module Awestruct module Handlers class FileHandler < BaseHandler attr_accessor :path def initialize(site, path) super( site ) case ( path ) when Pathname @path = path else @path = Pathname.new( path.to_s ) end end def output_filename File.basename( @path ) end def relative_source_path begin "/#{Pathname.new path.relative_path_from( site.dir )}" rescue Exception=>e nil end end def stale? return true if ( @content.nil? || ( File.mtime( @path ) > @mtime ) ) false end def input_mtime(page) path.mtime end def raw_content load_content end def rendered_content(context, with_layouts=true) raw_content end def read_content File.open(@path, 'r') {|is| is.read } end private def load_content ( @content = read_content ) if stale? @mtime = File.mtime( @path ) @content end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
awestruct-0.5.7 | lib/awestruct/handlers/file_handler.rb |