suo 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad72e1c0045977e0ccffb7a56d1d652f3ca12fc8
4
- data.tar.gz: b715298aacc8f3f7773103d0f7a7086ece89ef32
3
+ metadata.gz: 20c696b1f0967a3f064e80bb245266608465aa17
4
+ data.tar.gz: f5da2c07382f9a0ce9779e13cd508d0044d8f4c1
5
5
  SHA512:
6
- metadata.gz: ebc31f887ba239304901a342b33c0ec8a6065204b46eb923087524e2d23579dfce42f73ee7220f317ffa9b032e474c08f085b1693023148c2cc9b20c8569d4c9
7
- data.tar.gz: 9acbeeac7c2dca1ffec0807ebd8aaf56fa1b53f7c7f300f45fd52b0e68e8638506d1622c6b506cf0455a22ed8aafa177b975961e5fb623387be5bfe6fccff531
6
+ metadata.gz: 8651a6d683fea5f48b89fbd1d7d101b8627a7475bc9ac17dfe4d1c48c2725a4d28428661ab05682b13721c694343960574cfde5511ce4f1e79812ec078b2a4f6
7
+ data.tar.gz: 274fe4e9a3d2048e33276502c15fe9cee6e33e2fbaeec59e70845e8a0783d1df6cbf5cbab7883e9cc2b3be36d885bb03f8cae0276537f4e5bb83134555cd67be
@@ -74,7 +74,7 @@ Style/SpaceInsideBrackets:
74
74
  Style/AndOr:
75
75
  Enabled: false
76
76
 
77
- Style/TrailingComma:
77
+ Style/TrailingCommaInLiteral:
78
78
  Enabled: true
79
79
 
80
80
  Style/SpaceBeforeComma:
@@ -98,7 +98,7 @@ Style/SpaceAfterColon:
98
98
  Style/SpaceAfterComma:
99
99
  Enabled: true
100
100
 
101
- Style/SpaceAfterControlKeyword:
101
+ Style/SpaceAroundKeyword:
102
102
  Enabled: true
103
103
 
104
104
  Style/SpaceAfterNot:
@@ -163,7 +163,7 @@ Style/StringLiterals:
163
163
  EnforcedStyle: double_quotes
164
164
 
165
165
  Metrics/CyclomaticComplexity:
166
- Max: 8
166
+ Max: 10
167
167
 
168
168
  Metrics/LineLength:
169
169
  Max: 128
@@ -214,3 +214,6 @@ Metrics/ParameterLists:
214
214
 
215
215
  Metrics/PerceivedComplexity:
216
216
  Enabled: false
217
+
218
+ Style/Documentation:
219
+ Enabled: false
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.0
4
+ - 2.3.1
4
5
  services:
5
6
  - memcached
6
7
  - redis-server
@@ -1,3 +1,7 @@
1
+ ## 0.3.2
2
+
3
+ - Custom lock tokens (thanks to avokhmin).
4
+
1
5
  ## 0.3.1
2
6
 
3
7
  - Slight memory leak fix.
@@ -26,8 +26,8 @@ module Suo
26
26
  super() # initialize Monitor mixin for thread safety
27
27
  end
28
28
 
29
- def lock
30
- token = acquire_lock
29
+ def lock(custom_token = nil)
30
+ token = acquire_lock(custom_token)
31
31
 
32
32
  if block_given? && token
33
33
  begin
@@ -95,8 +95,8 @@ module Suo
95
95
 
96
96
  attr_accessor :retry_count
97
97
 
98
- def acquire_lock
99
- token = SecureRandom.base64(16)
98
+ def acquire_lock(token = nil)
99
+ token ||= SecureRandom.base64(16)
100
100
 
101
101
  retry_with_timeout do
102
102
  val, cas = get
@@ -1,3 +1,3 @@
1
1
  module Suo
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2".freeze
3
3
  end
@@ -31,6 +31,12 @@ module ClientTests
31
31
  assert_equal false, locked
32
32
  end
33
33
 
34
+ def test_lock_with_custom_token
35
+ token = 'foo-bar'
36
+ lock = @client.lock token
37
+ assert_equal lock, token
38
+ end
39
+
34
40
  def test_empty_lock_on_invalid_data
35
41
  @client.send(:initial_set, "bad value")
36
42
  assert_equal false, @client.locked?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Elser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dalli
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  requirements: []
172
172
  rubyforge_project:
173
- rubygems_version: 2.4.5
173
+ rubygems_version: 2.5.1
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Distributed locks (mutexes & semaphores) using Memcached or Redis.