ar-multidb 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43b7a06c5b9e515743e31eabe777ed7f3d56374ac1861b505266636fb30fb2a6
4
- data.tar.gz: cfdbffebdbd4c940c08fb0260abfe3f5c25700be5a9cf562f4ad7dc370b93aee
3
+ metadata.gz: 59634325586b5a51f26e35498fdde6414d0df71675743dfa0a4bf34036cc3f6a
4
+ data.tar.gz: 25c0d17f1b743ef1a5e37c88f588067403cd84036cb0de34bcff4f2aff266b46
5
5
  SHA512:
6
- metadata.gz: cb45e7c3f610828ad5293ec478b5b0cfda8b17952d0f2a7772b3128e7c2515f396546a1f7a3014864ed489fa1a0da1e721c03cf50297c498051e0a7b3060218b
7
- data.tar.gz: 68cce9fef6f957b8212c41bddaeca6fe0711a614cd84d8cb38e7419a572929e9e5119344b4602d6efc53deafed42fa0c9acda6122e16149ee68e3e1af4d0823c
6
+ metadata.gz: ceedd0edbddea598ee5ca45cfca028bb74b40a91bc17ab69e54d78944491f380574c52772dc9e836a575627a0a765a84d4361cd68b9cd609845f9d4a9633dd00
7
+ data.tar.gz: 95d7bfd12ba7fd33bfa7a4428614510f7c5ccafb4ea05ab9d4afcdf01ff2ef6396e93067f22c8657ac83e74bc41947b5dd6b7ded2db3877f5034598c3831d9c8
@@ -16,25 +16,22 @@ jobs:
16
16
  fail-fast: false
17
17
  matrix:
18
18
  ruby:
19
- - '2.5'
20
- - '2.7'
21
19
  - '3.0'
20
+ - '3.1'
21
+ - '3.2'
22
+ - '3.3'
23
+ - '3.4'
22
24
  activerecord:
23
- - '5.1'
24
- - '5.2'
25
- - '6.0'
26
- - '6.1'
27
- - '7.0'
28
25
  - '7.1'
26
+ - '7.2'
27
+ - '8.0'
29
28
  exclude:
30
- - ruby: '2.5'
31
- activerecord: '7.0'
32
- - ruby: '2.5'
33
- activerecord: '7.1'
34
29
  - ruby: '3.0'
35
- activerecord: '5.1'
30
+ activerecord: '7.2'
36
31
  - ruby: '3.0'
37
- activerecord: '5.2'
32
+ activerecord: '8.0'
33
+ - ruby: '3.1'
34
+ activerecord: '8.0'
38
35
  env:
39
36
  BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}.gemfile"
40
37
  steps:
data/.gitignore CHANGED
@@ -1,7 +1,7 @@
1
1
  /pkg
2
2
  *~
3
3
  \.DS_Store
4
- *.sqlite
4
+ *.sqlite*
5
5
  Gemfile.lock
6
6
  Gemfile.local
7
7
  gemfiles/*.lock
data/.rubocop.yml CHANGED
@@ -1,14 +1,14 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-rspec
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
5
+ TargetRubyVersion: 3.0
6
6
  SuggestExtensions: false
7
7
  NewCops: disable
8
8
  Exclude:
9
9
  - '**/vendor/**/*'
10
10
 
11
- Gemspec/DateAssignment: # new in 1.10
11
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.30
12
12
  Enabled: true
13
13
  Gemspec/RequireMFA: # new in 1.23
14
14
  Enabled: true
@@ -27,9 +27,6 @@ Layout/SpaceBeforeBrackets: # new in 1.7
27
27
 
28
28
  Lint/AmbiguousAssignment: # new in 1.7
29
29
  Enabled: true
30
- Lint/AmbiguousBlockAssociation:
31
- IgnoredMethods:
32
- - change
33
30
  Lint/AmbiguousOperatorPrecedence: # new in 1.21
34
31
  Enabled: true
35
32
  Lint/AmbiguousRange: # new in 1.19
@@ -110,6 +107,8 @@ RSpec/MultipleExpectations:
110
107
  Enabled: false
111
108
  RSpec/NestedGroups:
112
109
  Max: 4
110
+ RSpec/VerifiedDoubleReference: # new in 2.10
111
+ Enabled: false
113
112
 
114
113
  Security/CompoundHash: # new in 1.28
115
114
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
6
6
 
7
+ ## [0.8.1]
8
+ ### Changes
9
+ - Updated Log subscriber mixin to utilize Rails 7.1's contract for "color"
10
+ - Removed old backward compat path for Rails < 6.1
11
+
12
+ ## [0.8.0]
13
+ ### Changed
14
+ - dropped support for Ruby < 3.0
15
+ - dropped support for AR < 7.1
16
+ - add support for Rails 7.2 and 8.0
17
+
7
18
  ## [0.7.0]
8
19
  ### Changed
9
20
  - add AR 7.1 support
data/ar-multidb.gemspec CHANGED
@@ -12,22 +12,23 @@ Gem::Specification.new do |s|
12
12
  s.summary = s.description = 'Multidb is an ActiveRecord extension for switching between multiple database connections, such as primary/replica setups.'
13
13
  s.license = 'MIT'
14
14
  s.metadata['rubygems_mfa_required'] = 'true'
15
+ s.metadata['changelog_uri'] = 'https://github.com/OutOfOrder/multidb/blob/master/CHANGELOG.md'
16
+ s.metadata['source_code_uri'] = 'https://github.com/OutOfOrder/multidb'
15
17
 
16
18
  s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
19
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
20
  s.require_paths = ['lib']
20
21
 
21
- s.required_ruby_version = '>= 2.5.0'
22
+ s.required_ruby_version = '>= 3.0.0'
22
23
 
23
- s.add_runtime_dependency 'activerecord', '>= 5.1', '< 7.2'
24
- s.add_runtime_dependency 'activesupport', '>= 5.1', '< 7.2'
24
+ s.add_runtime_dependency 'activerecord', '>= 7.1', '< 8.1'
25
+ s.add_runtime_dependency 'activesupport', '>= 7.1', '< 8.1'
25
26
 
26
27
  s.add_development_dependency 'rake', '~> 13.0'
27
28
  s.add_development_dependency 'rspec', '~> 3.8'
28
- s.add_development_dependency 'rubocop', '~> 1.28.0'
29
- s.add_development_dependency 'rubocop-rspec', '~> 2.10.0'
30
- s.add_development_dependency 'simplecov', '~> 0.21.2'
29
+ s.add_development_dependency 'rubocop', '~> 1.75.0'
30
+ s.add_development_dependency 'rubocop-rspec', '~> 3.6.0'
31
+ s.add_development_dependency 'simplecov', '~> 0.22.0'
31
32
  s.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
32
- s.add_development_dependency 'sqlite3', '~> 1.3'
33
+ s.add_development_dependency 'sqlite3', '~> 2'
33
34
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 5.1.0'
5
+ gem 'activerecord', '~> 7.2.0'
6
6
 
7
7
  gemspec path: '..'
@@ -2,6 +2,6 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 5.2.0'
5
+ gem 'activerecord', '~> 8.0.0'
6
6
 
7
7
  gemspec path: '..'
@@ -2,19 +2,14 @@
2
2
 
3
3
  module Multidb
4
4
  class Candidate
5
- USE_RAILS_61 = Gem::Version.new(::ActiveRecord::VERSION::STRING) >= Gem::Version.new('6.1')
6
- SPEC_NAME = if USE_RAILS_61
7
- 'ActiveRecord::Base'
8
- else
9
- 'primary'
10
- end
5
+ SPEC_NAME = 'ActiveRecord::Base'
11
6
 
12
7
  def initialize(name, target)
13
8
  @name = name
14
9
 
15
10
  case target
16
11
  when Hash
17
- target = target.merge(name: 'primary') unless USE_RAILS_61
12
+ target = target.merge(name: 'primary')
18
13
 
19
14
  @connection_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
20
15
  @connection_handler.establish_connection(target)
@@ -11,7 +11,7 @@ module Multidb
11
11
  def debug(msg = nil)
12
12
  name = Multidb.balancer.current_connection_name
13
13
  if name
14
- db = color("[DB: #{name}]", ActiveSupport::LogSubscriber::GREEN, true)
14
+ db = color("[DB: #{name}]", ActiveSupport::LogSubscriber::GREEN, bold: true)
15
15
  super(db + msg.to_s)
16
16
  else
17
17
  super
@@ -6,11 +6,7 @@ module Multidb
6
6
  module Connection
7
7
  def establish_connection(spec = nil)
8
8
  super(spec)
9
- config = if connection_pool.respond_to?(:db_config)
10
- connection_pool.db_config.configuration_hash
11
- else
12
- connection_pool.spec.config
13
- end
9
+ config = connection_pool.db_config.configuration_hash
14
10
 
15
11
  Multidb.init(config)
16
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Multidb
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.1'
5
5
  end
@@ -36,7 +36,7 @@ RSpec.describe Multidb::Balancer do
36
36
  end
37
37
 
38
38
  it 'sets fallback to false' do
39
- expect(subject.fallback).to eq(false)
39
+ expect(subject.fallback).to be(false)
40
40
  end
41
41
 
42
42
  context 'when rails ENV is development' do
@@ -45,7 +45,7 @@ RSpec.describe Multidb::Balancer do
45
45
  end
46
46
 
47
47
  it 'sets fallback to true' do
48
- expect(subject.fallback).to eq(true)
48
+ expect(subject.fallback).to be(true)
49
49
  end
50
50
  end
51
51
 
@@ -55,7 +55,7 @@ RSpec.describe Multidb::Balancer do
55
55
  end
56
56
 
57
57
  it 'sets fallback to true' do
58
- expect(subject.fallback).to eq(true)
58
+ expect(subject.fallback).to be(true)
59
59
  end
60
60
  end
61
61
  end
@@ -78,7 +78,7 @@ RSpec.describe Multidb::Balancer do
78
78
  end
79
79
 
80
80
  it 'sets fallback to true' do
81
- expect(subject.fallback).to eq(true)
81
+ expect(subject.fallback).to be(true)
82
82
  end
83
83
  end
84
84
 
@@ -17,16 +17,6 @@ RSpec.describe Multidb::Candidate do
17
17
  handler = subject.instance_variable_get(:@connection_handler)
18
18
  expect(handler).to an_instance_of(ActiveRecord::ConnectionAdapters::ConnectionHandler)
19
19
  end
20
-
21
- it 'merges the name: primary into the hash', rails: '< 6.1' do
22
- handler = instance_double('ActiveRecord::ConnectionAdapters::ConnectionHandler')
23
- allow(ActiveRecord::ConnectionAdapters::ConnectionHandler).to receive(:new).and_return(handler)
24
- allow(handler).to receive(:establish_connection)
25
-
26
- subject
27
-
28
- expect(handler).to have_received(:establish_connection).with(hash_including(name: 'primary'))
29
- end
30
20
  end
31
21
 
32
22
  context 'when target is a connection handler' do
@@ -17,8 +17,12 @@ RSpec.describe Multidb::LogSubscriberExtension do
17
17
  msg
18
18
  end
19
19
 
20
- def color(text, _color, _bold)
21
- text
20
+ def color(text, color, options = {})
21
+ if options[:bold]
22
+ "Bold: Color #{color}: #{text}"
23
+ else
24
+ "Color #{color}: #{text}"
25
+ end
22
26
  end
23
27
  end
24
28
 
@@ -56,7 +60,7 @@ RSpec.describe Multidb::LogSubscriberExtension do
56
60
  end
57
61
 
58
62
  it 'does not change the payload' do
59
- expect { subject }.not_to change { event.payload }
63
+ expect { subject }.not_to(change { event.payload })
60
64
  end
61
65
  end
62
66
  end
@@ -65,13 +69,13 @@ RSpec.describe Multidb::LogSubscriberExtension do
65
69
  subject { instance.debug('message') }
66
70
 
67
71
  it 'prepends the db name to the message' do
68
- is_expected.to include('[DB: default]')
72
+ is_expected.to start_with "Bold: Color \e[32m: [DB: default]"
69
73
  end
70
74
 
71
75
  context 'when a replica is active' do
72
76
  it 'prepends the replica dbname to the message' do
73
77
  Multidb.use(:replica1) {
74
- is_expected.to include('[DB: replica1')
78
+ is_expected.to start_with "Bold: Color \e[32m: [DB: replica1"
75
79
  }
76
80
  end
77
81
  end
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,7 @@ require 'fileutils'
13
13
  $LOAD_PATH.unshift(File.expand_path('lib', __dir__))
14
14
  require 'multidb'
15
15
 
16
- Dir[File.join(__dir__, 'support', '**', '*.rb')].sort.each { |f| require f }
16
+ Dir[File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f }
17
17
 
18
18
  RSpec.configure do |config|
19
19
  config.disable_monkey_patching!
@@ -39,7 +39,7 @@ RSpec.configure do |config|
39
39
  end
40
40
 
41
41
  config.before do
42
- ActiveRecord::Base.clear_all_connections!
42
+ ActiveRecord::Base.connection_handler.clear_all_connections!
43
43
  Multidb.reset!
44
44
  end
45
45
 
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-multidb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Staubo
8
8
  - Edward Rudd
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-02-28 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
@@ -17,40 +16,40 @@ dependencies:
17
16
  requirements:
18
17
  - - ">="
19
18
  - !ruby/object:Gem::Version
20
- version: '5.1'
19
+ version: '7.1'
21
20
  - - "<"
22
21
  - !ruby/object:Gem::Version
23
- version: '7.2'
22
+ version: '8.1'
24
23
  type: :runtime
25
24
  prerelease: false
26
25
  version_requirements: !ruby/object:Gem::Requirement
27
26
  requirements:
28
27
  - - ">="
29
28
  - !ruby/object:Gem::Version
30
- version: '5.1'
29
+ version: '7.1'
31
30
  - - "<"
32
31
  - !ruby/object:Gem::Version
33
- version: '7.2'
32
+ version: '8.1'
34
33
  - !ruby/object:Gem::Dependency
35
34
  name: activesupport
36
35
  requirement: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: '5.1'
39
+ version: '7.1'
41
40
  - - "<"
42
41
  - !ruby/object:Gem::Version
43
- version: '7.2'
42
+ version: '8.1'
44
43
  type: :runtime
45
44
  prerelease: false
46
45
  version_requirements: !ruby/object:Gem::Requirement
47
46
  requirements:
48
47
  - - ">="
49
48
  - !ruby/object:Gem::Version
50
- version: '5.1'
49
+ version: '7.1'
51
50
  - - "<"
52
51
  - !ruby/object:Gem::Version
53
- version: '7.2'
52
+ version: '8.1'
54
53
  - !ruby/object:Gem::Dependency
55
54
  name: rake
56
55
  requirement: !ruby/object:Gem::Requirement
@@ -85,42 +84,42 @@ dependencies:
85
84
  requirements:
86
85
  - - "~>"
87
86
  - !ruby/object:Gem::Version
88
- version: 1.28.0
87
+ version: 1.75.0
89
88
  type: :development
90
89
  prerelease: false
91
90
  version_requirements: !ruby/object:Gem::Requirement
92
91
  requirements:
93
92
  - - "~>"
94
93
  - !ruby/object:Gem::Version
95
- version: 1.28.0
94
+ version: 1.75.0
96
95
  - !ruby/object:Gem::Dependency
97
96
  name: rubocop-rspec
98
97
  requirement: !ruby/object:Gem::Requirement
99
98
  requirements:
100
99
  - - "~>"
101
100
  - !ruby/object:Gem::Version
102
- version: 2.10.0
101
+ version: 3.6.0
103
102
  type: :development
104
103
  prerelease: false
105
104
  version_requirements: !ruby/object:Gem::Requirement
106
105
  requirements:
107
106
  - - "~>"
108
107
  - !ruby/object:Gem::Version
109
- version: 2.10.0
108
+ version: 3.6.0
110
109
  - !ruby/object:Gem::Dependency
111
110
  name: simplecov
112
111
  requirement: !ruby/object:Gem::Requirement
113
112
  requirements:
114
113
  - - "~>"
115
114
  - !ruby/object:Gem::Version
116
- version: 0.21.2
115
+ version: 0.22.0
117
116
  type: :development
118
117
  prerelease: false
119
118
  version_requirements: !ruby/object:Gem::Requirement
120
119
  requirements:
121
120
  - - "~>"
122
121
  - !ruby/object:Gem::Version
123
- version: 0.21.2
122
+ version: 0.22.0
124
123
  - !ruby/object:Gem::Dependency
125
124
  name: simplecov-lcov
126
125
  requirement: !ruby/object:Gem::Requirement
@@ -141,14 +140,14 @@ dependencies:
141
140
  requirements:
142
141
  - - "~>"
143
142
  - !ruby/object:Gem::Version
144
- version: '1.3'
143
+ version: '2'
145
144
  type: :development
146
145
  prerelease: false
147
146
  version_requirements: !ruby/object:Gem::Requirement
148
147
  requirements:
149
148
  - - "~>"
150
149
  - !ruby/object:Gem::Version
151
- version: '1.3'
150
+ version: '2'
152
151
  description: Multidb is an ActiveRecord extension for switching between multiple database
153
152
  connections, such as primary/replica setups.
154
153
  email:
@@ -168,12 +167,9 @@ files:
168
167
  - README.markdown
169
168
  - Rakefile
170
169
  - ar-multidb.gemspec
171
- - gemfiles/activerecord-5.1.gemfile
172
- - gemfiles/activerecord-5.2.gemfile
173
- - gemfiles/activerecord-6.0.gemfile
174
- - gemfiles/activerecord-6.1.gemfile
175
- - gemfiles/activerecord-7.0.gemfile
176
170
  - gemfiles/activerecord-7.1.gemfile
171
+ - gemfiles/activerecord-7.2.gemfile
172
+ - gemfiles/activerecord-8.0.gemfile
177
173
  - lib/ar-multidb.rb
178
174
  - lib/multidb.rb
179
175
  - lib/multidb/balancer.rb
@@ -196,7 +192,8 @@ licenses:
196
192
  - MIT
197
193
  metadata:
198
194
  rubygems_mfa_required: 'true'
199
- post_install_message:
195
+ changelog_uri: https://github.com/OutOfOrder/multidb/blob/master/CHANGELOG.md
196
+ source_code_uri: https://github.com/OutOfOrder/multidb
200
197
  rdoc_options: []
201
198
  require_paths:
202
199
  - lib
@@ -204,25 +201,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
201
  requirements:
205
202
  - - ">="
206
203
  - !ruby/object:Gem::Version
207
- version: 2.5.0
204
+ version: 3.0.0
208
205
  required_rubygems_version: !ruby/object:Gem::Requirement
209
206
  requirements:
210
207
  - - ">="
211
208
  - !ruby/object:Gem::Version
212
209
  version: '0'
213
210
  requirements: []
214
- rubygems_version: 3.1.6
215
- signing_key:
211
+ rubygems_version: 3.6.7
216
212
  specification_version: 4
217
213
  summary: Multidb is an ActiveRecord extension for switching between multiple database
218
214
  connections, such as primary/replica setups.
219
- test_files:
220
- - spec/lib/multidb/balancer_spec.rb
221
- - spec/lib/multidb/candidate_spec.rb
222
- - spec/lib/multidb/configuration_spec.rb
223
- - spec/lib/multidb/log_subscriber_extension_spec.rb
224
- - spec/lib/multidb/model_extensions_spec.rb
225
- - spec/lib/multidb_spec.rb
226
- - spec/spec_helper.rb
227
- - spec/support/have_database_matcher.rb
228
- - spec/support/helpers.rb
215
+ test_files: []
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'activerecord', '~> 6.0.0'
6
-
7
- gemspec path: '..'
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'activerecord', '~> 6.1.0'
6
-
7
- gemspec path: '..'
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'activerecord', '~> 7.0.0'
6
-
7
- gemspec path: '..'