octoball 0.1.4 → 0.1.8

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: 260d7c95bac1ba724636272cfa7ecf444124b868b2c7a3cea4d6966e0ac947a9
4
- data.tar.gz: 5036fc1b1f6f5f0d7b24c734951ad6cbff0fd48eabc529a3f5390e55f2ad50d2
3
+ metadata.gz: 825cfa3ec263110a928737f918d0576459a50aa67b1f1553ab194248e0c0d41c
4
+ data.tar.gz: c20b43133b0afd7c324b4cd57a54204d7c716f85acb7aa55a950be80e2bcec02
5
5
  SHA512:
6
- metadata.gz: 1d954e47f0a2603425d29e82669b9388d4f49abf7def04e268548554ee5ab52181a2b192a5ccfd34b288a67b34fd6cf8cac4d75b8304c918970f7523f3177285
7
- data.tar.gz: 7b294deea783c80324d5694afd87984017411677f593d042fa9b78a35e5dba5d12584209bb36d45190c3e63d748e1a4f5096e6a6e992ef9ebfa71e7968a41c4d
6
+ metadata.gz: 0002bc390d5982cb4a968ecdd91d12234a4d495553e906c0765efc09c29111b72fd136b15bd8fbd8a3b30b8b0f6d25fb9e6b41c5138ee777e791773a5117fcc6
7
+ data.tar.gz: 37efcbe5015be915ae7263a03f6da3443f03b6de711389ec59c76ada5fb0ea3a786c072c358a9f27573df1741ae978ef723930bb8ea4503fa80563669b13880e
data/.github/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../../'
4
+
5
+ gem 'activerecord', '~> 7.2.0'
6
+ gem 'activesupport', '~> 7.2.0'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../../'
4
+
5
+ gem 'activerecord', '~> 8.0.0'
6
+ gem 'activesupport', '~> 8.0.0'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../../'
4
+
5
+ gem 'activerecord', '~> 8.1.0'
6
+ gem 'activesupport', '~> 8.1.0'
@@ -0,0 +1,39 @@
1
+ name: rspec
2
+ on: push
3
+ jobs:
4
+ rspec:
5
+ runs-on: ubuntu-latest
6
+ services:
7
+ mysql:
8
+ image: mysql:5
9
+ ports:
10
+ - 3306:3306
11
+ env:
12
+ MYSQL_ALLOW_EMPTY_PASSWORD: yes
13
+ options: >-
14
+ --health-cmd "mysqladmin ping"
15
+ --health-interval 5s
16
+ --health-timeout 3s
17
+ strategy:
18
+ fail-fast: true
19
+ matrix:
20
+ ruby: ["3.2", "3.3", "3.4"]
21
+ rails: ["7.2", "8.0", "8.1"]
22
+ env:
23
+ BUNDLE_GEMFILE: .github/gemfiles/rails_${{ matrix.rails }}.gemfile
24
+ MYSQL_HOST: 127.0.0.1
25
+ RAILS_ENV: test
26
+ steps:
27
+ - name: Checkout
28
+ uses: actions/checkout@v4
29
+ - name: Setup ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby }}
33
+ bundler-cache: true
34
+ - name: Install rake
35
+ run: gem install rake
36
+ - name: Setup database
37
+ run: bundle exec rake db:prepare
38
+ - name: run rspec
39
+ run: bundle exec rspec
data/README.md CHANGED
@@ -11,12 +11,16 @@ Currently, its implementation is focusing on horizontal database sharding. Howev
11
11
  ## Scope of this gem
12
12
 
13
13
  ### What is included in Octoball
14
+
14
15
  - Octopus-like shard swithcing by `using` class method, e.g.:
16
+
15
17
  ```ruby
16
18
  Octoball.using(:shard1) { User.find_by_name("Alice") }
17
19
  User.using(:shard1).first
18
20
  ```
21
+
19
22
  - Each model instance knows which shard it came from so shard will be switched automatically:
23
+
20
24
  ```ruby
21
25
  user1 = User.using(:shard1).find_by_name("Bob")
22
26
  user2 = User.using(:shard2).find_by_name("Charlie")
@@ -25,15 +29,18 @@ Currently, its implementation is focusing on horizontal database sharding. Howev
25
29
  user1.save! # Save the user1 in the correct shard `:shard1`
26
30
  user2.save! # Save the user2 in the correct shard `:shard2`
27
31
  ```
32
+
28
33
  - Relations such as `has_many` are also resolved from the model instance's shard:
34
+
29
35
  ```ruby
30
36
  user = User.using(:shard1).find_by_name("Alice")
31
37
  user.blogs.where(title: "blog") # user's blogs are fetched from `:shard1`
32
38
  ```
33
39
 
34
40
  ### What is NOT included in Octoball
41
+
35
42
  - Connection handling and configuration -- managed by the native `ActiveRecord::Base.connects_to` methods introduced in ActiveRecord 6.1.
36
- - You need to migrate from Octopus' `config/shards.yml` to [Rails native multiple DB configuration using `config/database.yml`](https://edgeguides.rubyonrails.org/active_record_multiple_databases.html). Please refer the [Setup](#Setup) section for more details.
43
+ - You need to migrate from Octopus' `config/shards.yml` to [Rails native multiple DB configuration using `config/database.yml`](https://edgeguides.rubyonrails.org/active_record_multiple_databases.html). Please refer the [Setup](#setup) section for more details.
37
44
  - Migration -- done by ActiveRecord 6.1+ natively.
38
45
  - Instead of `using` method in Octopus, you can specify the `migrations_paths` parameter in the `config/database.yml` file.
39
46
  - Replication handling -- done by ActiveRecord's `role`
@@ -46,12 +53,13 @@ gem "octoball"
46
53
  ```
47
54
 
48
55
  Define the database connections in `config/database.yml`, e.g.:
56
+
49
57
  ```
50
58
  default: &default
51
- adapter: mysql2
59
+ adapter: trilogy
52
60
  pool: 5
53
61
  username: root
54
- host: localhost
62
+ host: 127.0.0.1
55
63
  timeout: 5000
56
64
  connnect_timeout: 5000
57
65
 
@@ -63,7 +71,9 @@ development:
63
71
  <<: *default
64
72
  database: db_shard1
65
73
  ```
74
+
66
75
  And define shards and corresponding connections in abstract ActiveRecord model class, e.g.:
76
+
67
77
  ```ruby
68
78
  class ApplicationRecord < ActiveRecord::Base
69
79
  self.abstract_class = true
@@ -80,21 +90,24 @@ end
80
90
  ```
81
91
 
82
92
  Optionally, to use the `:master` shard as a default connection like Octopus, add the following script to `config/initializers/default_shard.rb`:
93
+
83
94
  ```
84
95
  ActiveRecord::Base.default_shard = :master
85
96
  ```
86
97
 
87
-
88
98
  ## Development of Octoball
99
+
89
100
  Octoball has rspec tests delived from subsets of Octopus' rspec.
90
101
 
91
102
  To run the rspec tests, follow these steps:
103
+
92
104
  ```
93
105
  RAILS_ENV=test bundle exec rake db:prepare
94
106
  RAILS_ENV=test bundle exec rake spec
95
107
  ```
96
108
 
97
109
  ## License
110
+
98
111
  Octoball is released under the MIT license.
99
112
 
100
113
  Original Octopus' copyright: Copyright (c) Thiago Pradi
data/Rakefile CHANGED
@@ -9,9 +9,10 @@ RuboCop::RakeTask.new
9
9
 
10
10
  namespace :db do
11
11
  mysql_spec = {
12
- adapter: 'mysql2',
13
- host: (ENV['MYSQL_HOST'] || 'localhost'),
12
+ adapter: 'trilogy',
13
+ host: (ENV['MYSQL_HOST'] || '127.0.0.1'),
14
14
  username: (ENV['MYSQL_USER'] || 'root'),
15
+ port: (ENV['MYSQL_PORT'] || 3306),
15
16
  encoding: 'utf8mb4',
16
17
  }
17
18
 
@@ -31,6 +32,8 @@ namespace :db do
31
32
 
32
33
  desc 'Create tables on tests databases'
33
34
  task :create_tables do
35
+ require 'active_record'
36
+
34
37
  ActiveRecord::Base.configurations = {
35
38
  "test" => {
36
39
  shard1: mysql_spec.merge(database: 'octoball_shard_1'),
@@ -43,7 +46,7 @@ namespace :db do
43
46
  require './spec/models/application_record'
44
47
  ActiveRecord::Base.configurations.configs_for(env_name: "test").each do |config|
45
48
  ActiveRecord::Base.establish_connection(config)
46
- schema_migration = ActiveRecord::Base.connection.schema_migration
49
+ schema_migration = ActiveRecord::Base.connection.pool.schema_migration
47
50
  ActiveRecord::MigrationContext.new("spec/migration", schema_migration)
48
51
  .migrate(config.database == 'octoball_shard_5' ? 2 : 1)
49
52
  end
@@ -13,6 +13,38 @@ class Octoball
13
13
  attr_accessor :current_shard
14
14
  end
15
15
 
16
+ module ConnectionPoolSetCurrentShard
17
+ def with_connection(prevent_permanent_checkout: false)
18
+ lease = connection_lease
19
+ if lease.connection
20
+ lease.connection.current_shard = lease.connection.shard
21
+ end
22
+
23
+ super
24
+ end
25
+
26
+ def active_connection?
27
+ conn = connection_lease.connection
28
+ conn.current_shard = conn.shard if conn
29
+ conn
30
+ end
31
+
32
+ def active_connection
33
+ conn = connection_lease.connection
34
+ conn.current_shard = conn.shard if conn
35
+ conn
36
+ end
37
+
38
+ def lease_connection
39
+ lease = connection_lease
40
+ lease.sticky = true
41
+ lease.connection ||= checkout
42
+ lease.connection.current_shard = lease.connection.shard
43
+ lease.connection
44
+ end
45
+ end
46
+
47
+ ::ActiveRecord::ConnectionAdapters::ConnectionPool.prepend(ConnectionPoolSetCurrentShard)
16
48
  ::ActiveRecord::ConnectionAdapters::ConnectionHandler.prepend(ConnectionHandlerSetCurrentShard)
17
49
  ::ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(ConnectionHasCurrentShard)
18
50
  end
@@ -12,7 +12,7 @@ class Octoball
12
12
  private
13
13
 
14
14
  def debug(progname = nil, &block)
15
- conn = current_shard ? color("[Shard: #{current_shard}]", ActiveSupport::LogSubscriber::GREEN, true) : ''
15
+ conn = current_shard ? color("[Shard: #{current_shard}]", ActiveSupport::LogSubscriber::GREEN, bold: true) : ''
16
16
  super(conn + progname.to_s, &block)
17
17
  end
18
18
  end
@@ -0,0 +1,17 @@
1
+ class Octoball
2
+ def self.using(shard, &block)
3
+ ActiveRecord::Base.connected_to(role: current_role, shard: shard&.to_sym, &block)
4
+ end
5
+
6
+ def self.current_role
7
+ ActiveRecord::Base.current_role || ActiveRecord::Base.writing_role
8
+ end
9
+
10
+ module UsingShard
11
+ def using(shard)
12
+ Octoball::RelationProxy.new(all, shard&.to_sym)
13
+ end
14
+ end
15
+
16
+ ::ActiveRecord::Base.singleton_class.prepend(UsingShard)
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Octoball
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.8'
5
5
  end
data/lib/octoball.rb CHANGED
@@ -2,29 +2,14 @@
2
2
 
3
3
  require 'active_record'
4
4
  require 'octoball/version'
5
- require 'octoball/relation_proxy'
6
- require 'octoball/connection_adapters'
7
- require 'octoball/connection_handling'
8
- require 'octoball/current_shard_tracker'
9
- require 'octoball/association'
10
- require 'octoball/association_shard_check'
11
- require 'octoball/persistence'
12
- require 'octoball/log_subscriber'
13
5
 
14
- class Octoball
15
- def self.using(shard, &block)
16
- ActiveRecord::Base.connected_to(role: current_role, shard: shard&.to_sym, &block)
17
- end
18
-
19
- def self.current_role
20
- ActiveRecord::Base.current_role || ActiveRecord::Base.writing_role
21
- end
22
-
23
- module UsingShard
24
- def using(shard)
25
- Octoball::RelationProxy.new(all, shard&.to_sym)
26
- end
27
- end
28
-
29
- ::ActiveRecord::Base.singleton_class.prepend(UsingShard)
6
+ ActiveSupport.on_load(:active_record) do
7
+ require 'octoball/relation_proxy'
8
+ require 'octoball/connection_adapters'
9
+ require 'octoball/current_shard_tracker'
10
+ require 'octoball/association_shard_check'
11
+ require 'octoball/persistence'
12
+ require 'octoball/association'
13
+ require 'octoball/log_subscriber'
14
+ require 'octoball/using_shard'
30
15
  end
data/octoball.gemspec CHANGED
@@ -15,14 +15,14 @@ Gem::Specification.new do |s|
15
15
  s.homepage = 'https://github.com/aktsk/octoball'
16
16
  s.require_paths = ['lib']
17
17
 
18
- s.required_ruby_version = '>= 2.7.0'
18
+ s.required_ruby_version = '>= 3.2.0'
19
19
 
20
- s.add_dependency 'activerecord', '>= 6.1'
21
- s.add_dependency 'activesupport', '>= 6.1'
20
+ s.add_dependency 'activerecord', '>= 7.2'
21
+ s.add_dependency 'activesupport', '>= 7.2'
22
22
 
23
- s.add_development_dependency 'mysql2'
23
+ s.add_development_dependency 'trilogy'
24
24
  s.add_development_dependency 'rake'
25
25
  s.add_development_dependency 'rspec', '>= 3'
26
26
  s.add_development_dependency 'rubocop'
27
- s.add_development_dependency 'byebug'
27
+ s.add_development_dependency 'debug'
28
28
  end
@@ -123,7 +123,7 @@ describe Octoball do
123
123
 
124
124
  it 'should clean #current_shard from proxy when using execute' do
125
125
  User.using(:canada).connection.execute('select * from users limit 1;')
126
- expect(User.connection.current_shard).to eq(:default)
126
+ expect(User.connection.current_shard).to eq(:master)
127
127
  end
128
128
 
129
129
  it 'should allow scoping dynamically' do
@@ -264,7 +264,7 @@ describe Octoball do
264
264
 
265
265
  describe 'AR basic methods' do
266
266
  it 'connects_to' do
267
- expect(CustomConnection.connection.current_database).to eq('octoball_shard_2')
267
+ expect(CustomConnection.connection.current_database).to eq('octoball_shard_3')
268
268
  end
269
269
 
270
270
  it 'reuses parent model connection' do
@@ -590,7 +590,7 @@ describe Octoball do
590
590
  describe 'custom connection' do
591
591
  context 'by default' do
592
592
  it 'with plain call should use custom connection' do
593
- expect(CustomConnection.connection.current_database).to eq('octoball_shard_2')
593
+ expect(CustomConnection.connection.current_database).to eq('octoball_shard_3')
594
594
  end
595
595
 
596
596
  it 'should use model-specific shard' do
@@ -618,7 +618,7 @@ describe Octoball do
618
618
  CustomConnection.create(:value => 'custom value')
619
619
 
620
620
  # This is what Rails, Sidekiq etc call--this normally handles all connection pools in the app
621
- expect { ActiveRecord::Base.clear_active_connections! }
621
+ expect { ActiveRecord::Base.connection_handler.clear_active_connections! }
622
622
  .to change { CustomConnection.connection_pool.active_connection? }
623
623
 
624
624
  expect(CustomConnection.connection_pool.active_connection?).to be_falsey
@@ -39,19 +39,19 @@ describe Octoball do
39
39
  end
40
40
 
41
41
  it 'allows multiple selection by string' do
42
- expect(@evan.select('id, name').first.id).to be_a(Fixnum)
42
+ expect(@evan.select('id, name').first.id).to be_a(Integer)
43
43
  end
44
44
 
45
45
  it 'allows multiple selection by array' do
46
- expect(@evan.select(%w(id name)).first.id).to be_a(Fixnum)
46
+ expect(@evan.select(%w(id name)).first.id).to be_a(Integer)
47
47
  end
48
48
 
49
49
  it 'allows multiple selection by symbol' do
50
- expect(@evan.select(:id, :name).first.id).to be_a(Fixnum)
50
+ expect(@evan.select(:id, :name).first.id).to be_a(Integer)
51
51
  end
52
52
 
53
53
  it 'allows multiple selection by string and symbol' do
54
- expect(@evan.select(:id, 'name').first.id).to be_a(Fixnum)
54
+ expect(@evan.select(:id, 'name').first.id).to be_a(Integer)
55
55
  end
56
56
  end
57
57
 
data/spec/spec_helper.rb CHANGED
@@ -10,9 +10,10 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
10
10
 
11
11
  RSpec.configure do |config|
12
12
  mysql_spec = {
13
- adapter: 'mysql2',
14
- host: (ENV['MYSQL_HOST'] || 'localhost'),
13
+ adapter: 'trilogy',
14
+ host: (ENV['MYSQL_HOST'] || '127.0.0.1'),
15
15
  username: (ENV['MYSQL_USER'] || 'root'),
16
+ port: (ENV['MYSQL_PORT'] || 3306),
16
17
  encoding: 'utf8mb4',
17
18
  }
18
19
  ActiveRecord::Base.configurations = {
@@ -3,9 +3,10 @@ require 'logger'
3
3
  ActiveRecord::Base.logger = Logger.new(File.open('database.log', 'a'))
4
4
 
5
5
  mysql_spec = {
6
- adapter: 'mysql2',
7
- host: (ENV['MYSQL_HOST'] || 'localhost'),
6
+ adapter: 'trilogy',
7
+ host: (ENV['MYSQL_HOST'] || '127.0.0.1'),
8
8
  username: (ENV['MYSQL_USER'] || 'root'),
9
+ port: (ENV['MYSQL_PORT'] || 3306),
9
10
  encoding: 'utf8mb4',
10
11
  }
11
12
 
@@ -20,7 +20,7 @@ end
20
20
  # This class sets its own connection
21
21
  class CustomConnectionBase < ActiveRecord::Base
22
22
  self.abstract_class = true
23
- establish_connection(:adapter => 'mysql2', :host => (ENV['MYSQL_HOST'] || 'localhost'), :database => 'octoball_shard_2', :username => "#{ENV['MYSQL_USER'] || 'root'}", :password => '')
23
+ establish_connection(:adapter => 'trilogy', :host => (ENV['MYSQL_HOST'] || '127.0.0.1'), :database => 'octoball_shard_2', :username => "#{ENV['MYSQL_USER'] || 'root'}", :password => '', :port => (ENV['MYSQL_PORT'] || 3306))
24
24
  connects_to shards: {
25
25
  custom_shard: { writing: :shard3 }
26
26
  }
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octoball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoki Sekiyama
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-12-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activerecord
@@ -16,30 +15,30 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '6.1'
18
+ version: '7.2'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '6.1'
25
+ version: '7.2'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: activesupport
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: '6.1'
32
+ version: '7.2'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: '6.1'
39
+ version: '7.2'
41
40
  - !ruby/object:Gem::Dependency
42
- name: mysql2
41
+ name: trilogy
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - ">="
@@ -95,7 +94,7 @@ dependencies:
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  - !ruby/object:Gem::Dependency
98
- name: byebug
97
+ name: debug
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
@@ -116,8 +115,11 @@ executables: []
116
115
  extensions: []
117
116
  extra_rdoc_files: []
118
117
  files:
119
- - ".circleci/Gemfile"
120
- - ".circleci/config.yml"
118
+ - ".github/Gemfile"
119
+ - ".github/gemfiles/rails_7.2.gemfile"
120
+ - ".github/gemfiles/rails_8.0.gemfile"
121
+ - ".github/gemfiles/rails_8.1.gemfile"
122
+ - ".github/workflows/rspec.yml"
121
123
  - ".gitignore"
122
124
  - Gemfile
123
125
  - README.md
@@ -126,11 +128,11 @@ files:
126
128
  - lib/octoball/association.rb
127
129
  - lib/octoball/association_shard_check.rb
128
130
  - lib/octoball/connection_adapters.rb
129
- - lib/octoball/connection_handling.rb
130
131
  - lib/octoball/current_shard_tracker.rb
131
132
  - lib/octoball/log_subscriber.rb
132
133
  - lib/octoball/persistence.rb
133
134
  - lib/octoball/relation_proxy.rb
135
+ - lib/octoball/using_shard.rb
134
136
  - lib/octoball/version.rb
135
137
  - octoball.gemspec
136
138
  - spec/migration/1_test_tables.rb
@@ -153,7 +155,6 @@ homepage: https://github.com/aktsk/octoball
153
155
  licenses:
154
156
  - MIT
155
157
  metadata: {}
156
- post_install_message:
157
158
  rdoc_options: []
158
159
  require_paths:
159
160
  - lib
@@ -161,15 +162,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
163
  - - ">="
163
164
  - !ruby/object:Gem::Version
164
- version: 2.7.0
165
+ version: 3.2.0
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
168
  - - ">="
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []
171
- rubygems_version: 3.1.6
172
- signing_key:
172
+ rubygems_version: 3.7.0.dev
173
173
  specification_version: 4
174
174
  summary: Octopus-like Database Sharding Helper for ActiveRecord 6.1+
175
175
  test_files: []
data/.circleci/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- if RUBY_VERSION < '3.0'
4
- gem 'activerecord', '~> 6.1.0'
5
- gem 'activesupport', '~> 6.1.0'
6
- end
7
-
8
- gemspec :path => '../'
data/.circleci/config.yml DELETED
@@ -1,48 +0,0 @@
1
- version: 2.1
2
-
3
- executors:
4
- ruby:
5
- parameters:
6
- version:
7
- type: string
8
- docker:
9
- - image: circleci/ruby:<< parameters.version >>
10
- - image: circleci/mysql:5
11
- environment:
12
- - RAILS_ENV: test
13
- - MYSQL_HOST: 127.0.0.1
14
-
15
- jobs:
16
- rspec:
17
- parameters:
18
- version:
19
- type: string
20
- executor:
21
- name: ruby
22
- version: << parameters.version >>
23
- steps:
24
- - checkout
25
- - run:
26
- name: bundle install
27
- command: |
28
- gem update bundler
29
- bundle config --local path ../vendor/bundle
30
- bundle install --gemfile .circleci/Gemfile --jobs=4 --retry=3
31
- bundle config --local path vendor/bundle
32
- - run:
33
- name: Setup databases
34
- command: bundle exec rake db:prepare
35
- - run:
36
- name: Run tests
37
- command: bundle exec rspec
38
-
39
- workflows:
40
- version: 2
41
- rspecs:
42
- jobs:
43
- - rspec:
44
- matrix:
45
- parameters:
46
- version:
47
- - "2.7"
48
- - "3.0"
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Octoball
4
- module ConnectionHandlingAvoidAutoLoadProxy
5
- private
6
-
7
- def swap_connection_handler(handler, &blk)
8
- old_handler, ActiveRecord::Base.connection_handler = ActiveRecord::Base.connection_handler, handler
9
- return_value = yield
10
- return_value.load if !return_value.respond_to?(:ar_relation) && return_value.is_a?(ActiveRecord::Relation)
11
- return_value
12
- ensure
13
- ActiveRecord::Base.connection_handler = old_handler
14
- end
15
- end
16
-
17
- ::ActiveRecord::Base.extend(ConnectionHandlingAvoidAutoLoadProxy)
18
- end