1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/helpers/tmp_path.rb

25 lines
377 B
Ruby
Raw Normal View History

2020-07-12 13:00:29 -04:00
module TmpPath
def clean_tmp_paths
while path = tmp_paths.pop
delete_tmp_path(path)
end
2020-07-12 13:00:29 -04:00
end
private
def tmp_path(extension=nil)
path = Tempfile.create(['', extension]) { |f| f.path }
2020-07-12 13:00:29 -04:00
tmp_paths << path
path
end
def tmp_paths
@tmp_paths ||= []
end
def delete_tmp_path(path)
File.unlink(path)
rescue Errno::ENOENT
end
end