polymorphic_integer_type 3.0.0 → 3.1.1

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: 96fa454bca5e242711a9cc17183c3dbfe7b8c9303bd0bbe1cd246d030761639d
4
- data.tar.gz: 536c3c02769ef0e020e300225e9e1cf453235d5341adc6f98cd973e1d7ea79d1
3
+ metadata.gz: eb3b9a7f294ca84e3f4090aeb66dbd11046cb721e58b51b762d3fac2a77f90e3
4
+ data.tar.gz: 4b9ed1f6e1c36d98a573932bd747780aae00032e238ab8cf7385d6d12d6fb0a3
5
5
  SHA512:
6
- metadata.gz: dae28edc37bb45b1852a9d1f60347e74496d2ba371645514654ae9807a680de40d5487779b219a0fef3cad4ce220b2f0444e51c9907dbd6269653d2082eff1bf
7
- data.tar.gz: 32e6df91034dd5423d8c3787512246e570a1cec2d5d85bdfee2eed2d1932640562dc9ef08881aa6fe09edb1d218597613833ac56389f3807327a28cef7e517db
6
+ metadata.gz: 7a7cb4348a7be18c626d9a611a6005b991b6a09c016c0dd3908e10326da0bc8495072dfcf16ce998a55fce3c8f7bfbce34709df9b3882cceb01dbfe2ff274dc1
7
+ data.tar.gz: 1ddd7ed8095268053c37092ac0f1c8ebf73fee6111dc51bdda027dd4a2e3c4f23d92402ee60724c04f9d7737b06c8a022712683dc23503adf0f2c35b30090159
@@ -0,0 +1 @@
1
+ /.github/workflows/ @clio/application-security @clio/penguins
@@ -0,0 +1,34 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ gemfile:
17
+ - Gemfile.rails-5.0-stable
18
+ - Gemfile.rails-5.1-stable
19
+ - Gemfile.rails-5.2-stable
20
+ - Gemfile.rails-6.0-stable
21
+ - Gemfile.rails-6.1-stable
22
+ env:
23
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: "2.6"
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run:
34
+ bundle exec rspec
@@ -0,0 +1,30 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ release:
5
+ types: [ published ]
6
+
7
+ jobs:
8
+ build:
9
+ name: Build + Publish
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby 2.7
17
+ uses: actions/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.7.x
20
+
21
+ - name: Publish to RubyGems
22
+ env:
23
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
24
+ run: |
25
+ mkdir -p $HOME/.gem
26
+ touch $HOME/.gem/credentials
27
+ chmod 0600 $HOME/.gem/credentials
28
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
+ gem build *.gemspec
30
+ gem push *.gem
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec path: ".."
6
+
7
+ gem "activerecord", github: "rails/rails", branch: "6-1-stable"
@@ -10,7 +10,12 @@ module PolymorphicIntegerType
10
10
  # end
11
11
 
12
12
  def type_to_ids_mapping
13
- association = @associated_table.send(:association)
13
+ if ACTIVE_RECORD_VERSION < Gem::Version.new("6.1")
14
+ association = @associated_table.send(:association)
15
+ else
16
+ association = @associated_table.send(:reflection)
17
+ end
18
+
14
19
  name = association.name
15
20
  default_hash = Hash.new { |hsh, key| hsh[key] = [] }
16
21
  values.each_with_object(default_hash) do |value, hash|
@@ -1,10 +1,17 @@
1
1
  module ActiveRecord
2
2
  module Associations
3
3
  class BelongsToPolymorphicAssociation < BelongsToAssociation
4
- private def replace_keys(record)
5
- super
6
- unless record.nil?
7
- owner[reflection.foreign_type] = record.class.base_class
4
+ private
5
+
6
+ if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("6.1")
7
+ def replace_keys(record)
8
+ super
9
+ owner[reflection.foreign_type] = record.class.base_class unless record.nil?
10
+ end
11
+ elsif
12
+ def replace_keys(record, force: false)
13
+ super
14
+ owner[reflection.foreign_type] = record.class.base_class unless record.nil?
8
15
  end
9
16
  end
10
17
  end
@@ -1,3 +1,3 @@
1
1
  module PolymorphicIntegerType
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.1"
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "activerecord", "< 6.1"
21
+ spec.add_dependency "activerecord", "< 7"
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec"
data/spec/spec_helper.rb CHANGED
@@ -17,14 +17,21 @@ require 'pry'
17
17
  RSpec.configure do |config|
18
18
  config.before(:suite) do
19
19
  database_config = YAML.load(File.open("#{File.dirname(__FILE__)}/support/database.yml"))
20
+ migrations_path = "#{File.dirname(__FILE__)}/support/migrations"
21
+ active_record_version = Gem::Version.new(ActiveRecord::VERSION::STRING)
22
+
20
23
  ActiveRecord::Base.establish_connection(database_config)
21
24
 
22
- if Gem::Version.new(ActiveRecord::VERSION::STRING) == Gem::Version.new("5.2.0")
23
- ActiveRecord::MigrationContext.new("#{File.dirname(__FILE__)}/support/migrations").migrate
25
+ if active_record_version < Gem::Version.new("5.2")
26
+ ActiveRecord::Migrator.migrate(migrations_path)
27
+ end
28
+
29
+ if active_record_version >= Gem::Version.new("5.2") && active_record_version < Gem::Version.new("6.0")
30
+ ActiveRecord::MigrationContext.new(migrations_path).migrate
24
31
  end
25
32
 
26
- if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("6.0")
27
- ActiveRecord::MigrationContext.new("#{File.dirname(__FILE__)}/support/migrations", ActiveRecord::SchemaMigration).migrate
33
+ if active_record_version >= Gem::Version.new("6.0")
34
+ ActiveRecord::MigrationContext.new(migrations_path, ActiveRecord::SchemaMigration).migrate
28
35
  end
29
36
  end
30
37
 
@@ -1,4 +1,4 @@
1
- class CreateLinkTable < ActiveRecord::Migration[5.2]
1
+ class CreateLinkTable < ActiveRecord::Migration[5.0]
2
2
 
3
3
  def up
4
4
  create_table :links do |t|
@@ -1,4 +1,4 @@
1
- class CreateAnimalTable < ActiveRecord::Migration[5.2]
1
+ class CreateAnimalTable < ActiveRecord::Migration[5.0]
2
2
 
3
3
  def up
4
4
  create_table :animals do |t|
@@ -1,4 +1,4 @@
1
- class CreatePersonTable < ActiveRecord::Migration[5.2]
1
+ class CreatePersonTable < ActiveRecord::Migration[5.0]
2
2
 
3
3
  def up
4
4
  create_table :people do |t|
@@ -1,4 +1,4 @@
1
- class CreateFoodTable < ActiveRecord::Migration[5.2]
1
+ class CreateFoodTable < ActiveRecord::Migration[5.0]
2
2
 
3
3
  def up
4
4
  create_table :foods do |t|
@@ -1,4 +1,4 @@
1
- class CreateDrinkTable < ActiveRecord::Migration[5.2]
1
+ class CreateDrinkTable < ActiveRecord::Migration[5.0]
2
2
 
3
3
  def up
4
4
  create_table :drinks do |t|
@@ -1,4 +1,4 @@
1
- class CreatePlantTable < ActiveRecord::Migration[5.2]
1
+ class CreatePlantTable < ActiveRecord::Migration[5.0]
2
2
 
3
3
  def up
4
4
  create_table :plants do |t|
@@ -1,4 +1,4 @@
1
- class CreateActivityTable < ActiveRecord::Migration[5.2]
1
+ class CreateActivityTable < ActiveRecord::Migration[5.0]
2
2
 
3
3
  def up
4
4
  create_table :activities do |t|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polymorphic_integer_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle d'Oliveira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-20 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '6.1'
19
+ version: '7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '6.1'
26
+ version: '7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +102,9 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ".github/CODEOWNERS"
106
+ - ".github/workflows/ci.yml"
107
+ - ".github/workflows/gem-push.yml"
105
108
  - ".gitignore"
106
109
  - Gemfile
107
110
  - LICENSE.txt
@@ -109,13 +112,10 @@ files:
109
112
  - Rakefile
110
113
  - bin/setup
111
114
  - gemfiles/Gemfile.rails-5.0-stable
112
- - gemfiles/Gemfile.rails-5.0-stable.lock
113
115
  - gemfiles/Gemfile.rails-5.1-stable
114
- - gemfiles/Gemfile.rails-5.1-stable.lock
115
116
  - gemfiles/Gemfile.rails-5.2-stable
116
- - gemfiles/Gemfile.rails-5.2-stable.lock
117
- - gemfiles/Gemfile.rails-6-0-stable
118
- - gemfiles/Gemfile.rails-6-0-stable.lock
117
+ - gemfiles/Gemfile.rails-6.0-stable
118
+ - gemfiles/Gemfile.rails-6.1-stable
119
119
  - lib/polymorphic_integer_type.rb
120
120
  - lib/polymorphic_integer_type/activerecord_5_0_0/association_query_handler_extension.rb
121
121
  - lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb
@@ -149,7 +149,7 @@ homepage: ''
149
149
  licenses:
150
150
  - MIT
151
151
  metadata: {}
152
- post_install_message:
152
+ post_install_message:
153
153
  rdoc_options: []
154
154
  require_paths:
155
155
  - lib
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubygems_version: 3.1.6
168
- signing_key:
168
+ signing_key:
169
169
  specification_version: 4
170
170
  summary: Use integers rather than strings for the _type field
171
171
  test_files:
@@ -1,74 +0,0 @@
1
- GIT
2
- remote: https://github.com/rails/rails.git
3
- revision: ac6aa32f7cf66264ba87eabed7c042bb60bcf3a2
4
- branch: 5-0-stable
5
- specs:
6
- activemodel (5.0.7.2)
7
- activesupport (= 5.0.7.2)
8
- activerecord (5.0.7.2)
9
- activemodel (= 5.0.7.2)
10
- activesupport (= 5.0.7.2)
11
- arel (~> 7.0)
12
- activesupport (5.0.7.2)
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
-
18
- PATH
19
- remote: ..
20
- specs:
21
- polymorphic_integer_type (3.0.0)
22
- activerecord (< 6.1)
23
-
24
- GEM
25
- remote: https://rubygems.org/
26
- specs:
27
- arel (7.1.4)
28
- byebug (11.1.3)
29
- coderay (1.1.3)
30
- concurrent-ruby (1.1.8)
31
- diff-lcs (1.4.4)
32
- i18n (1.8.10)
33
- concurrent-ruby (~> 1.0)
34
- method_source (1.0.0)
35
- minitest (5.14.4)
36
- pry (0.13.1)
37
- coderay (~> 1.1)
38
- method_source (~> 1.0)
39
- pry-byebug (3.9.0)
40
- byebug (~> 11.0)
41
- pry (~> 0.13.0)
42
- rake (13.0.3)
43
- rspec (3.10.0)
44
- rspec-core (~> 3.10.0)
45
- rspec-expectations (~> 3.10.0)
46
- rspec-mocks (~> 3.10.0)
47
- rspec-core (3.10.1)
48
- rspec-support (~> 3.10.0)
49
- rspec-expectations (3.10.1)
50
- diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.10.0)
52
- rspec-mocks (3.10.2)
53
- diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.10.0)
55
- rspec-support (3.10.2)
56
- sqlite3 (1.3.13)
57
- thread_safe (0.3.6)
58
- tzinfo (1.2.9)
59
- thread_safe (~> 0.1)
60
-
61
- PLATFORMS
62
- ruby
63
-
64
- DEPENDENCIES
65
- activerecord!
66
- bundler
67
- polymorphic_integer_type!
68
- pry-byebug
69
- rake
70
- rspec
71
- sqlite3 (~> 1.3.6)
72
-
73
- BUNDLED WITH
74
- 2.1.4
@@ -1,74 +0,0 @@
1
- GIT
2
- remote: https://github.com/rails/rails.git
3
- revision: 663206d20aec374a28a24bb43bc7b1233042ed9b
4
- branch: 5-1-stable
5
- specs:
6
- activemodel (5.1.7)
7
- activesupport (= 5.1.7)
8
- activerecord (5.1.7)
9
- activemodel (= 5.1.7)
10
- activesupport (= 5.1.7)
11
- arel (~> 8.0)
12
- activesupport (5.1.7)
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
-
18
- PATH
19
- remote: ..
20
- specs:
21
- polymorphic_integer_type (3.0.0)
22
- activerecord (< 6.1)
23
-
24
- GEM
25
- remote: https://rubygems.org/
26
- specs:
27
- arel (8.0.0)
28
- byebug (11.1.3)
29
- coderay (1.1.3)
30
- concurrent-ruby (1.1.8)
31
- diff-lcs (1.4.4)
32
- i18n (1.8.10)
33
- concurrent-ruby (~> 1.0)
34
- method_source (1.0.0)
35
- minitest (5.14.4)
36
- pry (0.13.1)
37
- coderay (~> 1.1)
38
- method_source (~> 1.0)
39
- pry-byebug (3.9.0)
40
- byebug (~> 11.0)
41
- pry (~> 0.13.0)
42
- rake (13.0.3)
43
- rspec (3.10.0)
44
- rspec-core (~> 3.10.0)
45
- rspec-expectations (~> 3.10.0)
46
- rspec-mocks (~> 3.10.0)
47
- rspec-core (3.10.1)
48
- rspec-support (~> 3.10.0)
49
- rspec-expectations (3.10.1)
50
- diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.10.0)
52
- rspec-mocks (3.10.2)
53
- diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.10.0)
55
- rspec-support (3.10.2)
56
- sqlite3 (1.4.2)
57
- thread_safe (0.3.6)
58
- tzinfo (1.2.9)
59
- thread_safe (~> 0.1)
60
-
61
- PLATFORMS
62
- ruby
63
-
64
- DEPENDENCIES
65
- activerecord!
66
- bundler
67
- polymorphic_integer_type!
68
- pry-byebug
69
- rake
70
- rspec
71
- sqlite3
72
-
73
- BUNDLED WITH
74
- 2.1.4
@@ -1,74 +0,0 @@
1
- GIT
2
- remote: https://github.com/rails/rails.git
3
- revision: 48661542a2607d55f436438fe21001d262e61fec
4
- branch: 5-2-stable
5
- specs:
6
- activemodel (5.2.6)
7
- activesupport (= 5.2.6)
8
- activerecord (5.2.6)
9
- activemodel (= 5.2.6)
10
- activesupport (= 5.2.6)
11
- arel (>= 9.0)
12
- activesupport (5.2.6)
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
-
18
- PATH
19
- remote: ..
20
- specs:
21
- polymorphic_integer_type (3.0.0)
22
- activerecord (< 6.1)
23
-
24
- GEM
25
- remote: https://rubygems.org/
26
- specs:
27
- arel (9.0.0)
28
- byebug (11.1.3)
29
- coderay (1.1.3)
30
- concurrent-ruby (1.1.8)
31
- diff-lcs (1.4.4)
32
- i18n (1.8.10)
33
- concurrent-ruby (~> 1.0)
34
- method_source (1.0.0)
35
- minitest (5.14.4)
36
- pry (0.13.1)
37
- coderay (~> 1.1)
38
- method_source (~> 1.0)
39
- pry-byebug (3.9.0)
40
- byebug (~> 11.0)
41
- pry (~> 0.13.0)
42
- rake (13.0.3)
43
- rspec (3.10.0)
44
- rspec-core (~> 3.10.0)
45
- rspec-expectations (~> 3.10.0)
46
- rspec-mocks (~> 3.10.0)
47
- rspec-core (3.10.1)
48
- rspec-support (~> 3.10.0)
49
- rspec-expectations (3.10.1)
50
- diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.10.0)
52
- rspec-mocks (3.10.2)
53
- diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.10.0)
55
- rspec-support (3.10.2)
56
- sqlite3 (1.4.2)
57
- thread_safe (0.3.6)
58
- tzinfo (1.2.9)
59
- thread_safe (~> 0.1)
60
-
61
- PLATFORMS
62
- ruby
63
-
64
- DEPENDENCIES
65
- activerecord!
66
- bundler
67
- polymorphic_integer_type!
68
- pry-byebug
69
- rake
70
- rspec
71
- sqlite3
72
-
73
- BUNDLED WITH
74
- 2.1.4
@@ -1,74 +0,0 @@
1
- GIT
2
- remote: https://github.com/rails/rails.git
3
- revision: ef97441036e0ebbe1aa2108d59c408707f998ffd
4
- branch: 6-0-stable
5
- specs:
6
- activemodel (6.0.3.7)
7
- activesupport (= 6.0.3.7)
8
- activerecord (6.0.3.7)
9
- activemodel (= 6.0.3.7)
10
- activesupport (= 6.0.3.7)
11
- activesupport (6.0.3.7)
12
- concurrent-ruby (~> 1.0, >= 1.0.2)
13
- i18n (>= 0.7, < 2)
14
- minitest (~> 5.1)
15
- tzinfo (~> 1.1)
16
- zeitwerk (~> 2.2, >= 2.2.2)
17
-
18
- PATH
19
- remote: ..
20
- specs:
21
- polymorphic_integer_type (3.0.0)
22
- activerecord (< 6.1)
23
-
24
- GEM
25
- remote: https://rubygems.org/
26
- specs:
27
- byebug (11.1.3)
28
- coderay (1.1.3)
29
- concurrent-ruby (1.1.8)
30
- diff-lcs (1.4.4)
31
- i18n (1.8.10)
32
- concurrent-ruby (~> 1.0)
33
- method_source (1.0.0)
34
- minitest (5.14.4)
35
- pry (0.13.1)
36
- coderay (~> 1.1)
37
- method_source (~> 1.0)
38
- pry-byebug (3.9.0)
39
- byebug (~> 11.0)
40
- pry (~> 0.13.0)
41
- rake (13.0.3)
42
- rspec (3.10.0)
43
- rspec-core (~> 3.10.0)
44
- rspec-expectations (~> 3.10.0)
45
- rspec-mocks (~> 3.10.0)
46
- rspec-core (3.10.1)
47
- rspec-support (~> 3.10.0)
48
- rspec-expectations (3.10.1)
49
- diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.10.0)
51
- rspec-mocks (3.10.2)
52
- diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.10.0)
54
- rspec-support (3.10.2)
55
- sqlite3 (1.4.2)
56
- thread_safe (0.3.6)
57
- tzinfo (1.2.9)
58
- thread_safe (~> 0.1)
59
- zeitwerk (2.4.2)
60
-
61
- PLATFORMS
62
- ruby
63
-
64
- DEPENDENCIES
65
- activerecord!
66
- bundler
67
- polymorphic_integer_type!
68
- pry-byebug
69
- rake
70
- rspec
71
- sqlite3
72
-
73
- BUNDLED WITH
74
- 2.1.4