lib/aead/nonce.rb in aead-1.6.1 vs lib/aead/nonce.rb in aead-1.6.2
- old
+ new
@@ -49,11 +49,11 @@
#
# @param [String] file the tempfile to use
#
def self.stub_for_testing!(file = Tempfile.new('ruby-aead'))
define_method :state_file_with_stub_for_testing do
- path = file.path rescue file.to_s
+ path = file.respond_to?(:path) ? file.path : file.to_s
path = Pathname.new(path)
@state_file_stubbed_for_testing ||= Pathname.new(path)
end
@@ -205,10 +205,10 @@
end
private
def open_state_file
- self.state_file.open(File::RDWR) do |io|
+ self.state_file.open('r+b') do |io|
begin
io.flock File::LOCK_EX
yield io
ensure
io.flush