Class: Serum::StaticFile
- Inherits:
-
Object
- Object
- Serum::StaticFile
- Defined in:
- lib/serum/static_file.rb
Constant Summary collapse
- @@mtimes =
The cache of last modification times [path] -> mtime.
Hash.new
Class Method Summary collapse
-
.reset_cache ⇒ Object
Reset the mtimes cache (for testing purposes).
Instance Method Summary collapse
-
#destination(dest) ⇒ Object
Obtain destination path.
-
#initialize(site, base, dir, name) ⇒ StaticFile
constructor
Initialize a new StaticFile.
-
#modified? ⇒ Boolean
Is source path modified?.
-
#mtime ⇒ Object
Returns last modification time for this file.
-
#path ⇒ Object
Returns source file path.
Constructor Details
#initialize(site, base, dir, name) ⇒ StaticFile
Initialize a new StaticFile.
site - The Site. base - The String path to the <source>. dir - The String path between <source> and the file. name - The String filename of the file.
12 13 14 15 16 17 |
# File 'lib/serum/static_file.rb', line 12 def initialize(site, base, dir, name) @site = site @base = base @dir = dir @name = name end |
Class Method Details
.reset_cache ⇒ Object
Reset the mtimes cache (for testing purposes).
Returns nothing.
48 49 50 51 |
# File 'lib/serum/static_file.rb', line 48 def self.reset_cache @@mtimes = Hash.new nil end |
Instance Method Details
#destination(dest) ⇒ Object
Obtain destination path.
dest - The String path to the destination dir.
Returns destination file path.
29 30 31 |
# File 'lib/serum/static_file.rb', line 29 def destination(dest) File.join(dest, @dir, @name) end |
#modified? ⇒ Boolean
Is source path modified?
Returns true if modified since last write.
41 42 43 |
# File 'lib/serum/static_file.rb', line 41 def modified? @@mtimes[path] != mtime end |
#mtime ⇒ Object
Returns last modification time for this file.
34 35 36 |
# File 'lib/serum/static_file.rb', line 34 def mtime File.stat(path).mtime.to_i end |
#path ⇒ Object
Returns source file path.
20 21 22 |
# File 'lib/serum/static_file.rb', line 20 def path File.join(@base, @dir, @name) end |