pidlock 0.1.0 → 0.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.
data/lib/pidlock.rb CHANGED
@@ -21,7 +21,7 @@ class Pidlock
21
21
  unless (File.writable?(File.dirname(@filename)))
22
22
  @filename = File.join('/', 'tmp', @name)
23
23
  end
24
- @file = File.open(@filename, 'w+')
24
+ @file = File.open(@filename, 'r+')
25
25
  if (old_pid = @file.gets)
26
26
  if (old_process = Sys::ProcTable.ps(old_pid.chomp.to_i))
27
27
  raise ProcessRunning if old_process.comm == File.basename(@name, File.extname(@name))
@@ -9,7 +9,7 @@ describe Pidlock do
9
9
  @file.stub(:flock => 0)
10
10
  @file.stub(:flush)
11
11
  @file.stub(:gets)
12
- File.stub(:open).with('/var/run/my.pid', 'w+').and_return(@file)
12
+ File.stub(:open).with('/var/run/my.pid', 'r+').and_return(@file)
13
13
  File.stub(:writable?).with('/var/run').and_return(true)
14
14
  Logger.stub!(:new => logger)
15
15
  end
@@ -26,7 +26,7 @@ describe Pidlock do
26
26
  Pidlock.new('my.pid').lock
27
27
  end
28
28
  it "uses a directory under /var/run if given" do
29
- File.should_receive(:open).with("/var/run/my/my.pid", 'w+').and_return(@file)
29
+ File.should_receive(:open).with("/var/run/my/my.pid", 'r+').and_return(@file)
30
30
  File.should_receive(:writable?).with("/var/run/my").and_return(true)
31
31
  @file.should_receive(:write).with(666)
32
32
  Pidlock.new('my/my.pid').lock
@@ -61,7 +61,7 @@ describe Pidlock do
61
61
 
62
62
  it "uses /tmp if /var/run is not writeable" do
63
63
  File.should_receive(:writable?).with('/var/run').and_return(false)
64
- File.should_receive(:open).with('/tmp/my.pid', 'w+').and_return(@file)
64
+ File.should_receive(:open).with('/tmp/my.pid', 'r+').and_return(@file)
65
65
  Pidlock.new('my.pid').lock
66
66
  end
67
67
  it "warns but continue if the file exists but the process name does not" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pidlock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-27 00:00:00.000000000 Z
12
+ date: 2013-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sys-proctable
@@ -58,9 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  version: '0'
59
59
  requirements: []
60
60
  rubyforge_project:
61
- rubygems_version: 1.8.24
61
+ rubygems_version: 1.8.25
62
62
  signing_key:
63
63
  specification_version: 3
64
64
  summary: Using PID/file locking for daemons and long running tasks made easy.
65
65
  test_files: []
66
- has_rdoc: