rails_compatibility 0.0.4 → 0.0.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 +4 -4
- data/.github/workflows/ruby.yml +41 -14
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +13 -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/apply_join_dependency.rb +24 -0
- data/lib/rails_compatibility/has_include.rb +20 -0
- data/lib/rails_compatibility/pick.rb +23 -0
- data/lib/rails_compatibility/setup_autoload_paths.rb +25 -0
- data/lib/rails_compatibility/unscope_where.rb +3 -3
- data/lib/rails_compatibility/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e10843554c7729ecd8fb3b9ef7418fc458cb92ad18da1f4e6ce2829dd5ab1566
|
|
4
|
+
data.tar.gz: bdea2e8109abd52b32df8ca66675bc6ae3cd9a5ad3c6e1b73081d0344526e25b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f80ced4f5e1e7c22d04262c170fb478d46aa17c02a767cc37af0b4f170e634de81d1bf6824857e4f41bbeed846eb7365b28ee670e11262dd3da0b457ea2ea06e
|
|
7
|
+
data.tar.gz: b30469894f18200d7d102ddfe9f0308cda268c66236da7f7b6c6f53827a41616f03a871d92da95f89cd903485c139415ef0637c5c3605778fc928b9ebb661277
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -23,6 +23,8 @@ jobs:
|
|
|
23
23
|
- 2.2
|
|
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
65
|
ruby: 2.2
|
|
43
66
|
- gemfile: 6.1.gemfile
|
|
44
67
|
ruby: 2.2
|
|
68
|
+
- gemfile: 7.0.gemfile
|
|
69
|
+
ruby: 2.2
|
|
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/.rubocop.yml
CHANGED
|
@@ -178,7 +178,7 @@ Lint/UselessAssignment:
|
|
|
178
178
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars'
|
|
179
179
|
Enabled: true
|
|
180
180
|
|
|
181
|
-
Lint/
|
|
181
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
|
182
182
|
Description: 'Checks for comparison of something with itself.'
|
|
183
183
|
Enabled: true
|
|
184
184
|
|
|
@@ -1117,7 +1117,7 @@ Style/SymbolProc:
|
|
|
1117
1117
|
Description: 'Use symbols as procs instead of blocks when possible.'
|
|
1118
1118
|
Enabled: true
|
|
1119
1119
|
|
|
1120
|
-
Layout/
|
|
1120
|
+
Layout/IndentationStyle:
|
|
1121
1121
|
Description: 'No hard tabs.'
|
|
1122
1122
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation'
|
|
1123
1123
|
Enabled: true
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### [v0.0.7](https://github.com/khiav223577/rails_compatibility/compare/v0.0.6...v0.0.7) 2021/06/10
|
|
4
|
+
- [#12](https://github.com/khiav223577/rails_compatibility/pull/12) Implement #apply_join_dependency (@khiav223577)
|
|
5
|
+
|
|
6
|
+
### [v0.0.6](https://github.com/khiav223577/rails_compatibility/compare/v0.0.5...v0.0.6) 2021/06/10
|
|
7
|
+
- [#11](https://github.com/khiav223577/rails_compatibility/pull/11) Implement #has_include? (@khiav223577)
|
|
8
|
+
|
|
9
|
+
### [v0.0.5](https://github.com/khiav223577/rails_compatibility/compare/v0.0.4...v0.0.5) 2021/05/05
|
|
10
|
+
- [#10](https://github.com/khiav223577/rails_compatibility/pull/10) Implement #pick (@khiav223577)
|
|
11
|
+
- [#9](https://github.com/khiav223577/rails_compatibility/pull/9) refactor: use GTE_RAILS_4_0 (@khiav223577)
|
|
12
|
+
|
|
13
|
+
### [v0.0.4](https://github.com/khiav223577/rails_compatibility/compare/v0.0.3...v0.0.4) 2021/04/10
|
|
14
|
+
- [#8](https://github.com/khiav223577/rails_compatibility/pull/8) Fix: join dependency construct wrongly when HABTM associations have custom name (@khiav223577)
|
|
15
|
+
|
|
3
16
|
### [v0.0.3](https://github.com/khiav223577/rails_compatibility/compare/v0.0.2...v0.0.3) 2021/02/09
|
|
4
17
|
- [#7](https://github.com/khiav223577/rails_compatibility/pull/7) Implement #build_joins (@khiav223577)
|
|
5
18
|
- [#6](https://github.com/khiav223577/rails_compatibility/pull/6) Support Rails 6.1 (@khiav223577)
|
data/README.md
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
[](https://codeclimate.com/github/khiav223577/rails_compatibility/coverage)
|
|
8
8
|
|
|
9
9
|
## Supports
|
|
10
|
-
- Ruby 2.2 ~ 2.7
|
|
11
|
-
- Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0
|
|
10
|
+
- Ruby 2.2 ~ 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,24 @@
|
|
|
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_2
|
|
8
|
+
def apply_join_dependency(relation)
|
|
9
|
+
relation.send(:apply_join_dependency)
|
|
10
|
+
end
|
|
11
|
+
elsif GTE_RAILS_5_1
|
|
12
|
+
def apply_join_dependency(relation)
|
|
13
|
+
relation.send(:construct_relation_for_association_calculations)
|
|
14
|
+
end
|
|
15
|
+
elsif GTE_RAILS_5_0
|
|
16
|
+
def apply_join_dependency(relation)
|
|
17
|
+
relation.dup.send(:construct_relation_for_association_calculations)
|
|
18
|
+
end
|
|
19
|
+
else
|
|
20
|
+
def apply_join_dependency(relation)
|
|
21
|
+
relation.send(:construct_relation_for_association_calculations)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_compatibility'
|
|
4
|
+
require 'rails_compatibility/active_record'
|
|
5
|
+
|
|
6
|
+
class << RailsCompatibility
|
|
7
|
+
if GTE_RAILS_6_1
|
|
8
|
+
def has_include?(relation, column_name)
|
|
9
|
+
relation.send(:has_include?, column_name)
|
|
10
|
+
end
|
|
11
|
+
elsif GTE_RAILS_5_0
|
|
12
|
+
def has_include?(relation, column_name)
|
|
13
|
+
relation.dup.send(:has_include?, column_name)
|
|
14
|
+
end
|
|
15
|
+
else
|
|
16
|
+
def has_include?(relation, column_name)
|
|
17
|
+
relation.send(:has_include?, column_name)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_compatibility/active_record'
|
|
4
|
+
|
|
5
|
+
class << RailsCompatibility
|
|
6
|
+
if GTE_RAILS_6_0
|
|
7
|
+
def pick(relation, *args)
|
|
8
|
+
relation.pick(*args)
|
|
9
|
+
end
|
|
10
|
+
elsif GTE_RAILS_4_0
|
|
11
|
+
def pick(relation, *args)
|
|
12
|
+
relation.limit(1).pluck(*args).first
|
|
13
|
+
end
|
|
14
|
+
else
|
|
15
|
+
def pick(relation, *args)
|
|
16
|
+
model = relation.first
|
|
17
|
+
|
|
18
|
+
return nil if model == nil
|
|
19
|
+
return model[args.first] if args.size == 1
|
|
20
|
+
return args.map{|s| model[s] }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
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
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
require 'rails_compatibility/active_record'
|
|
4
4
|
|
|
5
5
|
class << RailsCompatibility
|
|
6
|
-
if
|
|
6
|
+
if GTE_RAILS_4_0
|
|
7
7
|
def unscope_where(relation)
|
|
8
|
-
relation.
|
|
8
|
+
relation.unscope(:where)
|
|
9
9
|
end
|
|
10
10
|
else
|
|
11
11
|
def unscope_where(relation)
|
|
12
|
-
relation.
|
|
12
|
+
relation.dup.tap{|s| s.where_values = [] }
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
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.8
|
|
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: 2022-01-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -126,11 +126,16 @@ 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
|
|
132
|
+
- lib/rails_compatibility/apply_join_dependency.rb
|
|
131
133
|
- lib/rails_compatibility/attribute_types.rb
|
|
132
134
|
- lib/rails_compatibility/build_joins.rb
|
|
133
135
|
- lib/rails_compatibility/construct_join_dependency.rb
|
|
136
|
+
- lib/rails_compatibility/has_include.rb
|
|
137
|
+
- lib/rails_compatibility/pick.rb
|
|
138
|
+
- lib/rails_compatibility/setup_autoload_paths.rb
|
|
134
139
|
- lib/rails_compatibility/unscope_where.rb
|
|
135
140
|
- lib/rails_compatibility/version.rb
|
|
136
141
|
- rails_compatibility.gemspec
|