Skip to content

Commit

Permalink
Merge pull request assaf#31 from langhorst/master
Browse files Browse the repository at this point in the history
For issue assaf#30, use Dir.tmpdir instead of hardcoded /var/tmp path
  • Loading branch information
assaf committed Feb 18, 2013
2 parents ae6699a + 4f5bd9c commit eaba877
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Expand Up @@ -62,7 +62,7 @@ first used by the application, to prevent multiple processes from
generating the same set of identifiers, and deal with changes to the
system clock.

The UUID state file is created in <tt>/var/tmp/ruby-uuid</tt> or the Windows
The UUID state file is created in <tt>#Dir.tmpdir/ruby-uuid</tt> or the Windows
common application data directory using mode 0644. If that directory is not
writable, the file is created as <tt>.ruby-uuid</tt> in the home directory.
If you need to create the file with a different mode, use UUID#state_file
Expand Down
4 changes: 2 additions & 2 deletions lib/uuid.rb
Expand Up @@ -146,7 +146,7 @@ def self.server=(address)
end

##
# Creates an empty state file in /var/tmp/ruby-uuid or the windows common
# Creates an empty state file in #Dir.tmpdir/ruby-uuid or the windows common
# application data directory using mode 0644. Call with a different mode
# before creating a UUID generator if you want to open access beyond your
# user by default.
Expand All @@ -169,7 +169,7 @@ def self.state_file(mode = 0644)

state_dir = File.join(path.strip)
rescue LoadError
state_dir = File.join('', 'var', 'tmp')
state_dir = Dir.tmpdir
end

@state_file = File.join(state_dir, 'ruby-uuid')
Expand Down
2 changes: 1 addition & 1 deletion test/test-uuid.rb
Expand Up @@ -39,7 +39,7 @@ def test_state_file_specify

def test_mode_is_set_on_state_file_specify
UUID.class_eval{ @state_file = nil; @mode = nil }
path = File.join("/tmp", "ruby-uuid-test")
path = File.join(Dir.tmpdir, "ruby-uuid-test")
File.delete path if File.exist?(path)

UUID.state_file = path
Expand Down

0 comments on commit eaba877

Please sign in to comment.