Sha256: 9f2c44c00c719d28b9a61942ef0274133f6eb470be06d44e8568fee4535b8003

Contents?: true

Size: 590 Bytes

Versions: 11

Compression:

Stored size: 590 Bytes

Contents

#!/usr/bin/env ruby

require 'ftools'

module FileCreation
  def create_timed_files(oldfile, newfile)
    return if File.exist?(oldfile) && File.exist?(newfile)
    old_time = create_file(oldfile)
    while create_file(newfile) <= old_time
      sleep(0.1)
      File.delete(newfile) rescue nil
    end
  end

  def create_file(name)
    dirname = File.dirname(name)
    FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
    open(name, "w") {|f| f.puts "HI" } unless File.exist?(name)
    File.new(name).mtime
  end

  def delete_file(name)
    File.delete(name) rescue nil
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rake-0.4.10 test/filecreation.rb
rake-0.4.9 test/filecreation.rb
rake-0.4.12 test/filecreation.rb
rake-0.4.8 test/filecreation.rb
rake-0.4.11 test/filecreation.rb
rake-0.4.13 test/filecreation.rb
rake-0.4.15 test/filecreation.rb
rake-0.5.0 test/filecreation.rb
rake-0.5.3 test/filecreation.rb
rake-0.4.14 test/filecreation.rb
rake-0.5.4 test/filecreation.rb