Method: Object#tmp

Defined in:
lib/mspec/helpers/tmp.rb

#tmp(name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mspec/helpers/tmp.rb', line 17

def tmp(name)
  unless @spec_temp_directory
    [ "/private/tmp", "/tmp", "/var/tmp", ENV["TMPDIR"], ENV["TMP"],
      ENV["TEMP"], ENV["USERPROFILE"] ].each do |dir|
      if dir and File.directory?(dir) and File.writable?(dir)
        temp = File.expand_path dir
        temp = File.readlink temp if File.symlink? temp
        @spec_temp_directory = temp
        break
      end
    end
  end

  File.join @spec_temp_directory, name
end