diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb index 55920a4..a44bd19 100644 --- a/lib/tmpdir.rb +++ b/lib/tmpdir.rb @@ -12,14 +12,14 @@ end class Dir - - @@systmpdir ||= defined?(Etc.systmpdir) ? Etc.systmpdir : '/tmp' + SYSTMPDIR = defined?(Etc.systmpdir) ? Etc.systmpdir.dup.freeze : '/tmp' + private_constant :SYSTMPDIR ## # Returns the operating system's temporary file path. def self.tmpdir - ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @@systmpdir], ['/tmp']*2, ['.']*2].find do |name, dir| + ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', SYSTMPDIR], ['/tmp']*2, ['.']*2].find do |name, dir| unless dir next if !(dir = ENV[name]) or dir.empty? end