mongoid-locker 0.3.0 → 0.3.1

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: a80f5cc223862e305b57a190f0713f9b40d98aa2
4
- data.tar.gz: 5e7b035e9de4e47acb180f8737aad225fef38170
3
+ metadata.gz: db96ccf9519cc4ef2df88bf968cfc40acd6d2ff7
4
+ data.tar.gz: 37d88ea39dbaec86ffe1be4ded07ad3fe1b47ac3
5
5
  SHA512:
6
- metadata.gz: 21b22b0c0e1902582d62565efa1ab8d38571960ab915756de31bd2ff9f021c5cab4e9e5bd49bffee967d392a0ef457e572c0a398db88560155124d9df29ffc62
7
- data.tar.gz: 582144c90fde1230f723f610f76153ffd475c1005fc5162891c88cd1ed38651e45f42432679a8b46b4682b9c08fe82f950a606128fadd03e7666efb51b4f03f0
6
+ metadata.gz: 8d3074ad2fcef9295c961924fde5d688bbede292f95fe3c0cc81ea155ab7f66659ab6ae13f080d4d4f6497b7dd528848b93ea6522be36cdd4cf6d4d7d2a0e757
7
+ data.tar.gz: 63bce2ad2b457225073b839744fbb6667f3e387f313d3a06095f35f4d9b0a4006328ac7b5c195c7a6869c6eb9041357050aff28a6baa6d5e86a8b8f410d91131
data/.rubocop.yml CHANGED
@@ -1,38 +1,7 @@
1
1
  AllCops:
2
- Excludes:
3
- - vendor/**
4
- - bin/**
2
+ Exclude:
3
+ - vendor/**/*
4
+ - bin/**/*
5
5
  - mongoid-locker.gemspec
6
6
 
7
- LineLength:
8
- Enabled: false
9
-
10
- MethodLength:
11
- Enabled: false
12
-
13
- ClassLength:
14
- Enabled: false
15
-
16
- Documentation:
17
- Enabled: false
18
-
19
- Encoding:
20
- Enabled: false
21
-
22
- Blocks:
23
- Enabled: false
24
-
25
- FileName:
26
- Enabled: false
27
-
28
- RaiseArgs:
29
- Enabled: false
30
-
31
- PredicateName:
32
- Enabled: false
33
-
34
- DoubleNegation:
35
- Enabled: false
36
-
37
- TrivialAccessors:
38
- Enabled: false
7
+ inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,58 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-03-12 10:43:25 -0400 using RuboCop version 0.29.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ Metrics/AbcSize:
10
+ Max: 18
11
+
12
+ # Offense count: 22
13
+ # Configuration parameters: AllowURI, URISchemes.
14
+ Metrics/LineLength:
15
+ Max: 184
16
+
17
+ # Offense count: 4
18
+ # Configuration parameters: CountComments.
19
+ Metrics/MethodLength:
20
+ Max: 25
21
+
22
+ # Offense count: 5
23
+ # Cop supports --auto-correct.
24
+ Style/Blocks:
25
+ Enabled: false
26
+
27
+ # Offense count: 3
28
+ Style/Documentation:
29
+ Enabled: false
30
+
31
+ # Offense count: 2
32
+ Style/DoubleNegation:
33
+ Enabled: false
34
+
35
+ # Offense count: 2
36
+ # Configuration parameters: Exclude.
37
+ Style/FileName:
38
+ Enabled: false
39
+
40
+ # Offense count: 1
41
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist.
42
+ Style/PredicateName:
43
+ Enabled: false
44
+
45
+ # Offense count: 1
46
+ # Configuration parameters: SupportedStyles.
47
+ Style/RaiseArgs:
48
+ EnforcedStyle: compact
49
+
50
+ # Offense count: 2
51
+ Style/RegexpLiteral:
52
+ MaxSlashes: 0
53
+
54
+ # Offense count: 1
55
+ # Cop supports --auto-correct.
56
+ # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
57
+ Style/TrivialAccessors:
58
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 ([diff](https://github.com/afeld/mongoid-locker/compare/v0.3.0...v0.3.1?w=1))
4
+
5
+ * fixed race condition, `undefined method '-' for nil:NilClass` - #18
6
+
3
7
  ## 0.3.0 ([diff](https://github.com/afeld/mongoid-locker/compare/v0.2.1...v0.3.0?w=1))
4
8
 
5
9
  * change exception class to be `Mongoid::Locker::LockError` - #8
data/Gemfile CHANGED
@@ -6,8 +6,8 @@ when /4/
6
6
  when /3/
7
7
  gem 'mongoid', '~> 3.1'
8
8
  when /2/
9
- gem 'bson_ext', :platforms => :ruby
10
- gem 'mongoid', '~> 2.4'
9
+ gem 'bson_ext', platforms: :ruby
10
+ gem 'mongoid', '~> 2.8'
11
11
  else
12
12
  gem 'mongoid', version
13
13
  end
@@ -23,5 +23,5 @@ end
23
23
 
24
24
  group :development, :test do
25
25
  gem 'rake'
26
- gem 'rubocop', '0.24.0'
26
+ gem 'rubocop', '0.29.1'
27
27
  end
data/Guardfile CHANGED
@@ -3,8 +3,8 @@
3
3
  guard 'rspec' do
4
4
  watch(%r{^spec/.+_spec\.rb$})
5
5
 
6
- watch('Gemfile') { "spec" }
7
- watch('Gemfile.lock') { "spec" }
8
- watch(%r{^lib/(.+)\.rb$}) { "spec" }
9
- watch('spec/spec_helper.rb') { "spec" }
6
+ watch('Gemfile') { 'spec' }
7
+ watch('Gemfile.lock') { 'spec' }
8
+ watch(%r{^lib/(.+)\.rb$}) { 'spec' }
9
+ watch('spec/spec_helper.rb') { 'spec' }
10
10
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -17,7 +17,7 @@ module Mongoid
17
17
  #
18
18
  # @return [Mongoid::Criteria]
19
19
  def unlocked
20
- any_of({ locked_until: nil }, { :locked_until.lte => Time.now })
20
+ any_of({ locked_until: nil }, :locked_until.lte => Time.now)
21
21
  end
22
22
 
23
23
  # Set the default lock timeout for this class. Note this only applies to new locks. Defaults to five seconds.
@@ -136,6 +136,8 @@ module Mongoid
136
136
  # if not passed a retry_sleep value, we sleep for the remaining life of the lock
137
137
  unless opts[:retry_sleep]
138
138
  locked_until = Mongoid::Locker::Wrapper.locked_until(self)
139
+ # the lock might be released since the last check so make another attempt
140
+ next unless locked_until
139
141
  retry_sleep = locked_until - Time.now
140
142
  end
141
143
 
@@ -2,15 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: mongoid-locker 0.3.0 ruby lib
5
+ # stub: mongoid-locker 0.3.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "mongoid-locker"
9
- s.version = "0.3.0"
9
+ s.version = "0.3.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
12
13
  s.authors = ["Aidan Feldman"]
13
- s.date = "2014-07-01"
14
+ s.date = "2015-03-16"
14
15
  s.description = "Allows multiple processes to operate on individual documents in MongoDB while ensuring that only one can act at a time."
15
16
  s.email = "aidan.feldman@gmail.com"
16
17
  s.extra_rdoc_files = [
@@ -21,6 +22,7 @@ Gem::Specification.new do |s|
21
22
  ".document",
22
23
  ".rspec",
23
24
  ".rubocop.yml",
25
+ ".rubocop_todo.yml",
24
26
  ".travis.yml",
25
27
  "CHANGELOG.md",
26
28
  "CONTRIBUTING.md",
@@ -48,8 +50,7 @@ Gem::Specification.new do |s|
48
50
  ]
49
51
  s.homepage = "http://github.com/afeld/mongoid-locker"
50
52
  s.licenses = ["MIT"]
51
- s.require_paths = ["lib"]
52
- s.rubygems_version = "2.1.11"
53
+ s.rubygems_version = "2.2.2"
53
54
  s.summary = "Document-level locking for MongoDB via Mongoid"
54
55
 
55
56
  if s.respond_to? :specification_version then
@@ -63,7 +64,7 @@ Gem::Specification.new do |s|
63
64
  s.add_development_dependency(%q<guard-rspec>, [">= 0"])
64
65
  s.add_development_dependency(%q<rb-fsevent>, ["~> 0.9.1"])
65
66
  s.add_development_dependency(%q<rake>, [">= 0"])
66
- s.add_development_dependency(%q<rubocop>, ["= 0.24.0"])
67
+ s.add_development_dependency(%q<rubocop>, ["= 0.29.1"])
67
68
  else
68
69
  s.add_dependency(%q<mongoid>, ["~> 4.0"])
69
70
  s.add_dependency(%q<rspec>, ["~> 3.0"])
@@ -72,7 +73,7 @@ Gem::Specification.new do |s|
72
73
  s.add_dependency(%q<guard-rspec>, [">= 0"])
73
74
  s.add_dependency(%q<rb-fsevent>, ["~> 0.9.1"])
74
75
  s.add_dependency(%q<rake>, [">= 0"])
75
- s.add_dependency(%q<rubocop>, ["= 0.24.0"])
76
+ s.add_dependency(%q<rubocop>, ["= 0.29.1"])
76
77
  end
77
78
  else
78
79
  s.add_dependency(%q<mongoid>, ["~> 4.0"])
@@ -82,7 +83,7 @@ Gem::Specification.new do |s|
82
83
  s.add_dependency(%q<guard-rspec>, [">= 0"])
83
84
  s.add_dependency(%q<rb-fsevent>, ["~> 0.9.1"])
84
85
  s.add_dependency(%q<rake>, [">= 0"])
85
- s.add_dependency(%q<rubocop>, ["= 0.24.0"])
86
+ s.add_dependency(%q<rubocop>, ["= 0.29.1"])
86
87
  end
87
88
  end
88
89
 
@@ -180,6 +180,18 @@ describe Mongoid::Locker do
180
180
  }.to raise_error(Mongoid::Locker::LockError)
181
181
  end
182
182
 
183
+ it 'does not fail if the lock has been released between check and sleep time calculation' do
184
+ allow(@user).to receive(:acquire_lock).and_return(false)
185
+ allow(Mongoid::Locker::Wrapper).to receive(:locked_until).and_return(nil)
186
+
187
+ expect(@user).to receive(:acquire_lock).exactly(2).times
188
+ expect {
189
+ @user.with_lock retries: 1 do
190
+ # no-op
191
+ end
192
+ }.to raise_error(Mongoid::Locker::LockError)
193
+ end
194
+
183
195
  it 'should, by default, when retrying, sleep until the lock expires' do
184
196
  allow(@user).to receive(:acquire_lock).and_return(false)
185
197
  allow(Mongoid::Locker::Wrapper).to receive(:locked_until).and_return(Time.now + 5.seconds)
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-locker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aidan Feldman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-01 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jeweler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.8'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rb-fsevent
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.9.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.9.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.24.0
117
+ version: 0.29.1
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.24.0
124
+ version: 0.29.1
125
125
  description: Allows multiple processes to operate on individual documents in MongoDB
126
126
  while ensuring that only one can act at a time.
127
127
  email: aidan.feldman@gmail.com
@@ -131,10 +131,11 @@ extra_rdoc_files:
131
131
  - LICENSE.txt
132
132
  - README.md
133
133
  files:
134
- - .document
135
- - .rspec
136
- - .rubocop.yml
137
- - .travis.yml
134
+ - ".document"
135
+ - ".rspec"
136
+ - ".rubocop.yml"
137
+ - ".rubocop_todo.yml"
138
+ - ".travis.yml"
138
139
  - CHANGELOG.md
139
140
  - CONTRIBUTING.md
140
141
  - Gemfile
@@ -168,17 +169,17 @@ require_paths:
168
169
  - lib
169
170
  required_ruby_version: !ruby/object:Gem::Requirement
170
171
  requirements:
171
- - - '>='
172
+ - - ">="
172
173
  - !ruby/object:Gem::Version
173
174
  version: '0'
174
175
  required_rubygems_version: !ruby/object:Gem::Requirement
175
176
  requirements:
176
- - - '>='
177
+ - - ">="
177
178
  - !ruby/object:Gem::Version
178
179
  version: '0'
179
180
  requirements: []
180
181
  rubyforge_project:
181
- rubygems_version: 2.1.11
182
+ rubygems_version: 2.2.2
182
183
  signing_key:
183
184
  specification_version: 4
184
185
  summary: Document-level locking for MongoDB via Mongoid