Sha256: 3738940bc5db47acb3f7daee803de7b48760a9fdc1e28b39df7ba0811889efbf
Contents?: true
Size: 1022 Bytes
Versions: 132
Compression:
Stored size: 1022 Bytes
Contents
# The #tmp method provides a similar functionality # to that of Dir.tmpdir. This helper can be overridden # by different implementations to provide a more useful # behavior if needed. # # Usage in a spec: # # File.open(tmp("tags.txt"), "w") { |f| f.puts "" } # # The order of directories below with "/private/tmp" # preceding "/tmp" is significant. On OS X, the directory # "/tmp" is a symlink to "private/tmp" with no leading # "/". Rather than futzing with what constitutes an # absolute path, we just look for "/private/tmp" first. class Object 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 end
Version data entries
132 entries across 108 versions & 3 rubygems