test/helper.rb in yahns-1.12.1 vs test/helper.rb in yahns-1.12.2
- old
+ new
@@ -86,24 +86,26 @@
end
end
require "tempfile"
require 'tmpdir'
-class Dir
- def Dir.mktmpdir
- begin
- d = "#{Dir.tmpdir}/#$$.#{rand}"
- Dir.mkdir(d)
- rescue Errno::EEXIST
- end while true
- return d unless block_given?
- begin
- yield d
- ensure
- FileUtils.remove_entry(d)
- end
+
+# Can't rely on mktmpdir until we drop Ruby 1.9.3 support
+def yahns_mktmpdir
+ d = nil
+ begin
+ dir = "#{Dir.tmpdir}/yahns.#$$.#{rand}"
+ Dir.mkdir(dir)
+ d = dir
+ rescue Errno::EEXIST
+ end until d
+ return d unless block_given?
+ begin
+ yield d
+ ensure
+ FileUtils.remove_entry(d)
end
-end unless Dir.respond_to?(:mktmpdir)
+end
def tmpfile(*args)
tmp = Tempfile.new(*args)
tmp.sync = true
tmp.binmode