Class: Fewer::Engines::Abstract
- Inherits:
-
Object
- Object
- Fewer::Engines::Abstract
- Defined in:
- lib/fewer/engines/abstract.rb
Constant Summary collapse
- SANITISE_REGEXP =
/\.?\.#{File::Separator}/
Class Attribute Summary collapse
-
.content_type ⇒ Object
Returns the value of attribute content_type.
-
.extension ⇒ Object
Returns the value of attribute extension.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #encoded ⇒ Object
- #etag ⇒ Object
-
#initialize(root, paths, options = {}) ⇒ Abstract
constructor
A new instance of Abstract.
- #mtime ⇒ Object
- #read ⇒ Object
- #source ⇒ Object
Constructor Details
Class Attribute Details
.content_type ⇒ Object
Returns the value of attribute content_type.
9 10 11 |
# File 'lib/fewer/engines/abstract.rb', line 9 def content_type @content_type end |
.extension ⇒ Object
Returns the value of attribute extension.
9 10 11 |
# File 'lib/fewer/engines/abstract.rb', line 9 def extension @extension end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/fewer/engines/abstract.rb', line 12 def @options end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
12 13 14 |
# File 'lib/fewer/engines/abstract.rb', line 12 def paths @paths end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
12 13 14 |
# File 'lib/fewer/engines/abstract.rb', line 12 def root @root end |
Instance Method Details
#encoded ⇒ Object
22 23 24 |
# File 'lib/fewer/engines/abstract.rb', line 22 def encoded Serializer.encode(root, paths) end |
#etag ⇒ Object
32 33 34 35 |
# File 'lib/fewer/engines/abstract.rb', line 32 def etag # MD5 for concatenation of all files Digest::MD5.hexdigest(source) end |
#mtime ⇒ Object
26 27 28 29 30 |
# File 'lib/fewer/engines/abstract.rb', line 26 def mtime paths.map { |path| File.mtime(path) }.max || Time.now end |
#read ⇒ Object
37 38 39 |
# File 'lib/fewer/engines/abstract.rb', line 37 def read source end |
#source ⇒ Object
41 42 43 44 45 |
# File 'lib/fewer/engines/abstract.rb', line 41 def source @source ||= paths.map { |path| File.read(path) }.join("\n") end |