mongo-lock 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +22 -0
- data/README.md +291 -0
- data/Rakefile +8 -0
- data/lib/mongo-lock.rb +296 -0
- data/lib/mongo-lock/configuration.rb +72 -0
- data/lib/mongo-lock/version.rb +5 -0
- data/mongo-lock.gemspec +30 -0
- data/mongoid.yml +6 -0
- data/spec/acquire_spec.rb +184 -0
- data/spec/acquired_spec.rb +52 -0
- data/spec/available_spec.rb +68 -0
- data/spec/clear_expired_spec.rb +20 -0
- data/spec/configuration_spec.rb +238 -0
- data/spec/configure_spec.rb +87 -0
- data/spec/ensure_indexes_spec.rb +25 -0
- data/spec/expired_spec.rb +40 -0
- data/spec/extend_by_spec.rb +133 -0
- data/spec/initialise_spec.rb +36 -0
- data/spec/release_all_spec.rb +78 -0
- data/spec/release_spec.rb +164 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/support/mongo_helper.rb +19 -0
- metadata +141 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'mongo-lock'
|
2
|
+
require 'mongo'
|
3
|
+
require 'active_support/core_ext/numeric/time'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
|
7
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
config.expect_with :rspec do |c|
|
10
|
+
c.syntax = :expect
|
11
|
+
end
|
12
|
+
config.order = :random
|
13
|
+
config.color = true
|
14
|
+
config.formatter = "Fuubar"
|
15
|
+
config.filter_run_excluding :wip => true
|
16
|
+
|
17
|
+
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f }
|
18
|
+
|
19
|
+
require 'pry'
|
20
|
+
|
21
|
+
include MongoHelper
|
22
|
+
|
23
|
+
config.before :each do
|
24
|
+
database.drop_collection("locks")
|
25
|
+
database.drop_collection("other_locks")
|
26
|
+
Mongo::Lock.configure collection: collection
|
27
|
+
end
|
28
|
+
|
29
|
+
config.after :each do
|
30
|
+
end
|
31
|
+
|
32
|
+
config.after :suite do
|
33
|
+
# connection.drop_database("mongo_lock_tests")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module MongoHelper
|
2
|
+
|
3
|
+
def connection
|
4
|
+
@connection ||= Mongo::Connection.new("localhost")
|
5
|
+
end
|
6
|
+
|
7
|
+
def database
|
8
|
+
@database ||= connection.db("mongo_lock_tests")
|
9
|
+
end
|
10
|
+
|
11
|
+
def collection
|
12
|
+
@collection ||= database.collection :locks
|
13
|
+
end
|
14
|
+
|
15
|
+
def other_collection
|
16
|
+
@other_collection ||= database.collection :other_locks
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongo-lock
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matthew Spence
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fuubar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Key based pessimistic locking for Ruby and MongoDB. Is this key avaliable?
|
70
|
+
Yes - Lock it for me for a sec will you. No - OK I'll just wait here until its ready.
|
71
|
+
email: msaspence@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- README.md
|
76
|
+
- LICENSE
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/mongo-lock.rb
|
85
|
+
- lib/mongo-lock/configuration.rb
|
86
|
+
- lib/mongo-lock/version.rb
|
87
|
+
- mongo-lock.gemspec
|
88
|
+
- mongoid.yml
|
89
|
+
- spec/acquire_spec.rb
|
90
|
+
- spec/acquired_spec.rb
|
91
|
+
- spec/available_spec.rb
|
92
|
+
- spec/clear_expired_spec.rb
|
93
|
+
- spec/configuration_spec.rb
|
94
|
+
- spec/configure_spec.rb
|
95
|
+
- spec/ensure_indexes_spec.rb
|
96
|
+
- spec/expired_spec.rb
|
97
|
+
- spec/extend_by_spec.rb
|
98
|
+
- spec/initialise_spec.rb
|
99
|
+
- spec/release_all_spec.rb
|
100
|
+
- spec/release_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
- spec/support/mongo_helper.rb
|
103
|
+
homepage: https://github.com/trakio/mongo-lock
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.3.6
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.0.6
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Pessimistic locking for Ruby and MongoDB
|
127
|
+
test_files:
|
128
|
+
- spec/acquire_spec.rb
|
129
|
+
- spec/acquired_spec.rb
|
130
|
+
- spec/available_spec.rb
|
131
|
+
- spec/clear_expired_spec.rb
|
132
|
+
- spec/configuration_spec.rb
|
133
|
+
- spec/configure_spec.rb
|
134
|
+
- spec/ensure_indexes_spec.rb
|
135
|
+
- spec/expired_spec.rb
|
136
|
+
- spec/extend_by_spec.rb
|
137
|
+
- spec/initialise_spec.rb
|
138
|
+
- spec/release_all_spec.rb
|
139
|
+
- spec/release_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- spec/support/mongo_helper.rb
|