barron 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'barron'
7
- s.version = '0.1.0'
7
+ s.version = '0.1.1'
8
8
  s.date = '2012-01-04'
9
9
 
10
10
  s.summary = "Barron helps you with locking"
data/bin/barron CHANGED
@@ -34,6 +34,10 @@ opts = OptionParser.new do |opts|
34
34
  options[:block] = true
35
35
  end
36
36
 
37
+ opts.on("--silent", "Don't make any noise") do
38
+ options[:silent] = true
39
+ end
40
+
37
41
  opts.on("--version", "Display current version") do
38
42
  puts "Spinto " + Spinto::VERSION
39
43
  exit 0
@@ -49,19 +53,19 @@ case ARGV.size
49
53
  when 1
50
54
  resource = ARGV[0]
51
55
  else
52
- puts "Invalid options. Run `barron --help` for assistance."
56
+ $stderr.puts "Invalid options. Run `barron --help` for assistance." unless options[:silent]
53
57
  exit(1)
54
58
  end
55
59
 
56
60
  # Fire the lock, return success if it is free,
57
61
  # or hang until it is free.
58
62
  Barron.lock resource, options do
59
- $stdout.puts "Requested resource is free."
63
+ $stdout.puts "Requested resource is free." unless options[:silent]
60
64
  exit(0)
61
65
  end
62
66
 
63
67
  # Unless barron was told to hang, we will pass
64
68
  # through to here when barron cannot get a lock.
65
69
  # So return failue.
66
- $stderr.puts "Requested resource is being used."
70
+ $stderr.puts "Requested resource is being used." unless options[:silent]
67
71
  exit(1)
@@ -1,7 +1,7 @@
1
1
  module Barron
2
2
  require 'barron/tmpfile'
3
3
 
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
 
6
6
  def lock *args, &block
7
7
  Barron.lock *args, &block
@@ -14,8 +14,16 @@ module Barron::Tmpfile
14
14
  begin
15
15
  if options[:block]
16
16
  f.flock(File::LOCK_EX)
17
+ begin
18
+ f.chmod(0666)
19
+ rescue Errno::EPERM
20
+ end
17
21
  value = yield f
18
22
  elsif f.flock(File::LOCK_EX|File::LOCK_NB)
23
+ begin
24
+ f.chmod(0666)
25
+ rescue Errno::EPERM
26
+ end
19
27
  value = yield f
20
28
  end
21
29
  ensure
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barron
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthew Beale