octoshark 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +17 -13
- data/.ruby-version +1 -1
- data/Appraisals +14 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +0 -1
- data/README.md +14 -12
- data/gemfiles/rails5.1.gemfile +2 -0
- data/gemfiles/rails5.2.gemfile +2 -0
- data/gemfiles/rails6.0.gemfile +2 -0
- data/gemfiles/rails6.1.gemfile +2 -0
- data/gemfiles/rails7.0.gemfile +2 -0
- data/gemfiles/{rails5.0.gemfile → rails7.2.gemfile} +1 -3
- data/lib/octoshark/active_record_extensions.rb +13 -0
- data/lib/octoshark/connection_manager.rb +8 -2
- data/lib/octoshark/version.rb +1 -1
- data/octoshark.gemspec +4 -3
- metadata +28 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2de2a405dc31b45333b03a5786a6ea1139902a5da197675f56d5b6a645c2eae3
|
4
|
+
data.tar.gz: 68c38806668ee3fc1573b19ad08f6e6b66736d3632134ab773a1cb08548798f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d15cbe8c2d345705284575ff7caa6082139c5274432b9a293035932788a3f156aa2002435dcb04f614ab7fd51a9ee5d0d85af5b04e5ff59f66eb74c4cf1a763
|
7
|
+
data.tar.gz: 2d971f5101357f0bf0dbba1efa1203f811b7707ab655d18ecef4999d726b943893e35132aa151ec6ec655d918284385facd0125a51cf5f5cb6d62def0804e19e
|
data/.github/workflows/build.yml
CHANGED
@@ -13,7 +13,7 @@ jobs:
|
|
13
13
|
runs-on: ubuntu-latest
|
14
14
|
services:
|
15
15
|
mysql:
|
16
|
-
image: mysql:
|
16
|
+
image: mysql:8.0
|
17
17
|
env:
|
18
18
|
MYSQL_ROOT_PASSWORD: pass
|
19
19
|
ports:
|
@@ -28,31 +28,35 @@ jobs:
|
|
28
28
|
strategy:
|
29
29
|
matrix:
|
30
30
|
include:
|
31
|
-
- gemfile: rails5.0
|
32
|
-
ruby: 2.6
|
33
31
|
- gemfile: rails5.1
|
34
|
-
ruby:
|
32
|
+
ruby: 3.1
|
33
|
+
- gemfile: rails5.1
|
34
|
+
ruby: 3.2
|
35
|
+
|
35
36
|
- gemfile: rails5.2
|
36
|
-
ruby:
|
37
|
+
ruby: 3.1
|
37
38
|
- gemfile: rails5.2
|
38
|
-
ruby: 3.
|
39
|
+
ruby: 3.2
|
39
40
|
|
40
41
|
- gemfile: rails6.0
|
41
|
-
ruby:
|
42
|
+
ruby: 3.1
|
43
|
+
- gemfile: rails6.0
|
44
|
+
ruby: 3.2
|
45
|
+
|
42
46
|
- gemfile: rails6.1
|
43
|
-
ruby: 2
|
47
|
+
ruby: 3.2
|
44
48
|
- gemfile: rails6.1
|
45
|
-
ruby: 3.
|
49
|
+
ruby: 3.3
|
46
50
|
|
47
51
|
- gemfile: rails7.0
|
48
|
-
ruby: 3.
|
52
|
+
ruby: 3.2
|
49
53
|
- gemfile: rails7.0
|
50
|
-
ruby: 3.
|
54
|
+
ruby: 3.3
|
51
55
|
|
52
|
-
- gemfile: rails7.1
|
53
|
-
ruby: 3.1
|
54
56
|
- gemfile: rails7.1
|
55
57
|
ruby: 3.2
|
58
|
+
- gemfile: rails7.1
|
59
|
+
ruby: 3.3
|
56
60
|
|
57
61
|
env:
|
58
62
|
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.4
|
data/Appraisals
CHANGED
@@ -1,23 +1,37 @@
|
|
1
1
|
appraise "rails5.1" do
|
2
2
|
gem "activerecord", "~> 5.1.0"
|
3
|
+
gem "mysql2", "~> 0.5.2"
|
4
|
+
gem "sqlite3", "~> 1.7.3"
|
3
5
|
end
|
4
6
|
|
5
7
|
appraise "rails5.2" do
|
6
8
|
gem "activerecord", "~> 5.2.0"
|
9
|
+
gem "mysql2", "~> 0.5.2"
|
10
|
+
gem "sqlite3", "~> 1.7.3"
|
7
11
|
end
|
8
12
|
|
9
13
|
appraise "rails6.0" do
|
10
14
|
gem "activerecord", "~> 6.0.0"
|
15
|
+
gem "mysql2", "~> 0.5.2"
|
16
|
+
gem "sqlite3", "~> 1.7.3"
|
11
17
|
end
|
12
18
|
|
13
19
|
appraise "rails6.1" do
|
14
20
|
gem "activerecord", "~> 6.1.0"
|
21
|
+
gem "mysql2", "~> 0.5.2"
|
22
|
+
gem "sqlite3", "~> 1.7.3"
|
15
23
|
end
|
16
24
|
|
17
25
|
appraise "rails7.0" do
|
18
26
|
gem "activerecord", "~> 7.0.0"
|
27
|
+
gem "mysql2", "~> 0.5.2"
|
28
|
+
gem "sqlite3", "~> 1.7.3"
|
19
29
|
end
|
20
30
|
|
21
31
|
appraise "rails7.1" do
|
22
32
|
gem "activerecord", "~> 7.1.0"
|
23
33
|
end
|
34
|
+
|
35
|
+
appraise "rails7.2" do
|
36
|
+
gem "activerecord", "~> 7.2.0"
|
37
|
+
end
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -109,21 +109,23 @@ To tell an ActiveRecord model to use the Octoshark connection we can override th
|
|
109
109
|
|
110
110
|
```ruby
|
111
111
|
class Post < ActiveRecord::Base
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
116
|
-
```
|
112
|
+
class << self
|
113
|
+
def connection
|
114
|
+
CONN_MANAGER.current_connection
|
115
|
+
end
|
117
116
|
|
118
|
-
|
117
|
+
# For Rails 7.2+ we need to override the following methods too:
|
119
118
|
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
def lease_connection
|
120
|
+
connection
|
121
|
+
end
|
123
122
|
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
def with_connection
|
124
|
+
yield connection
|
125
|
+
end
|
126
|
+
|
127
|
+
def schema_cache
|
128
|
+
connection.schema_cache
|
127
129
|
end
|
128
130
|
end
|
129
131
|
end
|
data/gemfiles/rails5.1.gemfile
CHANGED
data/gemfiles/rails5.2.gemfile
CHANGED
data/gemfiles/rails6.0.gemfile
CHANGED
data/gemfiles/rails6.1.gemfile
CHANGED
data/gemfiles/rails7.0.gemfile
CHANGED
@@ -34,6 +34,18 @@ module Octoshark
|
|
34
34
|
super(sql, name, *other_args, **kwargs, &block)
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
module ConnectionPool
|
39
|
+
# Handle Rails 8.0 ConnectionPool#connection deprecation
|
40
|
+
def connection
|
41
|
+
if respond_to?(:lease_connection)
|
42
|
+
# Rails 7.2+
|
43
|
+
lease_connection
|
44
|
+
else
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
37
49
|
end
|
38
50
|
|
39
51
|
# Rails 3.0 and 3.1 does not lazy load
|
@@ -43,3 +55,4 @@ end
|
|
43
55
|
|
44
56
|
ActiveRecord::ConnectionAdapters::ConnectionHandler.send(:prepend, Octoshark::ConnectionHandler)
|
45
57
|
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:prepend, Octoshark::ActiveRecordAbstractAdapter)
|
58
|
+
ActiveRecord::ConnectionAdapters::ConnectionPool.send(:prepend, Octoshark::ConnectionPool)
|
@@ -3,9 +3,15 @@ module Octoshark
|
|
3
3
|
include CurrentConnection
|
4
4
|
|
5
5
|
def with_connection(config, connection_name: nil, &block)
|
6
|
-
|
6
|
+
connection =
|
7
|
+
if ActiveRecord::ConnectionAdapters.respond_to?(:resolve)
|
8
|
+
# Rails 7.2+
|
9
|
+
ActiveRecord::ConnectionAdapters.resolve(config[:adapter]).new(config)
|
10
|
+
else
|
11
|
+
connection_method = "#{config[:adapter]}_connection"
|
12
|
+
ActiveRecord::Base.send(connection_method, config)
|
13
|
+
end
|
7
14
|
|
8
|
-
connection = ActiveRecord::Base.send(connection_method, config)
|
9
15
|
connection.connection_name = connection_name
|
10
16
|
connection.database_name = config[:database] if config[:database]
|
11
17
|
|
data/lib/octoshark/version.rb
CHANGED
data/octoshark.gemspec
CHANGED
@@ -21,8 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency "activerecord", ">= 3.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency "rspec"
|
25
|
-
spec.add_development_dependency "
|
26
|
-
spec.add_development_dependency "
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "activerecord", "~> 7.2.0"
|
26
|
+
spec.add_development_dependency "sqlite3"
|
27
|
+
spec.add_development_dependency "mysql2"
|
27
28
|
spec.add_development_dependency "appraisal"
|
28
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octoshark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dalibor Nasevic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -40,46 +40,60 @@ dependencies:
|
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
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: activerecord
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 7.2.0
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: 7.2.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: sqlite3
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: mysql2
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
89
|
+
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: appraisal
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,13 +125,13 @@ files:
|
|
111
125
|
- LICENSE.txt
|
112
126
|
- README.md
|
113
127
|
- Rakefile
|
114
|
-
- gemfiles/rails5.0.gemfile
|
115
128
|
- gemfiles/rails5.1.gemfile
|
116
129
|
- gemfiles/rails5.2.gemfile
|
117
130
|
- gemfiles/rails6.0.gemfile
|
118
131
|
- gemfiles/rails6.1.gemfile
|
119
132
|
- gemfiles/rails7.0.gemfile
|
120
133
|
- gemfiles/rails7.1.gemfile
|
134
|
+
- gemfiles/rails7.2.gemfile
|
121
135
|
- lib/octoshark.rb
|
122
136
|
- lib/octoshark/active_record_extensions.rb
|
123
137
|
- lib/octoshark/connection_manager.rb
|
@@ -153,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
167
|
- !ruby/object:Gem::Version
|
154
168
|
version: '0'
|
155
169
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.5.11
|
157
171
|
signing_key:
|
158
172
|
specification_version: 4
|
159
173
|
summary: Octoshark is an ActiveRecord connection switcher
|