Class: Webby::Resources::Static
- Defined in:
- lib/webby/resources/static.rb
Overview
A Static resource is any file in the content folder that does not contain YAML meta-data at the top of the file and does not start with and underscore “_” character (those are partials). Static resources will be copied as-is from the content directory to the output directory.
Instance Attribute Summary
Attributes inherited from Resource
#dir, #ext, #filename, #mtime, #path
Instance Method Summary collapse
-
#destination ⇒ Object
call-seq: destination => string.
-
#dirty? ⇒ Boolean
call-seq: dirty? => true or false.
-
#render ⇒ Object
call-seq: render => string.
Methods inherited from Resource
#<=>, #[], #[]=, #equal?, #initialize, #method_missing, #url
Constructor Details
This class inherits a constructor from Webby::Resources::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Webby::Resources::Resource
Instance Method Details
#destination ⇒ Object
call-seq:
destination => string
Returns the path in the output directory where the static file should be copied. This path is used to determine if the static file is dirty and in need of copying to the output file.
39 40 41 42 43 44 45 |
# File 'lib/webby/resources/static.rb', line 39 def destination return @dest if defined? @dest and @dest @dest = ::File.join(::Webby.site.output_dir, dir, filename) @dest << '.' << @ext if @ext and !@ext.empty? @dest end |
#dirty? ⇒ Boolean
call-seq:
dirty? => true or false
Returns true
if this static file is newer than its corresponding output product. The static file needs to be copied to the output directory.
27 28 29 30 |
# File 'lib/webby/resources/static.rb', line 27 def dirty? return true unless test(?e, destination) @mtime > ::File.mtime(destination) end |
#render ⇒ Object
call-seq:
render => string
Returns the contents of the file.
17 18 19 |
# File 'lib/webby/resources/static.rb', line 17 def render ::File.read(path) end |