Class: Fewer::Engines::Abstract
- Inherits:
-
Object
- Object
- Fewer::Engines::Abstract
- Defined in:
- lib/fewer/engines/abstract.rb
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #check_paths! ⇒ Object
- #content_type ⇒ Object
- #extension ⇒ Object
-
#initialize(root, names) ⇒ Abstract
constructor
A new instance of Abstract.
- #mtime ⇒ Object
- #paths ⇒ Object
- #read ⇒ Object
Constructor Details
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
4 5 6 |
# File 'lib/fewer/engines/abstract.rb', line 4 def names @names end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
4 5 6 |
# File 'lib/fewer/engines/abstract.rb', line 4 def root @root end |
Instance Method Details
#check_paths! ⇒ Object
12 13 14 15 16 17 |
# File 'lib/fewer/engines/abstract.rb', line 12 def check_paths! if (missing = paths.reject { |path| File.exist?(path) }).any? files = missing.map { |path| path.to_s }.join("\n") raise Fewer::MissingSourceFileError.new("Missing source file#{'s' if missing.size > 1}:\n#{files}") end end |
#content_type ⇒ Object
19 20 21 |
# File 'lib/fewer/engines/abstract.rb', line 19 def content_type 'text/plain' end |
#extension ⇒ Object
23 24 |
# File 'lib/fewer/engines/abstract.rb', line 23 def extension end |
#mtime ⇒ Object
26 27 28 29 30 |
# File 'lib/fewer/engines/abstract.rb', line 26 def mtime paths.map { |path| File.mtime(path).to_i }.sort.last end |
#paths ⇒ Object
32 33 34 35 36 37 |
# File 'lib/fewer/engines/abstract.rb', line 32 def paths names.map { |name| # TODO: Fix rather large security hole... File.join(root, "#{name}#{extension}") } end |
#read ⇒ Object
39 40 41 42 43 |
# File 'lib/fewer/engines/abstract.rb', line 39 def read paths.map { |path| File.read(path) }.join("\n") end |