Class: FileTask

Inherits:
Task
  • Object
show all
Defined in:
lib/rake.rb

Overview

A FileTask is a task that includes time based dependencies. If any of a FileTask’s prerequisites have a timestamp that is later than the file represented by this task, then the file must be rebuilt (using the supplied actions).

Constant Summary

Constants inherited from Task

Task::RULES, Task::TASKS

Instance Attribute Summary

Attributes inherited from Task

#comment, #prerequisites, #source

Instance Method Summary collapse

Methods inherited from Task

[], #add_comment, clear, create_rule, define_task, #enhance, enhance_with_matching_rule, #execute, #initialize, #invoke, lookup, #name, task_defined?, tasks

Constructor Details

This class inherits a constructor from Task

Instance Method Details

#needed?Boolean

Is this file task needed? Yes if it doesn’t exist, or if its time stamp is out of date.

Returns:

  • (Boolean)


275
276
277
278
279
280
# File 'lib/rake.rb', line 275

def needed?
  return true unless File.exist?(name)
  latest_prereq = @prerequisites.collect{|n| Task[n].timestamp}.max
  return false if latest_prereq.nil?
  timestamp < latest_prereq
end

#timestampObject

Time stamp for file task.



283
284
285
# File 'lib/rake.rb', line 283

def timestamp
  File.mtime(name.to_s)
end