filelock 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4d5bba388f19de54cba97e0af369c8c18764bb5
4
- data.tar.gz: 5a42b3b0e31fd1f9b2f02d1f1eef513a9112244e
3
+ metadata.gz: 8306638bf16d2c4aa3be2543c24d68e0a673fd31
4
+ data.tar.gz: 8d19eb1e21833db47e8b7fe67f36915482a5b6ce
5
5
  SHA512:
6
- metadata.gz: cd10b0613b05bff7c4d9eb70985e9ffe1e3236d9e6a8f84d9d1cc77af3486bc1767c91a0345abfe551924a8d0bce088401c34ce9c0adb681dd663f8f087795d4
7
- data.tar.gz: 9d4f60be252ceb0be614e8f6a701493aeff105db1b9e77c3c68c97dfe6d3756a44265985e62f3a3f32d1b593a7ea26afe2a2e73d5901a3eed2ecdfa331b99aec
6
+ metadata.gz: 2042a3b18be5cd3045051369501b5a50437e407841050d7c637254b0858a97a555160f19d91e7b2feb507e6e350fad9dc2561ace97d614eb7c918dc992bb197e
7
+ data.tar.gz: 08a2351b10bd4c078d513e98c8a9db180b964b877d7f8ab0a5a27f2851b5eed0e48f6aaf6522fe443e7c57d43e1fb2fc8a160c904a417c965e74cb5694927db1
@@ -1,7 +1,12 @@
1
+ # 1.1.1
2
+
3
+ - fix: Load timeout module before using it
4
+ - pass locked file to block provided to Filelock
5
+
1
6
  # 1.1.0
2
7
 
3
8
  - Add `:wait` flag for lock-acquiting timeout
4
- - Add two new timeout exteptions: `FileLock::ExecTimeout` and `FileLock::WaitTimeout`
9
+ - Add two new timeout exceptions: `FileLock::ExecTimeout` and `FileLock::WaitTimeout`
5
10
 
6
11
  # 1.0.3
7
12
 
data/README.md CHANGED
@@ -43,6 +43,16 @@ You can detect this kind of timeout by catching `Filelock::WaitTimeout`.
43
43
 
44
44
  Note that lock file directory must already exist, and lock file is not removed after unlock.
45
45
 
46
+ ### Getting handle to locked file
47
+
48
+
49
+ ```ruby
50
+ Filelock '/tmp/path/to/lock' do |file|
51
+ file.truncate
52
+ file.write Process.pid
53
+ end
54
+ ```
55
+
46
56
  ## FAQ
47
57
 
48
58
  *Does it support NFS?*
@@ -1,7 +1,7 @@
1
+ require 'timeout'
1
2
  require 'filelock/version'
2
3
  require 'filelock/exec_timeout'
3
4
  require 'filelock/wait_timeout'
4
- require 'timeout'
5
5
  require 'tempfile'
6
6
 
7
7
  if RUBY_PLATFORM == "java"
@@ -9,7 +9,7 @@ if RUBY_PLATFORM == "java"
9
9
  lockname = lockname.path if lockname.is_a?(Tempfile)
10
10
  File.open(lockname, File::RDWR|File::CREAT, 0644) do |file|
11
11
  Thread.pass until Timeout::timeout(options.fetch(:wait, 60*60*24), Filelock::WaitTimeout) { file.flock(File::LOCK_EX) }
12
- Timeout::timeout(options.fetch(:timeout, 60), Filelock::ExecTimeout) { yield }
12
+ Timeout::timeout(options.fetch(:timeout, 60), Filelock::ExecTimeout) { yield file }
13
13
  end
14
14
  end
15
15
  else
@@ -17,7 +17,7 @@ else
17
17
  lockname = lockname.path if lockname.is_a?(Tempfile)
18
18
  File.open(lockname, File::RDWR|File::CREAT, 0644) do |file|
19
19
  Timeout::timeout(options.fetch(:wait, 60*60*24), Filelock::WaitTimeout) { file.flock(File::LOCK_EX) }
20
- Timeout::timeout(options.fetch(:timeout, 60), Filelock::ExecTimeout) { yield }
20
+ Timeout::timeout(options.fetch(:timeout, 60), Filelock::ExecTimeout) { yield file }
21
21
  end
22
22
  end
23
23
  end
@@ -1,3 +1,3 @@
1
1
  module Filelock
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -59,6 +59,17 @@ describe Filelock do
59
59
  end
60
60
  end
61
61
 
62
+ it 'passes handle to block' do
63
+ Dir.mktmpdir do |dir|
64
+ lockpath = File.join(dir, 'sample.lock')
65
+ Filelock lockpath do |lock|
66
+ lock.write '42'
67
+ end
68
+
69
+ expect(File.read(File.join(dir,'sample.lock'))).to eq('42')
70
+ end
71
+ end
72
+
62
73
  it 'runs in parallel without race condition' do
63
74
  answer = 0
64
75
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filelock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stankiewicz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-06 00:00:00.000000000 Z
11
+ date: 2016-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler