Class: Rake::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).

Direct Known Subclasses

FileCreationTask

Constant Summary

Constants inherited from Task

Task::RULES, Task::TASKS

Instance Attribute Summary

Attributes inherited from Task

#comment, #prerequisites, #sources

Instance Method Summary collapse

Methods inherited from Task

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

Constructor Details

This class inherits a constructor from Rake::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)


398
399
400
401
402
# File 'lib/rake.rb', line 398

def needed?
  return true unless File.exist?(name)
  return true if out_of_date?(timestamp)
  false
end

#timestampObject

Time stamp for file task.



405
406
407
408
409
410
411
# File 'lib/rake.rb', line 405

def timestamp
  if File.exist?(name)
	File.mtime(name.to_s)
  else
	Rake::EARLY
  end
end