lockfile 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +8 -8
  2. data/lib/lockfile.rb +55 -41
  3. data/lockfile.gemspec +2 -2
  4. data/rakefile +2 -2
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGVhNzM3MjZiODUwOTIzMjAzNzgwMTdiN2Q5YzljMWM4NjYyOGIwZg==
4
+ ZjM2ODRmNTEyZTFhNjhkMjYwOGNmYTEyZTcyZDA0ZDRkOTIxZjNhMw==
5
5
  data.tar.gz: !binary |-
6
- YmI4MTdkNjUwZmFmY2RkOWI5OGJlYzE5YjJkNTAxY2JmOTc1NDg3Yw==
6
+ N2U4NTZmNmRhODY5YjQ2MWE2Mzk3NmI4YzcxMjJhN2VhNzVmMzU5MQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGFlYzJlNDY5MzljMGMxNjJmYjM2MWVjZWYyMTIwZjc3ZmQ2MGU2MTljN2Ix
10
- NzI3OGUwMjUzMGMwOTg4YjljN2EwNGMyNGQ0Y2YzYTZkZDZlNGUzODAxODM5
11
- OGEwZjE0MGY3ZTkzYmNiZDBkM2I5ZjVjNWNjZmY2MjAzYzA0MzQ=
9
+ MDNlNTJjZGIwOWMwMmU5YzJhNWE2YTI4YjQ3ZDgxNjA4MzAzNTM4Y2Q3OTFm
10
+ YTNjOGY1MDIwMTQzMWExYTFhZjc1MDMyMDdkOTg3MmVhNjY5MGVjZjhjM2Jk
11
+ MjgxN2E5MDMwNDFmNWM5ZDUxMDljNTk0YTEzMmQxMTViYmM2ZGM=
12
12
  data.tar.gz: !binary |-
13
- MTFmMDAxOTdlMWYxNDRjZmNlZDFhZTEyZWVlNTExNDU4MDkxMzdhNjU0NmI1
14
- MTQ2ZDdiNzg5ZWNiZTI4YWVlODE1NmU1MmMwNDU2ZDRhM2RkZDlkMzIwYmM5
15
- ZmY2ODczNWQ2MWRlYTRmMjVmMWE0MGZiNGU2MjVlZWUwZmJmMWQ=
13
+ N2FjYzk1MDk1ODY0ZDhhOWExNWJmZDA4ZTg3ZjdjM2FjYzMwYWE5ZWQyN2Vj
14
+ MTE3OWNlMWViMDRhNDI1ZmFmODcwYmEyMWQyMjZkNTI2Njk3MTg5MWMxZjI2
15
+ NjExNjE2NzMzNjUyM2Q1MjNlZTM1OTFjNzNmOWMxMmExMjNlNTg=
@@ -6,7 +6,7 @@ unless(defined?($__lockfile__) or defined?(Lockfile))
6
6
 
7
7
  class Lockfile
8
8
 
9
- VERSION = '2.1.2'
9
+ VERSION = '2.1.3'
10
10
  def Lockfile.version() Lockfile::VERSION end
11
11
  def version() Lockfile::VERSION end
12
12
 
@@ -24,10 +24,10 @@ unless(defined?($__lockfile__) or defined?(Lockfile))
24
24
  class UnLockError < LockError; end
25
25
 
26
26
  class SleepCycle < Array
27
- attr :min
28
- attr :max
29
- attr :range
30
- attr :inc
27
+ attr_reader :min
28
+ attr_reader :max
29
+ attr_reader :range
30
+ attr_reader :inc
31
31
 
32
32
  def initialize(min, max, inc)
33
33
  @min, @max, @inc = Float(min), Float(max), Float(inc)
@@ -72,20 +72,20 @@ unless(defined?($__lockfile__) or defined?(Lockfile))
72
72
  DEFAULT_DEBUG = ENV['LOCKFILE_DEBUG'] || false
73
73
 
74
74
  class << Lockfile
75
- attr :retries, true
76
- attr :max_age, true
77
- attr :sleep_inc, true
78
- attr :min_sleep, true
79
- attr :max_sleep, true
80
- attr :suspend, true
81
- attr :timeout, true
82
- attr :refresh, true
83
- attr :debug, true
84
- attr :dont_clean, true
85
- attr :poll_retries, true
86
- attr :poll_max_sleep, true
87
- attr :dont_sweep, true
88
- attr :dont_use_lock_id, true
75
+ attr_accessor :retries
76
+ attr_accessor :max_age
77
+ attr_accessor :sleep_inc
78
+ attr_accessor :min_sleep
79
+ attr_accessor :max_sleep
80
+ attr_accessor :suspend
81
+ attr_accessor :timeout
82
+ attr_accessor :refresh
83
+ attr_accessor :debug
84
+ attr_accessor :dont_clean
85
+ attr_accessor :poll_retries
86
+ attr_accessor :poll_max_sleep
87
+ attr_accessor :dont_sweep
88
+ attr_accessor :dont_use_lock_id
89
89
 
90
90
  def init
91
91
  @retries = DEFAULT_RETRIES
@@ -111,28 +111,28 @@ unless(defined?($__lockfile__) or defined?(Lockfile))
111
111
 
112
112
  Lockfile.init
113
113
 
114
- attr :klass
115
- attr :path
116
- attr :opts
117
- attr :locked
118
- attr :thief
119
- attr :refresher
120
- attr :dirname
121
- attr :basename
122
- attr :clean
123
- attr :retries
124
- attr :max_age
125
- attr :sleep_inc
126
- attr :min_sleep
127
- attr :max_sleep
128
- attr :suspend
129
- attr :refresh
130
- attr :timeout
131
- attr :dont_clean
132
- attr :poll_retries
133
- attr :poll_max_sleep
134
- attr :dont_sweep
135
- attr :dont_use_lock_id
114
+ attr_reader :klass
115
+ attr_reader :path
116
+ attr_reader :opts
117
+ attr_reader :locked
118
+ attr_reader :thief
119
+ attr_reader :refresher
120
+ attr_reader :dirname
121
+ attr_reader :basename
122
+ attr_reader :clean
123
+ attr_reader :retries
124
+ attr_reader :max_age
125
+ attr_reader :sleep_inc
126
+ attr_reader :min_sleep
127
+ attr_reader :max_sleep
128
+ attr_reader :suspend
129
+ attr_reader :refresh
130
+ attr_reader :timeout
131
+ attr_reader :dont_clean
132
+ attr_reader :poll_retries
133
+ attr_reader :poll_max_sleep
134
+ attr_reader :dont_sweep
135
+ attr_reader :dont_use_lock_id
136
136
 
137
137
  attr_accessor :debug
138
138
 
@@ -195,6 +195,20 @@ unless(defined?($__lockfile__) or defined?(Lockfile))
195
195
  lock(&block) if block
196
196
  end
197
197
 
198
+ ##
199
+ # Executes the given block after acquiring the lock and
200
+ # ensures that the lock is relinquished afterwards.
201
+ #
202
+ def synchronize
203
+ raise ArgumentError, 'block must be given' unless block_given?
204
+ begin
205
+ lock
206
+ yield
207
+ ensure
208
+ unlock
209
+ end
210
+ end
211
+
198
212
  def lock
199
213
  raise StackingLockError, "<#{ @path }> is locked!" if @locked
200
214
 
@@ -3,11 +3,11 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "lockfile"
6
- spec.version = "2.1.2"
6
+ spec.version = "2.1.3"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "lockfile"
9
9
  spec.description = "a ruby library for creating perfect and NFS safe lockfiles"
10
- spec.license = "same as ruby's"
10
+ spec.license = "Ruby"
11
11
 
12
12
  spec.files =
13
13
  ["README",
data/rakefile CHANGED
@@ -4,7 +4,7 @@ This.email = "ara.t.howard@gmail.com"
4
4
  This.homepage = "https://github.com/ahoward/#{ This.lib }"
5
5
 
6
6
  task :license do
7
- open('LICENSE', 'w'){|fd| fd.puts "same as ruby's"}
7
+ open('LICENSE', 'w'){|fd| fd.puts "Ruby"}
8
8
  end
9
9
 
10
10
  task :default do
@@ -93,7 +93,7 @@ task :gemspec do
93
93
  test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
94
94
  summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
95
95
  description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
96
- license = object.respond_to?(:license) ? object.license : "same as ruby's"
96
+ license = object.respond_to?(:license) ? object.license : "Ruby"
97
97
 
98
98
  if This.extensions.nil?
99
99
  This.extensions = []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-22 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: a ruby library for creating perfect and NFS safe lockfiles
14
14
  email: ara.t.howard@gmail.com
@@ -32,7 +32,7 @@ files:
32
32
  - samples/out
33
33
  homepage: https://github.com/ahoward/lockfile
34
34
  licenses:
35
- - same as ruby's
35
+ - Ruby
36
36
  metadata: {}
37
37
  post_install_message:
38
38
  rdoc_options: []