Sha256: 8b6aa777e68bfe743b86a6d3a1a18e4b9470357130c4e39b6fa2711ddb5740a4

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require 'autobuild/config'
require 'find'
require 'rake/tasklib'
require 'fileutils'

STAMPFILE = "autobuild-stamp"

module Autobuild
    def tree_timestamp(path, *exclude)
        # Exclude autobuild timestamps
        exclude << "*-#{STAMPFILE}"

        puts "getting tree timestamp for #{path}" if Autobuild.debug
        latest = Time.at(0)
        latest_file = ""

        exclude.collect! { |e| File.expand_path(e, path) }
        Find.find(path) { |p|
            Find.prune if File.basename(p) =~ /^\./
            exclude.each { |pattern| 
                if File.fnmatch?(pattern, p) 
                    puts "  excluding #{p}" if Autobuild.debug
                    Find.prune
                end
            }
            next if File.directory?(p)

            p_time = File.mtime(p)
            if latest < p_time
                latest = p_time
                latest_file = p
            end
        }

        puts "  #{latest}" if Autobuild.debug
        return latest
    end

    class SourceTreeTask < Rake::Task
        attr_accessor :exclude
        def timestamp
            tree_timestamp(name, "*CVS", *@exclude)
        end
    end
    def source_tree(path, exclude = [], &block)
        task = SourceTreeTask.define_task(path, &block)
        task.exclude = exclude
    end
            
    def get_stamp(stampfile)
        return Time.at(0) if !File.exists?(stampfile)
        return File.mtime(stampfile)
    end

    def touch_stamp(stampfile)
        puts "Touching #{stampfile}" if Autobuild.debug
        FileUtils.touch(stampfile)
        sleep(1)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
autobuild-0.6 lib/autobuild/timestamps.rb