Class: Loki::Task::File
- Inherits:
-
Loki::Task
- Object
- Loki::Task
- Loki::Task::File
- Includes:
- Identity
- Defined in:
- lib/loki/task/file.rb
Class Method Summary collapse
Instance Method Summary collapse
- #done? ⇒ Boolean
- #exists? ⇒ Boolean
-
#initialize(path, sources = nil) ⇒ File
constructor
A new instance of File.
- #path ⇒ Object
- #result_path ⇒ Object
- #source_path ⇒ Object
- #sources ⇒ Object
- #time ⇒ Object
- #up_to_date? ⇒ Boolean
Methods included from Identity
Constructor Details
#initialize(path, sources = nil) ⇒ File
7 8 9 10 11 |
# File 'lib/loki/task/file.rb', line 7 def initialize(path, sources = nil) @sources = Array(sources).map { |s| File.new(s) } @path = FilePath.new(path) super(@path.relative) end |
Class Method Details
.identify(name) ⇒ Object
14 15 16 |
# File 'lib/loki/task/file.rb', line 14 def self.identify(name) ::File.(name.to_s) end |
Instance Method Details
#done? ⇒ Boolean
39 40 41 |
# File 'lib/loki/task/file.rb', line 39 def done? exists? and up_to_date? and super end |
#exists? ⇒ Boolean
44 45 46 |
# File 'lib/loki/task/file.rb', line 44 def exists? @path.exists? end |
#path ⇒ Object
34 35 36 |
# File 'lib/loki/task/file.rb', line 34 def path @path.path end |
#result_path ⇒ Object
29 30 31 |
# File 'lib/loki/task/file.rb', line 29 def result_path @path.path end |
#source_path ⇒ Object
24 25 26 |
# File 'lib/loki/task/file.rb', line 24 def source_path @sources.first.path end |
#sources ⇒ Object
19 20 21 |
# File 'lib/loki/task/file.rb', line 19 def sources @sources.collect(&:path) end |
#time ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/loki/task/file.rb', line 54 def time if exists? @path.mtime else Loki::PRIMEVAL end end |
#up_to_date? ⇒ Boolean
49 50 51 |
# File 'lib/loki/task/file.rb', line 49 def up_to_date? (@children + @sources).none? { |task| task.time > time } end |