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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '098b8a529ace3b8a925536484b3c3de41d7eea6336ec601228173b8000d55ec6'
4
- data.tar.gz: f9570b710a2a4c00371e840f12a74258ee60f5d1f42cbf3934e4d2ff57f8cb40
3
+ metadata.gz: 2de2a405dc31b45333b03a5786a6ea1139902a5da197675f56d5b6a645c2eae3
4
+ data.tar.gz: 68c38806668ee3fc1573b19ad08f6e6b66736d3632134ab773a1cb08548798f6
5
5
  SHA512:
6
- metadata.gz: 62600a72c3ce6590beb8dfe0638bcaf00fc0cfea95afe146b9c1c97d4d2b1ad8ae96e533af6361ca8acb75abc3a50db0bbb03e3dee9532ce9812b341024cf539
7
- data.tar.gz: aca0193931b046f9918a5a0b4a076c945aabb8f99133465b8619cda3e5b5064cc0d7d74fc3a8b15c2c3ee200d1aa8d39f1291ab93228143d546ccc2076c4eba1
6
+ metadata.gz: 1d15cbe8c2d345705284575ff7caa6082139c5274432b9a293035932788a3f156aa2002435dcb04f614ab7fd51a9ee5d0d85af5b04e5ff59f66eb74c4cf1a763
7
+ data.tar.gz: 2d971f5101357f0bf0dbba1efa1203f811b7707ab655d18ecef4999d726b943893e35132aa151ec6ec655d918284385facd0125a51cf5f5cb6d62def0804e19e
@@ -13,7 +13,7 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  services:
15
15
  mysql:
16
- image: mysql:5.7
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: 2.6
32
+ ruby: 3.1
33
+ - gemfile: rails5.1
34
+ ruby: 3.2
35
+
35
36
  - gemfile: rails5.2
36
- ruby: 2.6
37
+ ruby: 3.1
37
38
  - gemfile: rails5.2
38
- ruby: 3.0
39
+ ruby: 3.2
39
40
 
40
41
  - gemfile: rails6.0
41
- ruby: 2.7
42
+ ruby: 3.1
43
+ - gemfile: rails6.0
44
+ ruby: 3.2
45
+
42
46
  - gemfile: rails6.1
43
- ruby: 2.7
47
+ ruby: 3.2
44
48
  - gemfile: rails6.1
45
- ruby: 3.0
49
+ ruby: 3.3
46
50
 
47
51
  - gemfile: rails7.0
48
- ruby: 3.0
52
+ ruby: 3.2
49
53
  - gemfile: rails7.0
50
- ruby: 3.1
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.2.2
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
@@ -1,5 +1,9 @@
1
1
  # Change log
2
2
 
3
+ ## 0.6.0 2024-09-04
4
+
5
+ - Add support for Rails 7.2
6
+
3
7
  ## 0.5.1 2024-04-22
4
8
 
5
9
  - Add kwargs argument to the ActiveRecordAbstractAdapter
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gem "activerecord", "~> 7.1.0"
3
2
 
4
3
  # Specify your gem's dependencies in octoshark.gemspec
5
4
  gemspec
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
- def self.connection
113
- CONN_MANAGER.current_connection
114
- end
115
- end
116
- ```
112
+ class << self
113
+ def connection
114
+ CONN_MANAGER.current_connection
115
+ end
117
116
 
118
- Alternatively, we can extract it as a module and include in multiple models.
117
+ # For Rails 7.2+ we need to override the following methods too:
119
118
 
120
- ```ruby
121
- module ShardingModel
122
- extend ActiveSupport::Concern
119
+ def lease_connection
120
+ connection
121
+ end
123
122
 
124
- module ClassMethods
125
- def connection
126
- CONN_MANAGER.current_connection
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
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.1.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.7.3"
6
8
 
7
9
  gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.2.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.7.3"
6
8
 
7
9
  gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 6.0.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.7.3"
6
8
 
7
9
  gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 6.1.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.7.3"
6
8
 
7
9
  gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 7.0.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.7.3"
6
8
 
7
9
  gemspec path: "../"
@@ -2,8 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.0"
6
- gem "mysql2", "~> 0.5.2"
7
- gem "sqlite3", "~> 1.3.13"
5
+ gem "activerecord", "~> 7.2.0"
8
6
 
9
7
  gemspec path: "../"
@@ -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
- connection_method = "#{config[:adapter]}_connection"
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
 
@@ -1,3 +1,3 @@
1
1
  module Octoshark
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
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", "~> 3.12.0"
25
- spec.add_development_dependency "sqlite3", "~> 1.4.1"
26
- spec.add_development_dependency "mysql2", "~> 0.5.2"
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.5.1
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-04-22 00:00:00.000000000 Z
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: 3.12.0
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: 3.12.0
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: 1.4.1
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: 1.4.1
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.5.2
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.5.2
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.4.10
170
+ rubygems_version: 3.5.11
157
171
  signing_key:
158
172
  specification_version: 4
159
173
  summary: Octoshark is an ActiveRecord connection switcher