Sha256: 854558635749fdcab6997394dd2380c301fa5f8d03202600277d167a50367d27

Contents?: true

Size: 1.28 KB

Versions: 215

Compression:

Stored size: 1.28 KB

Contents

require 'rake/task.rb'
require 'rake/early_time'

module Rake
  # #########################################################################
  # 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).
  #
  class FileTask < Task

    # Is this file task needed?  Yes if it doesn't exist, or if its time stamp
    # is out of date.
    def needed?
      ! File.exist?(name) || out_of_date?(timestamp)
    end

    # Time stamp for file task.
    def timestamp
      if File.exist?(name)
        File.mtime(name.to_s)
      else
        Rake::EARLY
      end
    end

    private

    # Are there any prerequisites with a later time than the given time stamp?
    def out_of_date?(stamp)
      @prerequisites.any? { |n| application[n, @scope].timestamp > stamp}
    end

    # ----------------------------------------------------------------
    # Task class methods.
    #
    class << self
      # 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.
      def scope_name(scope, task_name)
        task_name
      end
    end
  end
end

Version data entries

215 entries across 169 versions & 43 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rake-0.9.6/lib/rake/file_task.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rake-0.9.6/lib/rake/file_task.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_task.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rake-10.0.3/lib/rake/file_task.rb
gss-0.0.7 vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_task.rb
gss-0.0.6 vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_task.rb
gss-0.0.5 vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_task.rb
candlepin-api-0.4.0 bundle/ruby/gems/rake-0.9.2.2/lib/rake/file_task.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/file_task.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_task.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/rake-10.0.3/lib/rake/file_task.rb
swipe-rails-0.0.5 vendor/bundle/gems/rake-10.0.4/lib/rake/file_task.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_task.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_task.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_task.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/rake-10.0.4/lib/rake/file_task.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/rake-10.0.4/lib/rake/file_task.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_task.rb
vergissberlin-0.0.9 vendor/bundle/gems/rake-10.0.4/lib/rake/file_task.rb
vergissberlin-0.0.7 vendor/bundle/gems/rake-10.0.4/lib/rake/file_task.rb