Class: Loki::Task::File

Inherits:
Loki::Task show all
Includes:
Identity
Defined in:
lib/loki/task/file.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Identity

included

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.expand_path(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

#pathObject



34
35
36
# File 'lib/loki/task/file.rb', line 34

def path
  @path.path
end

#result_pathObject



29
30
31
# File 'lib/loki/task/file.rb', line 29

def result_path
  @path.path
end

#source_pathObject



24
25
26
# File 'lib/loki/task/file.rb', line 24

def source_path
  @sources.first.path
end

#sourcesObject



19
20
21
# File 'lib/loki/task/file.rb', line 19

def sources
  @sources.collect(&:path)
end

#timeObject



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