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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aafe3c705988ad9cab9db8346d85935f1b94de2c
4
- data.tar.gz: be7b71975f7740d6adaac306fa64fad71305a1d6
3
+ metadata.gz: 624916896cfdc77c6a74fde8700a9b07ff587250
4
+ data.tar.gz: dea7261a14573e0202de967869d123b473785d86
5
5
  SHA512:
6
- metadata.gz: bfc5ae34fd11e782db2e317c568c7fe490eb76d896f9e35e6b1dd3161572a7bcda616b566515f3ca451a42c7d3ddca04dea808a4c9835cc532a0bb4f45c547d9
7
- data.tar.gz: cb27416ab27496bebe7e06f36214c7a010a9a8a27c3e4604c0a6687e883e673842d99b8cc65aacf2f66e070b8dc1d96a6bf8710e81c27b7d6fa6703a03a1d552
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', '~>0.3.0'
20
+ dependency 'mysql2', '~>0.3.0'
21
21
  dependency 'activerecord', '~> 4.0'
22
- development_dependency 'test-unit', '~>3.0'
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.2
1
+ 2.3.3
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: active_record_mutex 2.3.2 ruby lib
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.2"
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-23"
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 = ActiveRecord::Base.connection.execute(sql)
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
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord::DatabaseMutex
2
2
  # ActiveRecord::DatabaseMutex version
3
- VERSION = '2.3.2'
3
+ VERSION = '2.3.3'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
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.2
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-23 00:00:00.000000000 Z
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