class Awestruct::Handlers::FileHandler
Attributes
path[RW]
Public Class Methods
new(site, path)
click to toggle source
Calls superclass method
Awestruct::Handlers::BaseHandler::new
# File lib/awestruct/handlers/file_handler.rb, line 9 def initialize(site, path) super( site ) case ( path ) when Pathname @path = path else @path = Pathname.new( path.to_s ) end @relative_source_path = nil end
Public Instance Methods
input_mtime(page)
click to toggle source
# File lib/awestruct/handlers/file_handler.rb, line 39 def input_mtime(page) path.mtime end
output_filename()
click to toggle source
# File lib/awestruct/handlers/file_handler.rb, line 20 def output_filename File.basename( @path ) end
raw_content()
click to toggle source
# File lib/awestruct/handlers/file_handler.rb, line 43 def raw_content load_content end
read_content()
click to toggle source
# File lib/awestruct/handlers/file_handler.rb, line 51 def read_content File.open(@path, 'r') {|is| is.read } end
relative_source_path()
click to toggle source
# File lib/awestruct/handlers/file_handler.rb, line 24 def relative_source_path return @relative_source_path unless @relative_source_path.nil? begin @relative_source_path = "/#{Pathname.new path.relative_path_from( site.dir )}" rescue Exception=>e nil end @relative_source_path end
rendered_content(context, with_layouts=true)
click to toggle source
# File lib/awestruct/handlers/file_handler.rb, line 47 def rendered_content(context, with_layouts=true) raw_content end
stale?()
click to toggle source
# File lib/awestruct/handlers/file_handler.rb, line 34 def stale? return true if ( @content.nil? || ( File.mtime( @path ) > @mtime ) ) false end
Private Instance Methods
load_content()
click to toggle source
# File lib/awestruct/handlers/file_handler.rb, line 57 def load_content ( @content = read_content ) if stale? @mtime = File.mtime( @path ) @content end