Sha256: 7f62ad515f4f0cbb36a3cf0dcf47d9c2d2af70124efb2905fe3868010a831bb9
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
#-- #++ #require 'digest/md5' module Reap # = Filer # # class Filer include TaskUtils attr_accessor :source def initialize( name, source, &build ) @name = name @source = [source].flatten @build = build end # Is this file task needed? Yes if it doesn't exist, or if its time # stamp is out of date. def needed? return true unless ::File.exist?( @name ) return true if out_of_date?( timestamp( @name ) ) false end # Check timestamp. def timestamp( name ) if ::File.exist?( name.to_s ) ::File.mtime( name.to_s ) else Time::EARLY # TODO replace with Facets' -Infinity class (?) end end # Are there any sources with a later time than the given timestamp? def out_of_date?( stamp ) @source.any? { |n| timestamp(n) > stamp } end # Build file. def build @build.call if needed? end alias_method :call, :build private #def salt( file ) # Digest::MD5.new( File.read( file ) ).hexdigest #end end end #module Reap
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
reap-6.0.0 | lib/reap/class/filer.rb |
reap-6.0.2 | lib/reap/class/filer.rb |
reap-6.0.1 | lib/reap/class/filer.rb |