home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ruby164.zip / rbemx164.zip / ruby / share / doc / rdtool-0.6.10 / test / temp-dir.rb < prev    next >
Text File  |  2001-03-22  |  254b  |  20 lines

  1.  
  2. def in_temp_dir
  3.   tmpdir = "test-tmp.#$$"
  4.   pwd = Dir.pwd
  5.   Dir.mkdir(tmpdir)
  6.   Dir.chdir(tmpdir)
  7.   begin
  8.     yield
  9.   ensure
  10.     Dir.chdir(pwd)
  11.     Dir.rmdir(tmpdir)
  12.   end
  13. end
  14.  
  15. def remove_file(file)
  16.   if File.exist? file
  17.     File.unlink(file)
  18.   end
  19. end
  20.