rails_compatibility 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +44 -17
- data/CHANGELOG.md +9 -0
- data/README.md +2 -2
- data/gemfiles/7.0.gemfile +12 -0
- data/lib/rails_compatibility/active_record.rb +1 -0
- data/lib/rails_compatibility/cast_values.rb +45 -0
- data/lib/rails_compatibility/deserialize.rb +17 -0
- data/lib/rails_compatibility/setup_autoload_paths.rb +25 -0
- data/lib/rails_compatibility/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c219e0fdf9b8fd4c4eddbd1b0a14a325932b9e9b54d4e3769bc8e3cfcff1196e
|
4
|
+
data.tar.gz: 55d3190a204319f37b82a3bc8dba1fd0b8d8ee404ef1f8d562ec0f8762077f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd440b56ff89b8c8d972ede08988bb0bf83f14ab3aefef78c32eaba37500f36b9e178ef8fb1f6e6d937550bf906aab8cc9c5703d3e769f739bb0b7f6c9801bc5
|
7
|
+
data.tar.gz: 1eed03d043721a4246499686a2c701774090d9028ed9c78dd708f5658b775999421c1186802d1704c306e7478f792507ce139f15b52cf2c060d7a6373baa1b83
|
data/.github/workflows/ruby.yml
CHANGED
@@ -20,9 +20,11 @@ jobs:
|
|
20
20
|
fail-fast: false
|
21
21
|
matrix:
|
22
22
|
ruby:
|
23
|
-
- 2.
|
23
|
+
- 2.3
|
24
24
|
- 2.6
|
25
25
|
- 2.7
|
26
|
+
- 3.0
|
27
|
+
- 3.1
|
26
28
|
gemfile:
|
27
29
|
- 3.2.gemfile
|
28
30
|
- 4.2.gemfile
|
@@ -31,32 +33,57 @@ jobs:
|
|
31
33
|
- 5.2.gemfile
|
32
34
|
- 6.0.gemfile
|
33
35
|
- 6.1.gemfile
|
36
|
+
- 7.0.gemfile
|
34
37
|
exclude:
|
35
38
|
- gemfile: 3.2.gemfile
|
36
39
|
ruby: 2.6
|
37
40
|
- gemfile: 3.2.gemfile
|
38
41
|
ruby: 2.7
|
42
|
+
- gemfile: 3.2.gemfile
|
43
|
+
ruby: 3.0
|
44
|
+
- gemfile: 3.2.gemfile
|
45
|
+
ruby: 3.1
|
39
46
|
- gemfile: 4.2.gemfile
|
40
47
|
ruby: 2.7
|
48
|
+
- gemfile: 4.2.gemfile
|
49
|
+
ruby: 3.0
|
50
|
+
- gemfile: 4.2.gemfile
|
51
|
+
ruby: 3.1
|
52
|
+
- gemfile: 5.0.gemfile
|
53
|
+
ruby: 3.0
|
54
|
+
- gemfile: 5.0.gemfile
|
55
|
+
ruby: 3.1
|
56
|
+
- gemfile: 5.1.gemfile
|
57
|
+
ruby: 3.0
|
58
|
+
- gemfile: 5.1.gemfile
|
59
|
+
ruby: 3.1
|
60
|
+
- gemfile: 5.2.gemfile
|
61
|
+
ruby: 3.0
|
62
|
+
- gemfile: 5.2.gemfile
|
63
|
+
ruby: 3.1
|
41
64
|
- gemfile: 6.0.gemfile
|
42
|
-
ruby: 2.
|
65
|
+
ruby: 2.3
|
43
66
|
- gemfile: 6.1.gemfile
|
44
|
-
ruby: 2.
|
67
|
+
ruby: 2.3
|
68
|
+
- gemfile: 7.0.gemfile
|
69
|
+
ruby: 2.3
|
70
|
+
- gemfile: 7.0.gemfile
|
71
|
+
ruby: 2.6
|
45
72
|
env:
|
46
73
|
BUNDLE_GEMFILE: "gemfiles/${{ matrix.gemfile }}"
|
47
74
|
|
48
75
|
steps:
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
76
|
+
- name: Checkout
|
77
|
+
uses: actions/checkout@v2
|
78
|
+
- name: Setup Ruby
|
79
|
+
uses: ruby/setup-ruby@v1
|
80
|
+
with:
|
81
|
+
ruby-version: ${{ matrix.ruby }}
|
82
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
83
|
+
- name: Run tests
|
84
|
+
run: bundle exec rake
|
85
|
+
- name: Publish code coverage
|
86
|
+
if: ${{ success() }}
|
87
|
+
uses: paambaati/codeclimate-action@v2.7.5
|
88
|
+
env:
|
89
|
+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## Change Log
|
2
2
|
|
3
|
+
### [v0.0.8](https://github.com/khiav223577/rails_compatibility/compare/v0.0.7...v0.0.8) 2022/01/21
|
4
|
+
- [#16](https://github.com/khiav223577/rails_compatibility/pull/16) Implement #setup_autoload_paths (@khiav223577)
|
5
|
+
- [#15](https://github.com/khiav223577/rails_compatibility/pull/15) Support Rails 7.0 (@khiav223577)
|
6
|
+
- [#14](https://github.com/khiav223577/rails_compatibility/pull/14) Support Ruby 3.1 (@khiav223577)
|
7
|
+
- [#13](https://github.com/khiav223577/rails_compatibility/pull/13) Support Ruby 3.0 (@khiav223577)
|
8
|
+
|
9
|
+
### [v0.0.7](https://github.com/khiav223577/rails_compatibility/compare/v0.0.6...v0.0.7) 2021/06/10
|
10
|
+
- [#12](https://github.com/khiav223577/rails_compatibility/pull/12) Implement #apply_join_dependency (@khiav223577)
|
11
|
+
|
3
12
|
### [v0.0.6](https://github.com/khiav223577/rails_compatibility/compare/v0.0.5...v0.0.6) 2021/06/10
|
4
13
|
- [#11](https://github.com/khiav223577/rails_compatibility/pull/11) Implement #has_include? (@khiav223577)
|
5
14
|
|
data/README.md
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
[![Test Coverage](https://codeclimate.com/github/khiav223577/rails_compatibility/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/rails_compatibility/coverage)
|
8
8
|
|
9
9
|
## Supports
|
10
|
-
- Ruby 2.
|
11
|
-
- Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0
|
10
|
+
- Ruby 2.3 ~ 2.7, 3.0 ~ 3.1
|
11
|
+
- Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -4,6 +4,7 @@ require 'rails_compatibility'
|
|
4
4
|
require 'active_record'
|
5
5
|
|
6
6
|
class << RailsCompatibility
|
7
|
+
GTE_RAILS_7_0 = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.0.0')
|
7
8
|
GTE_RAILS_6_1 = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('6.1.0')
|
8
9
|
GTE_RAILS_6_0 = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('6.0.0')
|
9
10
|
GTE_RAILS_5_2 = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('5.2.0')
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_compatibility'
|
4
|
+
require 'rails_compatibility/active_record'
|
5
|
+
require 'rails_compatibility/deserialize'
|
6
|
+
|
7
|
+
class << RailsCompatibility
|
8
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.0.6')
|
9
|
+
# Rails 7.0.6 changes parameter handling. Details at: https://github.com/rails/rails/pull/45783
|
10
|
+
def cast_values(klass, result)
|
11
|
+
attribute_types = self.attribute_types(klass)
|
12
|
+
|
13
|
+
result.map do |attributes| # This map behaves different to array#map
|
14
|
+
attributes.each_with_index do |(key, attribute), index|
|
15
|
+
attributes[key] = deserialize(result.send(:column_type, key, index, attribute_types), attribute)
|
16
|
+
end
|
17
|
+
|
18
|
+
next attributes
|
19
|
+
end
|
20
|
+
end
|
21
|
+
elsif GTE_RAILS_4_0
|
22
|
+
def cast_values(klass, result)
|
23
|
+
attribute_types = self.attribute_types(klass)
|
24
|
+
|
25
|
+
result.map do |attributes| # This map behaves different to array#map
|
26
|
+
attributes.each do |key, attribute|
|
27
|
+
attributes[key] = deserialize(result.send(:column_type, key, attribute_types), attribute)
|
28
|
+
end
|
29
|
+
|
30
|
+
next attributes
|
31
|
+
end
|
32
|
+
end
|
33
|
+
else
|
34
|
+
def cast_values(klass, result)
|
35
|
+
result.map! do |attributes| # This map! behaves different to array#map!
|
36
|
+
initialized_attributes = klass.initialize_attributes(attributes)
|
37
|
+
attributes.each do |key, _attribute|
|
38
|
+
attributes[key] = klass.type_cast_attribute(key, initialized_attributes)
|
39
|
+
end
|
40
|
+
|
41
|
+
next attributes
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_compatibility'
|
4
|
+
require 'rails_compatibility/active_record'
|
5
|
+
|
6
|
+
class << RailsCompatibility
|
7
|
+
if GTE_RAILS_5_0
|
8
|
+
# type_cast_from_database was changed to deserialize in Rails 5
|
9
|
+
def deserialize(type, attribute)
|
10
|
+
type.deserialize(attribute)
|
11
|
+
end
|
12
|
+
else
|
13
|
+
def deserialize(type, attribute)
|
14
|
+
type.type_cast_from_database(attribute)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_compatibility'
|
4
|
+
|
5
|
+
class << RailsCompatibility
|
6
|
+
if ActiveSupport::VERSION::MAJOR >= 7
|
7
|
+
def setup_autoload_paths(paths)
|
8
|
+
require 'zeitwerk'
|
9
|
+
loader = Zeitwerk::Loader.new
|
10
|
+
|
11
|
+
paths.each do |path|
|
12
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
13
|
+
loader.push_dir(path)
|
14
|
+
end
|
15
|
+
|
16
|
+
loader.setup
|
17
|
+
end
|
18
|
+
else
|
19
|
+
def setup_autoload_paths(paths)
|
20
|
+
paths.each do |path|
|
21
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_compatibility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -126,14 +126,18 @@ files:
|
|
126
126
|
- gemfiles/5.2.gemfile
|
127
127
|
- gemfiles/6.0.gemfile
|
128
128
|
- gemfiles/6.1.gemfile
|
129
|
+
- gemfiles/7.0.gemfile
|
129
130
|
- lib/rails_compatibility.rb
|
130
131
|
- lib/rails_compatibility/active_record.rb
|
131
132
|
- lib/rails_compatibility/apply_join_dependency.rb
|
132
133
|
- lib/rails_compatibility/attribute_types.rb
|
133
134
|
- lib/rails_compatibility/build_joins.rb
|
135
|
+
- lib/rails_compatibility/cast_values.rb
|
134
136
|
- lib/rails_compatibility/construct_join_dependency.rb
|
137
|
+
- lib/rails_compatibility/deserialize.rb
|
135
138
|
- lib/rails_compatibility/has_include.rb
|
136
139
|
- lib/rails_compatibility/pick.rb
|
140
|
+
- lib/rails_compatibility/setup_autoload_paths.rb
|
137
141
|
- lib/rails_compatibility/unscope_where.rb
|
138
142
|
- lib/rails_compatibility/version.rb
|
139
143
|
- rails_compatibility.gemspec
|