active_record_mutex 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/active_record_mutex.gemspec +6 -3
- data/lib/active_record/database_mutex/implementation.rb +20 -2
- data/lib/active_record/database_mutex/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 624916896cfdc77c6a74fde8700a9b07ff587250
|
4
|
+
data.tar.gz: dea7261a14573e0202de967869d123b473785d86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa68c4dd7ba5c49f7a17fabdb17afbbdf7943e994fea75c1d6b61aeed001a1793326b69bc24b5422987c84dfe573a803d87642539516050607bd141a70f7ea57
|
7
|
+
data.tar.gz: 4d86b6ebca7510b1f9f4276c1380a7a16655404ed57f91b6c1f3038a827d8e260daa2407dceddf63e309fa22230a37f062586f2ac3dd9e92eee850cad25602c2
|
data/Rakefile
CHANGED
@@ -17,9 +17,10 @@ GemHadar do
|
|
17
17
|
readme 'README.md'
|
18
18
|
licenses << 'GPL-2'
|
19
19
|
|
20
|
-
dependency 'mysql2',
|
20
|
+
dependency 'mysql2', '~>0.3.0'
|
21
21
|
dependency 'activerecord', '~> 4.0'
|
22
|
-
|
22
|
+
dependency 'tins', '~> 1.12.0'
|
23
|
+
development_dependency 'test-unit', '~>3.0'
|
23
24
|
development_dependency 'byebug'
|
24
25
|
development_dependency 'simplecov'
|
25
26
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.3
|
data/active_record_mutex.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: active_record_mutex 2.3.
|
2
|
+
# stub: active_record_mutex 2.3.3 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "active_record_mutex"
|
6
|
-
s.version = "2.3.
|
6
|
+
s.version = "2.3.3"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Florian Frank"]
|
11
|
-
s.date = "2016-08-
|
11
|
+
s.date = "2016-08-24"
|
12
12
|
s.description = "Mutex that can be used to synchronise ruby processes via an ActiveRecord datababase connection. (Only Mysql is supported at the moment.)"
|
13
13
|
s.email = "flori@ping.de"
|
14
14
|
s.extra_rdoc_files = ["README.md", "lib/active_record/database_mutex.rb", "lib/active_record/database_mutex/implementation.rb", "lib/active_record/database_mutex/version.rb", "lib/active_record/mutex.rb", "lib/active_record_mutex.rb"]
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
31
31
|
s.add_runtime_dependency(%q<mysql2>, ["~> 0.3.0"])
|
32
32
|
s.add_runtime_dependency(%q<activerecord>, ["~> 4.0"])
|
33
|
+
s.add_runtime_dependency(%q<tins>, ["~> 1.12.0"])
|
33
34
|
else
|
34
35
|
s.add_dependency(%q<gem_hadar>, ["~> 1.7.1"])
|
35
36
|
s.add_dependency(%q<test-unit>, ["~> 3.0"])
|
@@ -37,6 +38,7 @@ Gem::Specification.new do |s|
|
|
37
38
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
38
39
|
s.add_dependency(%q<mysql2>, ["~> 0.3.0"])
|
39
40
|
s.add_dependency(%q<activerecord>, ["~> 4.0"])
|
41
|
+
s.add_dependency(%q<tins>, ["~> 1.12.0"])
|
40
42
|
end
|
41
43
|
else
|
42
44
|
s.add_dependency(%q<gem_hadar>, ["~> 1.7.1"])
|
@@ -45,5 +47,6 @@ Gem::Specification.new do |s|
|
|
45
47
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
46
48
|
s.add_dependency(%q<mysql2>, ["~> 0.3.0"])
|
47
49
|
s.add_dependency(%q<activerecord>, ["~> 4.0"])
|
50
|
+
s.add_dependency(%q<tins>, ["~> 1.12.0"])
|
48
51
|
end
|
49
52
|
end
|
@@ -1,8 +1,26 @@
|
|
1
1
|
require 'base64'
|
2
|
+
require 'tins/xt/string_version'
|
2
3
|
|
3
4
|
module ActiveRecord
|
4
5
|
module DatabaseMutex
|
5
6
|
class Implementation
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def db
|
10
|
+
ActiveRecord::Base.connection
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_size?
|
14
|
+
if defined? @check_size
|
15
|
+
@check_size
|
16
|
+
else
|
17
|
+
version = db.execute("SHOW VARIABLES LIKE 'version'").first.last.
|
18
|
+
delete('^0-9.').version
|
19
|
+
@check_size = version >= '5.7'.version
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
6
24
|
# Creates a mutex with the name given with the option :name.
|
7
25
|
def initialize(opts = {})
|
8
26
|
@name = opts[:name] or raise ArgumentError, "mutex requires a :name argument"
|
@@ -121,7 +139,7 @@ module ActiveRecord
|
|
121
139
|
def counter
|
122
140
|
encoded_name = ?$ + Base64.encode64(name).delete('^A-Za-z0-9+/').
|
123
141
|
gsub(/[+\/]/, ?+ => ?_, ?/ => ?.)
|
124
|
-
if encoded_name.size <= 64 # mysql 5.7 only allows size <=64 variable names
|
142
|
+
if !self.class.check_size? || encoded_name.size <= 64 # mysql 5.7 only allows size <=64 variable names
|
125
143
|
"@#{encoded_name}"
|
126
144
|
end
|
127
145
|
end
|
@@ -161,7 +179,7 @@ module ActiveRecord
|
|
161
179
|
end
|
162
180
|
|
163
181
|
def query(sql)
|
164
|
-
if result =
|
182
|
+
if result = self.class.db.execute(sql)
|
165
183
|
result = result.first.first.to_i
|
166
184
|
$DEBUG and warn %{query("#{sql}") = #{result}}
|
167
185
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_mutex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '4.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: tins
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.12.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.12.0
|
97
111
|
description: Mutex that can be used to synchronise ruby processes via an ActiveRecord
|
98
112
|
datababase connection. (Only Mysql is supported at the moment.)
|
99
113
|
email: flori@ping.de
|