octoshark 0.2.2 → 0.3.0

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
- SHA1:
3
- metadata.gz: 7a5b422e9a70b5d3ea461f8f1d60d00fdf95fcc2
4
- data.tar.gz: 67b85692596f3c3414239b4820a0415e40c09af4
2
+ SHA256:
3
+ metadata.gz: 743be64d2aeb897827aec871dfd86150ea1ca7ce6505839cea1caf16e85676bc
4
+ data.tar.gz: a801773571a7388fed3d16179be6006d10a6e060fb514813a2e21ba3532816ee
5
5
  SHA512:
6
- metadata.gz: 41d351c20e433d40caa1f3e1888360911a8440a03aeded1092d618b78b91febbf6f3a8cdffc8e537ee6cf482d017500a495019191902a6f77904c165c236e099
7
- data.tar.gz: a1f0f8e84cd69a8445e5ce0e6c9abcb53ac1a9b144d7141f8e36ea3596a2ec15c639a6515da9df8554f3e37066aa3368bae76794d2b990ed88ca542b197a96ed
6
+ metadata.gz: 2fa8e793d0eae00f5d99420e1f3b5bc6218b9b5a5b8c27b0c63dbbde080265d5797cc4d56cbce049cd25459e0f8961228f0acb5d677f35f1de45a42fbd82f610
7
+ data.tar.gz: 16f82b5d43d619ff5d8691229a8377189c10ef3b9d20752649d2e63725bff171afe9f232d2300916b573bff7260ff63d92be08bae567934ff7751285d6240728
@@ -0,0 +1,66 @@
1
+ name: Build Legacy
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - "*"
7
+ push:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-16.04
14
+ services:
15
+ mysql:
16
+ image: mysql:5.5
17
+ env:
18
+ MYSQL_ROOT_PASSWORD: pass
19
+ ports:
20
+ - "3306:3306"
21
+ options: >-
22
+ --health-cmd="mysqladmin ping"
23
+ --health-interval=10s
24
+ --health-timeout=5s
25
+ --health-retries=3
26
+
27
+ name: ruby-${{ matrix.ruby }} ${{ matrix.gemfile }}
28
+ strategy:
29
+ matrix:
30
+ include:
31
+ - gemfile: rails3.0
32
+ ruby: 2.2
33
+ - gemfile: rails3.1
34
+ ruby: 2.2
35
+ - gemfile: rails3.2
36
+ ruby: 2.2
37
+
38
+ - gemfile: rails4.0
39
+ ruby: 2.4
40
+ - gemfile: rails4.1
41
+ ruby: 2.4
42
+ - gemfile: rails4.2
43
+ ruby: 2.4
44
+
45
+ env:
46
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
47
+ BUNDLE_PATH_RELATIVE_TO_CWD: true
48
+
49
+ steps:
50
+ - uses: actions/checkout@master
51
+
52
+ - name: Set up Ruby
53
+ uses: ruby/setup-ruby@v1
54
+ with:
55
+ ruby-version: ${{ matrix.ruby }}
56
+ bundler: default
57
+ bundler-cache: true
58
+
59
+ - name: Set up database
60
+ run: |
61
+ cp spec/support/config.yml.github spec/support/config.yml
62
+ bundle exec rake db:create
63
+
64
+ - name: Run tests
65
+ run: |
66
+ bundle exec rspec spec
@@ -0,0 +1,64 @@
1
+ name: Build
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - "*"
7
+ push:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ services:
15
+ mysql:
16
+ image: mysql:5.7
17
+ env:
18
+ MYSQL_ROOT_PASSWORD: pass
19
+ ports:
20
+ - "3306:3306"
21
+ options: >-
22
+ --health-cmd="mysqladmin ping"
23
+ --health-interval=10s
24
+ --health-timeout=5s
25
+ --health-retries=3
26
+
27
+ name: ruby-${{ matrix.ruby }} ${{ matrix.gemfile }}
28
+ strategy:
29
+ matrix:
30
+ include:
31
+ - gemfile: rails5.0
32
+ ruby: 2.6
33
+ - gemfile: rails5.1
34
+ ruby: 2.6
35
+ - gemfile: rails5.2
36
+ ruby: 2.6
37
+
38
+ - gemfile: rails6.0
39
+ ruby: 2.7
40
+ - gemfile: rails6.1
41
+ ruby: 2.7
42
+
43
+ env:
44
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
45
+ BUNDLE_PATH_RELATIVE_TO_CWD: true
46
+
47
+ steps:
48
+ - uses: actions/checkout@master
49
+
50
+ - name: Set up Ruby
51
+ uses: ruby/setup-ruby@v1
52
+ with:
53
+ ruby-version: ${{ matrix.ruby }}
54
+ bundler: default
55
+ bundler-cache: true
56
+
57
+ - name: Set up database
58
+ run: |
59
+ cp spec/support/config.yml.github spec/support/config.yml
60
+ bundle exec rake db:create
61
+
62
+ - name: Run tests
63
+ run: |
64
+ bundle exec rspec spec
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.2
1
+ 2.7.4
data/Appraisals CHANGED
@@ -1,28 +1,29 @@
1
- appraise "rails3.0" do
2
- gem "activerecord", "~> 3.0.0"
3
- gem "mysql2", '< 0.3'
4
- end
5
-
6
- appraise "rails3.1" do
7
- gem "activerecord", "~> 3.1.0"
8
- end
9
-
10
- appraise "rails3.2" do
11
- gem "activerecord", "~> 3.2.0"
1
+ appraise "rails5.0" do
2
+ gem "activerecord", "~> 5.0.0"
3
+ gem "mysql2", "~> 0.5.2"
4
+ gem "sqlite3", "~> 1.3.13"
12
5
  end
13
6
 
14
- appraise "rails4.0" do
15
- gem "activerecord", "~> 4.0.0"
7
+ appraise "rails5.1" do
8
+ gem "activerecord", "~> 5.1.0"
9
+ gem "mysql2", "~> 0.5.2"
10
+ gem "sqlite3", "~> 1.4.1"
16
11
  end
17
12
 
18
- appraise "rails4.1" do
19
- gem "activerecord", "~> 4.1.0"
13
+ appraise "rails5.2" do
14
+ gem "activerecord", "~> 5.2.0"
15
+ gem "mysql2", "~> 0.5.2"
16
+ gem "sqlite3", "~> 1.4.1"
20
17
  end
21
18
 
22
- appraise "rails4.2" do
23
- gem "activerecord", "~> 4.2.0"
19
+ appraise "rails6.0" do
20
+ gem "activerecord", "~> 6.0.0"
21
+ gem "mysql2", "~> 0.5.2"
22
+ gem "sqlite3", "~> 1.4.1"
24
23
  end
25
24
 
26
- appraise "rails5.0" do
27
- gem "activerecord", "~> 5.0.0"
25
+ appraise "rails6.1" do
26
+ gem "activerecord", "~> 6.1.0"
27
+ gem "mysql2", "~> 0.5.2"
28
+ gem "sqlite3", "~> 1.4.1"
28
29
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change log
2
2
 
3
+ ## 0.3.0 2021-07-20
4
+
5
+ - Add support for Rails 6.1
6
+
3
7
  ## 0.2.2 2016-11-09
4
8
 
5
9
  - Fix `alias_method_chain` deprecation in Rails 5
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
+ gem "activerecord", "~> 6.1.0"
2
3
 
3
4
  # Specify your gem's dependencies in octoshark.gemspec
4
5
  gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![Octoshark logo](https://dl.dropboxusercontent.com/u/3230730/github/octoshark.png)
1
+ ![Octoshark logo](http://dalibornasevic.com/images/octoshark.png)
2
2
 
3
3
  ![Travis status](https://travis-ci.org/dalibor/octoshark.png)
4
4
 
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ namespace :db do
19
19
  task :create => :establish_connection do
20
20
  @databases.each do |database|
21
21
  begin
22
- ActiveRecord::Base.connection.create_database(database)
22
+ ActiveRecord::Base.connection.create_database(database, charset: 'utf8')
23
23
  puts "#{database} created."
24
24
  rescue ActiveRecord::StatementInvalid => e
25
25
  if e.message.match /database exists/
@@ -4,5 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 3.0.0"
6
6
  gem "mysql2", "< 0.3"
7
+ gem "sqlite3", "~> 1.3.13"
7
8
 
8
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 3.1.0"
6
+ gem "mysql2", "~> 0.3.10"
7
+ gem "sqlite3", "~> 1.3.13"
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 3.2.0"
6
+ gem "mysql2", "~> 0.3.10"
7
+ gem "sqlite3", "~> 1.3.13"
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 4.0.0"
6
+ gem "mysql2", "~> 0.3.10"
7
+ gem "sqlite3", "~> 1.3.13"
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 4.1.0"
6
+ gem "mysql2", "~> 0.3.13"
7
+ gem "sqlite3", "~> 1.3.13"
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 4.2.0"
6
+ gem "mysql2", "~> 0.3.13"
7
+ gem "sqlite3", "~> 1.3.13"
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -3,5 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.0.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.3.13"
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.1.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.4.1"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.2.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.4.1"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.0.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.4.1"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.1.0"
6
+ gem "mysql2", "~> 0.5.2"
7
+ gem "sqlite3", "~> 1.4.1"
8
+
9
+ gemspec path: "../"
@@ -61,14 +61,6 @@ module Octoshark
61
61
  end
62
62
 
63
63
  private
64
- def spec_class
65
- if defined?(ActiveRecord::ConnectionAdapters::ConnectionSpecification)
66
- spec_class = ActiveRecord::ConnectionAdapters::ConnectionSpecification
67
- else
68
- # Rails 3.0, 3.1 and 3.2
69
- spec_class = ActiveRecord::Base::ConnectionSpecification
70
- end
71
- end
72
64
 
73
65
  def setup_connection_pools
74
66
  @connection_pools = HashWithIndifferentAccess.new
@@ -79,13 +71,24 @@ module Octoshark
79
71
  end
80
72
 
81
73
  def create_connection_pool(name, config)
82
- adapter_method = "#{config[:adapter]}_connection"
83
74
  spec =
84
- if spec_class.instance_method(:initialize).arity == 3
85
- # Rails 5 ConnectionSpecification accepts spec name
86
- spec_class.new(name, config, adapter_method)
75
+ if defined?(ActiveRecord::ConnectionAdapters::PoolConfig)
76
+ env_name = defined?(Rails) ? Rails.env : nil
77
+ db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(env_name, name, config)
78
+ ActiveRecord::ConnectionAdapters::PoolConfig.new(owner_name = ActiveRecord::Base, db_config)
87
79
  else
88
- spec_class.new(config, adapter_method)
80
+ adapter_method = "#{config[:adapter]}_connection"
81
+ if defined?(ActiveRecord::ConnectionAdapters::ConnectionSpecification)
82
+ spec_class = ActiveRecord::ConnectionAdapters::ConnectionSpecification
83
+
84
+ if spec_class.instance_method(:initialize).arity == 3
85
+ spec_class.new(name, config, adapter_method)
86
+ else
87
+ spec_class.new(config, adapter_method)
88
+ end
89
+ else
90
+ ActiveRecord::Base::ConnectionSpecification.new(config, adapter_method)
91
+ end
89
92
  end
90
93
 
91
94
  ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec)
@@ -1,3 +1,3 @@
1
1
  module Octoshark
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
data/octoshark.gemspec CHANGED
@@ -20,10 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency "activerecord", ">= 3.0"
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.5"
24
23
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec", "~> 3.0.0"
26
- spec.add_development_dependency "sqlite3", "~> 1.3.0"
27
- spec.add_development_dependency "mysql2", "~> 0.3.14"
24
+ spec.add_development_dependency "rspec", "~> 3.7.0"
25
+ spec.add_development_dependency "sqlite3", "~> 1.4.1"
26
+ spec.add_development_dependency "mysql2", "~> 0.5.2"
28
27
  spec.add_development_dependency "appraisal"
29
28
  end
@@ -42,7 +42,7 @@ describe Octoshark::ConnectionManager do
42
42
  connection.execute("SELECT 1")
43
43
  end
44
44
 
45
- expect(result).to eq([{"1"=>1, 0=>1}])
45
+ expect(result.first['1']).to eq(1)
46
46
  end
47
47
  end
48
48
  end
@@ -67,7 +67,7 @@ describe Octoshark::ConnectionPoolsManager do
67
67
  it "returns value from execution" do
68
68
  manager = Octoshark::ConnectionPoolsManager.new(configs)
69
69
  result = manager.with_connection(:db1) { |connection| connection.execute("SELECT 1") }
70
- expect(result).to eq([{"1"=>1, 0=>1}])
70
+ expect(result.first['1']).to eq(1)
71
71
  end
72
72
 
73
73
  it "raises Octoshark::Error::NoConnection" do
@@ -4,9 +4,9 @@ db1:
4
4
  reconnect: false
5
5
  database: octoshark_db1
6
6
  pool: 5
7
- username: travis
8
- password:
9
- host: localhost
7
+ username: root
8
+ password: pass
9
+ host: 127.0.0.1
10
10
  port: 3306
11
11
 
12
12
  db2:
@@ -15,7 +15,7 @@ db2:
15
15
  reconnect: false
16
16
  database: octoshark_db2
17
17
  pool: 5
18
- username: travis
19
- password:
20
- host: localhost
18
+ username: root
19
+ password: pass
20
+ host: 127.0.0.1
21
21
  port: 3306
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.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dalibor Nasevic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.5'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.5'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,42 +44,42 @@ dependencies:
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 3.0.0
47
+ version: 3.7.0
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 3.0.0
54
+ version: 3.7.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: sqlite3
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 1.3.0
61
+ version: 1.4.1
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 1.3.0
68
+ version: 1.4.1
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: mysql2
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 0.3.14
75
+ version: 0.5.2
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 0.3.14
82
+ version: 0.5.2
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: appraisal
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -115,10 +101,11 @@ executables: []
115
101
  extensions: []
116
102
  extra_rdoc_files: []
117
103
  files:
104
+ - ".github/workflows/ci-legacy.yml"
105
+ - ".github/workflows/ci.yml"
118
106
  - ".gitignore"
119
107
  - ".rspec"
120
108
  - ".ruby-version"
121
- - ".travis.yml"
122
109
  - Appraisals
123
110
  - CHANGELOG.md
124
111
  - Gemfile
@@ -132,6 +119,10 @@ files:
132
119
  - gemfiles/rails4.1.gemfile
133
120
  - gemfiles/rails4.2.gemfile
134
121
  - gemfiles/rails5.0.gemfile
122
+ - gemfiles/rails5.1.gemfile
123
+ - gemfiles/rails5.2.gemfile
124
+ - gemfiles/rails6.0.gemfile
125
+ - gemfiles/rails6.1.gemfile
135
126
  - lib/octoshark.rb
136
127
  - lib/octoshark/active_record_extensions.rb
137
128
  - lib/octoshark/connection_manager.rb
@@ -145,14 +136,14 @@ files:
145
136
  - spec/octoshark/connection_pools_manager_spec.rb
146
137
  - spec/octoshark/current_connection_spec.rb
147
138
  - spec/spec_helper.rb
139
+ - spec/support/config.yml.github
148
140
  - spec/support/config.yml.template
149
- - spec/support/config.yml.travis
150
141
  - spec/support/helpers.rb
151
142
  homepage: https://github.com/dalibor/octoshark
152
143
  licenses:
153
144
  - MIT
154
145
  metadata: {}
155
- post_install_message:
146
+ post_install_message:
156
147
  rdoc_options: []
157
148
  require_paths:
158
149
  - lib
@@ -167,9 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
158
  - !ruby/object:Gem::Version
168
159
  version: '0'
169
160
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 2.4.5
172
- signing_key:
161
+ rubygems_version: 3.1.6
162
+ signing_key:
173
163
  specification_version: 4
174
164
  summary: Octoshark is an ActiveRecord connection switcher
175
165
  test_files:
@@ -178,6 +168,6 @@ test_files:
178
168
  - spec/octoshark/connection_pools_manager_spec.rb
179
169
  - spec/octoshark/current_connection_spec.rb
180
170
  - spec/spec_helper.rb
171
+ - spec/support/config.yml.github
181
172
  - spec/support/config.yml.template
182
- - spec/support/config.yml.travis
183
173
  - spec/support/helpers.rb
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- rvm:
2
- - 2.2.2
3
- cache:
4
- - bundler
5
- notifications:
6
- email:
7
- - dalibor.nasevic@gmail.com
8
- gemfile:
9
- - gemfiles/rails3.0.gemfile
10
- - gemfiles/rails3.1.gemfile
11
- - gemfiles/rails3.2.gemfile
12
- - gemfiles/rails4.0.gemfile
13
- - gemfiles/rails4.1.gemfile
14
- - gemfiles/rails4.2.gemfile
15
- - gemfiles/rails5.0.gemfile
16
- before_script:
17
- - cp spec/support/config.yml.travis spec/support/config.yml
18
- - bundle exec rake db:create
19
- script:
20
- - bundle exec rspec spec