Debian Codegraph @

rake.d/vendor/drake-0.9.2.0.3.1/lib/rake/file_task.rb

raw
1 require 'rake/task.rb'
2 require 'rake/early_time'
3
4 module Rake
5 # #########################################################################
6 # A FileTask is a task that includes time based dependencies. If any of a
7 # FileTask's prerequisites have a timestamp that is later than the file
8 # represented by this task, then the file must be rebuilt (using the
9 # supplied actions).
10 #
11 class FileTask < Task
12
13 # Is this file task needed? Yes if it doesn't exist, or if its time stamp
14 # is out of date.
15 def needed?
16 ! File.exist?(name) || out_of_date?(timestamp)
17 end
18
19 # Time stamp for file task.
20 def timestamp
21 if File.exist?(name)
22 File.mtime(name.to_s)
23 else
24 Rake::EARLY
25 end
26 end
27
28 private
29
30 # Are there any prerequisites with a later time than the given time stamp?
31 def out_of_date?(stamp)
32 @prerequisites.any? { |n| application[n, @scope].timestamp > stamp}
33 end
34
35 # ----------------------------------------------------------------
36 # Task class methods.
37 #
38 class << self
39 # Apply the scope to the task name according to the rules for this kind
40 # of task. File based tasks ignore the scope when creating the name.
41 def scope_name(scope, task_name)
42 task_name
43 end
44 end
45 end
46 end
47