Class: Rake::FileTask

Inherits:
Task
  • Object
show all
Defined in:
lib/rake/file_task.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

Instance Attribute Summary

Attributes inherited from Task

#actions, #already_invoked, #application, #locations, #order_only_prerequisites, #prerequisites, #scope, #sources

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Task

[], #add_description, #all_prerequisite_tasks, #arg_description, #arg_names, #clear, clear, #clear_actions, #clear_args, #clear_comments, #clear_prerequisites, #comment, #comment=, create_rule, define_task, #enhance, #execute, format_deps, #full_comment, #initialize, #inspect, #investigation, #invoke, #invoke_prerequisites, #invoke_prerequisites_concurrently, #name, #name_with_args, #prerequisite_tasks, #reenable, #set_arg_names, #source, task_defined?, tasks, #to_s, #|

Constructor Details

This class inherits a constructor from Rake::Task

Class Method Details

.scope_name(scope, task_name) ⇒ Object

Apply the scope to the task name according to the rules for this kind of task. File based tasks ignore the scope when creating the name.



53
54
55
# File 'lib/rake/file_task.rb', line 53

def scope_name(scope, task_name)
  Rake.from_pathname(task_name)
end

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)


16
17
18
19
20
21
22
# File 'lib/rake/file_task.rb', line 16

def needed?
  begin
    out_of_date?(File.mtime(name)) || @application.options.build_all
  rescue Errno::ENOENT
    true
  end
end

#timestampObject

Time stamp for file task.



25
26
27
28
29
30
31
# File 'lib/rake/file_task.rb', line 25

def timestamp
  begin
    File.mtime(name)
  rescue Errno::ENOENT
    Rake::LATE
  end
end