deep_pluck 1.1.3 → 1.2.0

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: 378081961b9290a5a9b980183be343f68dbc27c718d6b8b78ce579577a18c5b3
4
- data.tar.gz: 91a7eb4c989d257f85e9f59356e620d87a4ee0d3f408d0e7735152e629c51af1
3
+ metadata.gz: 52f6de9f10f4af623d62fa914e2def86bdf2c7f9af69fe2e8260be2b2e8d83c3
4
+ data.tar.gz: 743caa89d3bff27bad73b543e3b4c0b8bee9a7c0fa3b4e41bd9746d9e6574232
5
5
  SHA512:
6
- metadata.gz: cae771fdd717b163da5d3f894b2e9025cb448f23565a32b1978a81da6419404998105718d493f2f0092727e9a06add477545648a53577b15efb58ddf7ab9027e
7
- data.tar.gz: 1f52ccf2d762ddd8e2c56117c2c62156bb5a30a98c86cd2df364c6be26c6f91fcefd7043fd265ce00b7a469c5e35ac3d47bf43878440cade9188af6c862701ce
6
+ metadata.gz: d21c3a241cb7d3bc9afbe11b52ecf1cbc17a110c3d5d0e2e4f1e73be5a8992634b51679348f8bac0a1d2b84e3807a9544366205d29fcb571bebbe3d6346c371e
7
+ data.tar.gz: e176efb7b6d920ae5863424a95052f9ed263a2a205fb0acd9897d2ae7beead768567fbc9adf63490ce8e37971ac8b18166f187793b6a1c2500d68ddad211b9f7
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [khiav223577] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -0,0 +1,62 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ paths-ignore:
6
+ - 'README.md'
7
+ - 'CHANGELOG.md'
8
+ pull_request:
9
+ branches: [ master ]
10
+ paths-ignore:
11
+ - 'README.md'
12
+ - 'CHANGELOG.md'
13
+
14
+ jobs:
15
+ test:
16
+ runs-on: ubuntu-latest
17
+ name: Test
18
+ if: "contains(github.event.commits[0].message, '[ci skip]') == false"
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ ruby:
23
+ - 2.2
24
+ - 2.6
25
+ - 2.7
26
+ gemfile:
27
+ - 3.2.gemfile
28
+ - 4.2.gemfile
29
+ - 5.0.gemfile
30
+ - 5.1.gemfile
31
+ - 5.2.gemfile
32
+ - 6.0.gemfile
33
+ - 6.1.gemfile
34
+ exclude:
35
+ - gemfile: 3.2.gemfile
36
+ ruby: 2.6
37
+ - gemfile: 3.2.gemfile
38
+ ruby: 2.7
39
+ - gemfile: 4.2.gemfile
40
+ ruby: 2.7
41
+ - gemfile: 6.0.gemfile
42
+ ruby: 2.2
43
+ - gemfile: 6.1.gemfile
44
+ ruby: 2.2
45
+ env:
46
+ BUNDLE_GEMFILE: "gemfiles/${{ matrix.gemfile }}"
47
+
48
+ steps:
49
+ - name: Checkout
50
+ uses: actions/checkout@v2
51
+ - name: Setup Ruby
52
+ uses: ruby/setup-ruby@v1
53
+ with:
54
+ ruby-version: ${{ matrix.ruby }}
55
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
56
+ - name: Run tests
57
+ run: bundle exec rake
58
+ - name: Publish code coverage
59
+ if: ${{ success() && github.event.pull_request.head.repo.full_name == github.repository }}
60
+ uses: paambaati/codeclimate-action@v2.7.5
61
+ env:
62
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
3
  /Gemfile.lock
4
+ /gemfiles/*.gemfile.lock
4
5
  /_yardoc/
5
6
  /coverage/
6
7
  /doc/
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rails
4
+
1
5
  AllCops:
2
6
  DisabledByDefault: true
3
7
  Exclude: []
@@ -73,10 +77,6 @@ Layout/EndAlignment:
73
77
  Description: 'Align ends correctly.'
74
78
  Enabled: true
75
79
 
76
- Lint/EndInMethod:
77
- Description: 'END blocks should not be placed inside method definitions.'
78
- Enabled: true
79
-
80
80
  Lint/EnsureReturn:
81
81
  Description: 'Do not use return in an ensure block.'
82
82
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-return-ensure'
@@ -90,7 +90,7 @@ Lint/FormatParameterMismatch:
90
90
  Description: 'The number of parameters to format/sprint must match the fields.'
91
91
  Enabled: true
92
92
 
93
- Lint/HandleExceptions:
93
+ Lint/SuppressedException:
94
94
  Description: "Don't suppress exception."
95
95
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
96
96
  Enabled: true
@@ -139,7 +139,7 @@ Lint/ShadowingOuterLocalVariable:
139
139
  for block arguments or block local variables.
140
140
  Enabled: true
141
141
 
142
- Lint/StringConversionInInterpolation:
142
+ Lint/RedundantStringCoercion:
143
143
  Description: 'Checks for Object#to_s usage in string interpolation.'
144
144
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-to-s'
145
145
  Enabled: true
@@ -148,7 +148,7 @@ Lint/UnderscorePrefixedVariableName:
148
148
  Description: 'Do not use prefix `_` for a variable that is used.'
149
149
  Enabled: true
150
150
 
151
- Lint/UnneededCopDisableDirective:
151
+ Lint/RedundantCopDisableDirective:
152
152
  Description: >-
153
153
  Checks for rubocop:disable comments that can be removed.
154
154
  Note: this cop is not disabled when disabling all cops.
@@ -178,8 +178,8 @@ Lint/UselessAssignment:
178
178
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars'
179
179
  Enabled: true
180
180
 
181
- Lint/UselessComparison:
182
- Description: 'Checks for comparison of something with itself.'
181
+ Lint/BinaryOperatorWithIdenticalOperands:
182
+ Description: 'This cop checks for places where binary operator has identical operands.'
183
183
  Enabled: true
184
184
 
185
185
  Lint/UselessElseWithoutRescue:
@@ -221,7 +221,7 @@ Metrics/CyclomaticComplexity:
221
221
  of test cases needed to validate a method.
222
222
  Enabled: true
223
223
 
224
- Metrics/LineLength:
224
+ Layout/LineLength:
225
225
  Description: 'Limit lines to 120 characters.'
226
226
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
227
227
  Max: 120
@@ -285,7 +285,7 @@ Performance/ReverseEach:
285
285
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
286
286
  Enabled: true
287
287
 
288
- Performance/Sample:
288
+ Style/Sample:
289
289
  Description: >-
290
290
  Use `sample` instead of `shuffle.first`,
291
291
  `shuffle.last`, and `shuffle[Fixnum]`.
@@ -353,7 +353,7 @@ Rails/TimeZone:
353
353
  Description: 'Checks the correct usage of time zone aware methods.'
354
354
  StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
355
355
  Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
356
- Enabled: true
356
+ Enabled: false
357
357
 
358
358
  Rails/Validation:
359
359
  Description: 'Use validates :attribute, hash of validations.'
@@ -375,21 +375,21 @@ Style/Alias:
375
375
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
376
376
  Enabled: true
377
377
 
378
- Layout/AlignArray:
378
+ Layout/ArrayAlignment:
379
379
  Description: >-
380
380
  Align the elements of an array literal if they span more than
381
381
  one line.
382
382
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays'
383
383
  Enabled: true
384
384
 
385
- Layout/AlignHash:
385
+ Layout/HashAlignment:
386
386
  Description: >-
387
387
  Align the elements of a hash literal if they span more than
388
388
  one line.
389
389
  EnforcedHashRocketStyle: table
390
390
  Enabled: true
391
391
 
392
- Layout/AlignParameters:
392
+ Layout/ParameterAlignment:
393
393
  Description: >-
394
394
  Align the parameters of a method call if they span more
395
395
  than one line.
@@ -448,10 +448,6 @@ Style/BlockDelimiters:
448
448
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
449
449
  Enabled: true
450
450
 
451
- Style/BracesAroundHashParameters:
452
- Description: 'Enforce braces style around hash parameters.'
453
- Enabled: true
454
-
455
451
  Style/CaseEquality:
456
452
  Description: 'Avoid explicit use of the case equality operator(===).'
457
453
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
@@ -596,7 +592,7 @@ Style/EndBlock:
596
592
  Layout/EndOfLine:
597
593
  Description: 'Use Unix-style line endings.'
598
594
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#crlf'
599
- Enabled: true
595
+ Enabled: false
600
596
 
601
597
  Style/EvenOdd:
602
598
  Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
@@ -617,14 +613,14 @@ Layout/InitialIndentation:
617
613
  Checks the indentation of the first non-blank non-comment line in a file.
618
614
  Enabled: true
619
615
 
620
- Layout/IndentFirstArgument:
616
+ Layout/FirstArgumentIndentation:
621
617
  Description: 'Checks the indentation of the first parameter in a method call.'
622
618
  Enabled: true
623
619
 
624
- Style/FlipFlop:
620
+ Lint/FlipFlop:
625
621
  Description: 'Checks for flip flops'
626
622
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
627
- Enabled: true
623
+ Enabled: false
628
624
 
629
625
  Style/For:
630
626
  Description: 'Checks use of for or each in multiline loops.'
@@ -634,9 +630,12 @@ Style/For:
634
630
  Style/FormatString:
635
631
  Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
636
632
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
637
- EnforcedStyle: sprintf
633
+ EnforcedStyle: percent
638
634
  Enabled: true
639
635
 
636
+ Style/FormatStringToken:
637
+ Enabled: false
638
+
640
639
  Style/GlobalVars:
641
640
  Description: 'Do not introduce global variables.'
642
641
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
@@ -676,14 +675,14 @@ Layout/IndentationWidth:
676
675
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation'
677
676
  Enabled: true
678
677
 
679
- Layout/IndentFirstArrayElement:
678
+ Layout/FirstArrayElementIndentation:
680
679
  Description: >-
681
680
  Checks the indentation of the first element in an array
682
681
  literal.
683
682
  EnforcedStyle: consistent
684
683
  Enabled: true
685
684
 
686
- Layout/IndentFirstHashElement:
685
+ Layout/FirstHashElementIndentation:
687
686
  Description: 'Checks the indentation of the first key in a hash literal.'
688
687
  EnforcedStyle: consistent
689
688
  Enabled: true
@@ -862,7 +861,7 @@ Style/PercentQLiterals:
862
861
  Style/PerlBackrefs:
863
862
  Description: 'Avoid Perl-style regex back references.'
864
863
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
865
- Enabled: true
864
+ Enabled: false
866
865
 
867
866
  Naming/PredicateName:
868
867
  Description: 'Check the names of predicate methods.'
@@ -940,11 +939,11 @@ Style/SingleLineBlockParams:
940
939
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
941
940
  Methods:
942
941
  - reduce:
943
- - acc
944
- - elem
942
+ - sum
943
+ - v
945
944
  - inject:
946
- - acc
947
- - elem
945
+ - sum
946
+ - v
948
947
  Enabled: true
949
948
 
950
949
  Style/SingleLineMethods:
@@ -1118,12 +1117,12 @@ Style/SymbolProc:
1118
1117
  Description: 'Use symbols as procs instead of blocks when possible.'
1119
1118
  Enabled: true
1120
1119
 
1121
- Layout/Tab:
1120
+ Layout/IndentationStyle:
1122
1121
  Description: 'No hard tabs.'
1123
1122
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation'
1124
1123
  Enabled: true
1125
1124
 
1126
- Layout/TrailingBlankLines:
1125
+ Layout/TrailingEmptyLines:
1127
1126
  Description: 'Checks trailing blank lines and final newline.'
1128
1127
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof'
1129
1128
  Enabled: true
@@ -1178,11 +1177,11 @@ Style/UnlessElse:
1178
1177
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-else-with-unless'
1179
1178
  Enabled: true
1180
1179
 
1181
- Style/UnneededCapitalW:
1180
+ Style/RedundantCapitalW:
1182
1181
  Description: 'Checks for %W when interpolation is not needed.'
1183
1182
  Enabled: true
1184
1183
 
1185
- Style/UnneededPercentQ:
1184
+ Style/RedundantPercentQ:
1186
1185
  Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
1187
1186
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q'
1188
1187
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,54 +1,75 @@
1
- ## Change Log
2
-
3
- ### [v1.1.2](https://github.com/khiav223577/deep_pluck/compare/v1.1.1...v1.1.2) 2019/09/25
4
- - [#32](https://github.com/khiav223577/deep_pluck/pull/32) Remove unneeded `PreloadedModel` (@khiav223577)
5
- - [#31](https://github.com/khiav223577/deep_pluck/pull/31) Support Rails 6.0 (@khiav223577)
6
- - [#30](https://github.com/khiav223577/deep_pluck/pull/30) Lock sqlite3 version to 1.3.x (@khiav223577)
7
- - [#28](https://github.com/khiav223577/deep_pluck/pull/28) Fix: broken test cases after bundler 2.0 was released (@khiav223577)
8
- - [#27](https://github.com/khiav223577/deep_pluck/pull/27) Remove deprecated codeclimate-test-reporter gem and update travis config (@khiav223577)
9
-
10
- ### [v1.1.1](https://github.com/khiav223577/deep_pluck/compare/v1.1.0...v1.1.1) 2018/07/08
11
- - [#26](https://github.com/khiav223577/deep_pluck/pull/26) Fix: `id` may disappear when plucking at model instance (@khiav223577)
12
- - [#25](https://github.com/khiav223577/deep_pluck/pull/25) Refactor - move models definition to separate files (@khiav223577)
13
- - [#24](https://github.com/khiav223577/deep_pluck/pull/24) test Rails 5.2 (@khiav223577)
14
- - [#23](https://github.com/khiav223577/deep_pluck/pull/23) should test both 5.0.x and 5.1.x (@khiav223577)
15
- - [#22](https://github.com/khiav223577/deep_pluck/pull/22) #deep_pluck at active model without plucking deeply will cause ArgumentError (@khiav223577)
16
- - [#20](https://github.com/khiav223577/deep_pluck/pull/20) [ENHANCE] Eliminate Extra Select Loop in Hash Lookup (@berniechiu)
17
-
18
- ### [v1.1.0](https://github.com/khiav223577/deep_pluck/compare/v1.0.3...v1.1.0) 2018/02/15
19
- - [#19](https://github.com/khiav223577/deep_pluck/pull/19) Support deep_pluck at active model (@khiav223577)
20
- - [#18](https://github.com/khiav223577/deep_pluck/pull/18) Add rubocop and Improve code quality (@khiav223577)
21
-
22
- ### [v1.0.3](https://github.com/khiav223577/deep_pluck/compare/v1.0.2...v1.0.3) 2017/06/30
23
- - [#15](https://github.com/khiav223577/deep_pluck/pull/15) test deep_pluck in rails 5.1.x (@khiav223577)
24
- - [#14](https://github.com/khiav223577/deep_pluck/pull/14) Handle polymorphic associations correctly. (@Bogadon)
25
-
26
- ### [v1.0.0](https://github.com/khiav223577/deep_pluck/compare/v0.1.4...v1.0.0) 2017/03/28
27
- - [#12](https://github.com/khiav223577/deep_pluck/pull/12) reduce cyclomatic complexity in model.rb (@khiav223577)
28
-
29
- ### [v0.1.4](https://github.com/khiav223577/deep_pluck/compare/v0.1.3...v0.1.4) 2017/03/27
30
- - [#11](https://github.com/khiav223577/deep_pluck/pull/11) Fix conditional associations (@khiav223577)
31
-
32
- ### [v0.1.3](https://github.com/khiav223577/deep_pluck/compare/v0.1.2...v0.1.3) 2017/03/20
33
- - [#10](https://github.com/khiav223577/deep_pluck/pull/10) fix custom foreign_key, custom primary_key issues (@khiav223577)
34
- - [#9](https://github.com/khiav223577/deep_pluck/pull/9) fix has_and_belongs_to_many (@khiav223577)
35
-
36
- ### [v0.1.2](https://github.com/khiav223577/deep_pluck/compare/v0.1.1...v0.1.2) 2017/03/17
37
- - [#8](https://github.com/khiav223577/deep_pluck/pull/8) fix some need columns is missing (@khiav223577)
38
- - [#7](https://github.com/khiav223577/deep_pluck/pull/7) raise error message when association not found (@khiav223577)
39
-
40
- ### [v0.1.1](https://github.com/khiav223577/deep_pluck/compare/v0.1.0...v0.1.1) 2017/03/16
41
- - [#6](https://github.com/khiav223577/deep_pluck/pull/6) fix deep_pluck with #joins (@khiav223577)
42
-
43
- ### [v0.1.0](https://github.com/khiav223577/deep_pluck/compare/v0.0.4...v0.1.0) 2017/03/15
44
- - [#5](https://github.com/khiav223577/deep_pluck/pull/5) Support pluck many-to-many associations (@khiav223577)
45
-
46
- ### [v0.0.4](https://github.com/khiav223577/deep_pluck/compare/v0.0.3...v0.0.4) 2017/03/14
47
- - [#4](https://github.com/khiav223577/deep_pluck/pull/4) Fix use deep_pluck on NullRelation will raise exception and prevent unneeded query. (@khiav223577)
48
-
49
- ### [v0.0.3](https://github.com/khiav223577/deep_pluck/compare/v0.0.2...v0.0.3) 2017/03/06
50
- - [#3](https://github.com/khiav223577/deep_pluck/pull/3) support more than two level (@khiav223577)
51
-
52
- ### [v0.0.2](https://github.com/khiav223577/deep_pluck/compare/v0.0.1...v0.0.2) 2017/03/06
53
- - [#2](https://github.com/khiav223577/deep_pluck/pull/2) The result of has_one association should not be array (@khiav223577)
54
- - [#1](https://github.com/khiav223577/deep_pluck/pull/1) deep pluck (@khiav223577)
1
+ ## Change Log
2
+
3
+ ### [v1.1.7](https://github.com/khiav223577/deep_pluck/compare/v1.1.6...v1.1.7) 2021/04/10
4
+ - [#48](https://github.com/khiav223577/deep_pluck/pull/48) Fix: joins incorrect table when doing inverse lookup for HABTM associations with custom name (@khiav223577)
5
+ - [#45](https://github.com/khiav223577/deep_pluck/pull/45) Do not publish code coverage for PRs from forks (@moon-moon-husky)
6
+
7
+ ### [v1.1.6](https://github.com/khiav223577/deep_pluck/compare/v1.1.5...v1.1.6) 2021/02/09
8
+ - [#43](https://github.com/khiav223577/deep_pluck/pull/43) Fix has_and_belongs_to_many issues when it does not specify "through" table (@khiav223577)
9
+ - [#42](https://github.com/khiav223577/deep_pluck/pull/42) Migrating from Travis CI to GitHub Actions (@khiav223577)
10
+
11
+ ### [v1.1.5](https://github.com/khiav223577/deep_pluck/compare/v1.1.4...v1.1.5) 2021/01/10
12
+ - [#39](https://github.com/khiav223577/deep_pluck/pull/39) Compatibility with Rails 6.1.1 (@klausbadelt)
13
+ - [#40](https://github.com/khiav223577/deep_pluck/pull/40) Exclude tests from coverage (@klausbadelt)
14
+
15
+ ### [v1.1.4](https://github.com/khiav223577/deep_pluck/compare/v1.1.3...v1.1.4) 2020/01/13
16
+ - [#36](https://github.com/khiav223577/deep_pluck/pull/36) A workaround to fix mismatched association named (@khiav223577)
17
+ - [#35](https://github.com/khiav223577/deep_pluck/pull/35) Support Ruby 2.7 (@khiav223577)
18
+
19
+ ### [v1.1.3](https://github.com/khiav223577/deep_pluck/compare/v1.1.2...v1.1.3) 2019/12/17
20
+ - [#34](https://github.com/khiav223577/deep_pluck/pull/34) Support for plucking directly on a has_one through association (@khiav223577)
21
+
22
+ ### [v1.1.2](https://github.com/khiav223577/deep_pluck/compare/v1.1.1...v1.1.2) 2019/09/25
23
+ - [#32](https://github.com/khiav223577/deep_pluck/pull/32) Remove unneeded `PreloadedModel` (@khiav223577)
24
+ - [#31](https://github.com/khiav223577/deep_pluck/pull/31) Support Rails 6.0 (@khiav223577)
25
+ - [#30](https://github.com/khiav223577/deep_pluck/pull/30) Lock sqlite3 version to 1.3.x (@khiav223577)
26
+ - [#28](https://github.com/khiav223577/deep_pluck/pull/28) Fix: broken test cases after bundler 2.0 was released (@khiav223577)
27
+ - [#27](https://github.com/khiav223577/deep_pluck/pull/27) Remove deprecated codeclimate-test-reporter gem and update travis config (@khiav223577)
28
+
29
+ ### [v1.1.1](https://github.com/khiav223577/deep_pluck/compare/v1.1.0...v1.1.1) 2018/07/08
30
+ - [#26](https://github.com/khiav223577/deep_pluck/pull/26) Fix: `id` may disappear when plucking at model instance (@khiav223577)
31
+ - [#25](https://github.com/khiav223577/deep_pluck/pull/25) Refactor - move models definition to separate files (@khiav223577)
32
+ - [#24](https://github.com/khiav223577/deep_pluck/pull/24) test Rails 5.2 (@khiav223577)
33
+ - [#23](https://github.com/khiav223577/deep_pluck/pull/23) It should test both 5.0.x and 5.1.x (@khiav223577)
34
+ - [#22](https://github.com/khiav223577/deep_pluck/pull/22) #deep_pluck at active model without plucking deeply will cause ArgumentError (@khiav223577)
35
+ - [#20](https://github.com/khiav223577/deep_pluck/pull/20) [ENHANCE] Eliminate Extra Select Loop in Hash Lookup (@berniechiu)
36
+
37
+ ### [v1.1.0](https://github.com/khiav223577/deep_pluck/compare/v1.0.3...v1.1.0) 2018/02/15
38
+ - [#19](https://github.com/khiav223577/deep_pluck/pull/19) Support deep_pluck at active model (@khiav223577)
39
+ - [#18](https://github.com/khiav223577/deep_pluck/pull/18) Add rubocop and Improve code quality (@khiav223577)
40
+
41
+ ### [v1.0.3](https://github.com/khiav223577/deep_pluck/compare/v1.0.2...v1.0.3) 2017/06/30
42
+ - [#15](https://github.com/khiav223577/deep_pluck/pull/15) Test deep_pluck in rails 5.1.x (@khiav223577)
43
+ - [#14](https://github.com/khiav223577/deep_pluck/pull/14) Handle polymorphic associations correctly. (@Bogadon)
44
+
45
+ ### [v1.0.0](https://github.com/khiav223577/deep_pluck/compare/v0.1.4...v1.0.0) 2017/03/28
46
+ - [#12](https://github.com/khiav223577/deep_pluck/pull/12) Reduce cyclomatic complexity in model.rb (@khiav223577)
47
+
48
+ ### [v0.1.4](https://github.com/khiav223577/deep_pluck/compare/v0.1.3...v0.1.4) 2017/03/27
49
+ - [#11](https://github.com/khiav223577/deep_pluck/pull/11) Fix conditional associations (@khiav223577)
50
+
51
+ ### [v0.1.3](https://github.com/khiav223577/deep_pluck/compare/v0.1.2...v0.1.3) 2017/03/20
52
+ - [#10](https://github.com/khiav223577/deep_pluck/pull/10) Fix custom foreign_key, custom primary_key issues (@khiav223577)
53
+ - [#9](https://github.com/khiav223577/deep_pluck/pull/9) Fix has_and_belongs_to_many (@khiav223577)
54
+
55
+ ### [v0.1.2](https://github.com/khiav223577/deep_pluck/compare/v0.1.1...v0.1.2) 2017/03/17
56
+ - [#8](https://github.com/khiav223577/deep_pluck/pull/8) Fix that some need columns are missing (@khiav223577)
57
+ - [#7](https://github.com/khiav223577/deep_pluck/pull/7) Raise error message when association not found (@khiav223577)
58
+
59
+ ### [v0.1.1](https://github.com/khiav223577/deep_pluck/compare/v0.1.0...v0.1.1) 2017/03/16
60
+ - [#6](https://github.com/khiav223577/deep_pluck/pull/6) Fix deep_pluck with #joins (@khiav223577)
61
+
62
+ ### [v0.1.0](https://github.com/khiav223577/deep_pluck/compare/v0.0.4...v0.1.0) 2017/03/15
63
+ - [#5](https://github.com/khiav223577/deep_pluck/pull/5) Support pluck many-to-many associations (@khiav223577)
64
+
65
+ ### [v0.0.4](https://github.com/khiav223577/deep_pluck/compare/v0.0.3...v0.0.4) 2017/03/14
66
+ - [#4](https://github.com/khiav223577/deep_pluck/pull/4) Fix use deep_pluck on NullRelation will raise exception and prevent unneeded query. (@khiav223577)
67
+
68
+ ### [v0.0.3](https://github.com/khiav223577/deep_pluck/compare/v0.0.2...v0.0.3) 2017/03/06
69
+ - [#3](https://github.com/khiav223577/deep_pluck/pull/3) Support more than two level (@khiav223577)
70
+
71
+ ### [v0.0.2](https://github.com/khiav223577/deep_pluck/compare/v0.0.1...v0.0.2) 2017/03/06
72
+ - [#2](https://github.com/khiav223577/deep_pluck/pull/2) The result of has_one association should not be array (@khiav223577)
73
+
74
+ ### v0.0.1 2017/03/04
75
+ - [#1](https://github.com/khiav223577/deep_pluck/pull/1) Implement deep_pluck (@khiav223577)
data/README.md CHANGED
@@ -1,15 +1,16 @@
1
1
  # DeepPluck
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/deep_pluck.svg?style=flat)](http://rubygems.org/gems/deep_pluck)
4
- [![Build Status](https://travis-ci.org/khiav223577/deep_pluck.svg?branch=master)](https://travis-ci.org/khiav223577/deep_pluck)
4
+ [![Build Status](https://github.com/khiav223577/deep_pluck/workflows/Ruby/badge.svg)](https://github.com/khiav223577/deep_pluck/actions)
5
5
  [![RubyGems](http://img.shields.io/gem/dt/deep_pluck.svg?style=flat)](http://rubygems.org/gems/deep_pluck)
6
6
  [![Code Climate](https://codeclimate.com/github/khiav223577/deep_pluck/badges/gpa.svg)](https://codeclimate.com/github/khiav223577/deep_pluck)
7
7
  [![Test Coverage](https://codeclimate.com/github/khiav223577/deep_pluck/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/deep_pluck/coverage)
8
8
 
9
9
  Allow you to pluck deeply into nested associations without loading a bunch of records.
10
10
 
11
- Support Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0.
12
-
11
+ ## Supports
12
+ - Ruby 2.2 ~ 2.7
13
+ - Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0
13
14
 
14
15
  ## Installation
15
16
 
data/deep_pluck.gemspec CHANGED
@@ -40,6 +40,6 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency 'minitest', '~> 5.0'
41
41
 
42
42
  spec.add_dependency 'activerecord', '>= 3'
43
- spec.add_dependency 'pluck_all', '>= 1.2.3'
44
- spec.add_dependency 'rails_compatibility', '>= 0.0.1'
43
+ spec.add_dependency 'pluck_all', '>= 2.3.2'
44
+ spec.add_dependency 'rails_compatibility', '>= 0.0.4'
45
45
  end
data/gemfiles/3.2.gemfile CHANGED
@@ -1,10 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activerecord', '~> 3.2.0'
4
- gem 'pluck_all', '~> 1.2.2'
4
+ gem 'pluck_all', '~> 2.3.2'
5
+
6
+ gem 'globalize'
5
7
 
6
8
  group :test do
7
- gem 'simplecov'
9
+ gem 'simplecov', '< 0.18'
8
10
  gem 'sqlite3', '~> 1.3.6'
9
11
  end
10
12
 
data/gemfiles/4.2.gemfile CHANGED
@@ -1,10 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activerecord', '~> 4.2.0'
4
- gem 'pluck_all', '~> 1.2.2'
4
+ gem 'pluck_all', '~> 2.3.2'
5
+
6
+ gem 'globalize'
5
7
 
6
8
  group :test do
7
- gem 'simplecov'
9
+ gem 'simplecov', '< 0.18'
8
10
  gem 'sqlite3', '~> 1.3.6'
9
11
  end
10
12
 
data/gemfiles/5.0.gemfile CHANGED
@@ -1,10 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activerecord', '~> 5.0.0'
4
- gem 'pluck_all', '~> 1.2.2'
4
+ gem 'pluck_all', '~> 2.3.2'
5
+
6
+ gem 'globalize'
5
7
 
6
8
  group :test do
7
- gem 'simplecov'
9
+ gem 'simplecov', '< 0.18'
8
10
  gem 'sqlite3', '~> 1.3.6'
9
11
  end
10
12
 
data/gemfiles/5.1.gemfile CHANGED
@@ -1,10 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activerecord', '~> 5.1.0'
4
- gem 'pluck_all', '~> 1.2.2'
4
+ gem 'pluck_all', '~> 2.3.2'
5
+
6
+ gem 'globalize'
5
7
 
6
8
  group :test do
7
- gem 'simplecov'
9
+ gem 'simplecov', '< 0.18'
8
10
  gem 'sqlite3', '~> 1.3.6'
9
11
  end
10
12
 
data/gemfiles/5.2.gemfile CHANGED
@@ -1,10 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activerecord', '~> 5.2.0'
4
- gem 'pluck_all', '~> 1.2.2'
4
+ gem 'pluck_all', '~> 2.3.2'
5
+
6
+ gem 'globalize'
5
7
 
6
8
  group :test do
7
- gem 'simplecov'
9
+ gem 'simplecov', '< 0.18'
8
10
  gem 'sqlite3', '~> 1.3.6'
9
11
  end
10
12
 
data/gemfiles/6.0.gemfile CHANGED
@@ -1,10 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activerecord', '~> 6.0.0'
4
- gem 'pluck_all', '~> 2.0.4'
4
+ gem 'pluck_all', '~> 2.3.2'
5
+
6
+ gem 'globalize'
5
7
 
6
8
  group :test do
7
- gem 'simplecov'
9
+ gem 'simplecov', '< 0.18'
8
10
  gem 'sqlite3', '~> 1.4.1'
9
11
  end
10
12
 
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 6.1.1'
4
+ gem 'pluck_all', '~> 2.3.2'
5
+
6
+ gem 'globalize'
7
+
8
+ group :test do
9
+ gem 'simplecov', '< 0.18'
10
+ gem 'sqlite3', '~> 1.4.1'
11
+ end
12
+
13
+ gemspec path: '../'
@@ -26,8 +26,8 @@ module DeepPluck
26
26
  def assign_values_to_parent(collection, parent, children_hash, column_name, foreign_key, reverse: false)
27
27
  parent.each do |s|
28
28
  next if (id = s[foreign_key]) == nil
29
- left = reverse ? children_hash[id] : s
30
- right = !reverse ? children_hash[id] : s
29
+ left = reverse ? children_hash[id] : s
30
+ right = !reverse ? children_hash[id] : s
31
31
  if collection
32
32
  left[column_name] << right
33
33
  else
@@ -1,5 +1,6 @@
1
1
  require 'rails_compatibility'
2
2
  require 'rails_compatibility/unscope_where'
3
+ require 'rails_compatibility/build_joins'
3
4
  require 'deep_pluck/data_combiner'
4
5
 
5
6
  module DeepPluck
@@ -31,7 +32,7 @@ module DeepPluck
31
32
  @klass.reflect_on_association(association_key.to_sym) || # add to_sym since rails 3 only support symbol
32
33
  fail(ActiveRecord::ConfigurationError, "ActiveRecord::ConfigurationError: Association named \
33
34
  '#{association_key}' was not found on #{@klass.name}; perhaps you misspelled it?"
34
- )
35
+ )
35
36
  end
36
37
 
37
38
  def with_conditions(reflect, relation)
@@ -119,7 +120,26 @@ module DeepPluck
119
120
  query[reflect.type] = reflect.active_record.to_s if reflect.type
120
121
 
121
122
  return get_association_scope(reflect).where(query) if use_association_to_query?(reflect)
122
- return relation.joins(get_join_table(reflect)).where(query)
123
+
124
+ joins = if reflect.macro == :has_and_belongs_to_many
125
+ RailsCompatibility.build_joins(reflect, relation)[0]
126
+ else
127
+ backtrace_possible_association(relation, get_join_table(reflect))
128
+ end
129
+
130
+ return relation.joins(joins).where(query)
131
+ end
132
+
133
+ # Let city has_many :users, through: :schools
134
+ # And the query is: City.deep_pluck('users' => :name)
135
+ # We want to get the users data via `User.joins(:school).where(city_id: city_ids)`
136
+ # But get_join_table(reflect) returns `:schools` not :school
137
+ # No idea how to get the right association, so we try singularize or pluralize it.
138
+ def backtrace_possible_association(relation, join_table)
139
+ return join_table if relation.reflect_on_association(join_table)
140
+ join_table.to_s.singularize.to_sym.tap{|s| return s if relation.reflect_on_association(s) }
141
+ join_table.to_s.pluralize.to_sym.tap{|s| return s if relation.reflect_on_association(s) }
142
+ return nil
123
143
  end
124
144
 
125
145
  def set_includes_data(parent, column_name, model)
@@ -1,3 +1,3 @@
1
1
  module DeepPluck
2
- VERSION = '1.1.3'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_pluck
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2021-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: 1.2.3
95
+ version: 2.3.2
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 1.2.3
102
+ version: 2.3.2
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rails_compatibility
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 0.0.1
109
+ version: 0.0.4
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: 0.0.1
116
+ version: 0.0.4
117
117
  description: 'Use deep_pluck as a shortcut to select one or more attributes and include
118
118
  associated models without loading a bunch of records. And DRY up your code when
119
119
  using #as_json.'
@@ -123,9 +123,10 @@ executables: []
123
123
  extensions: []
124
124
  extra_rdoc_files: []
125
125
  files:
126
+ - ".github/FUNDING.yml"
127
+ - ".github/workflows/ruby.yml"
126
128
  - ".gitignore"
127
129
  - ".rubocop.yml"
128
- - ".travis.yml"
129
130
  - CHANGELOG.md
130
131
  - CODE_OF_CONDUCT.md
131
132
  - LICENSE.txt
@@ -140,6 +141,7 @@ files:
140
141
  - gemfiles/5.1.gemfile
141
142
  - gemfiles/5.2.gemfile
142
143
  - gemfiles/6.0.gemfile
144
+ - gemfiles/6.1.gemfile
143
145
  - lib/deep_pluck.rb
144
146
  - lib/deep_pluck/data_combiner.rb
145
147
  - lib/deep_pluck/model.rb
@@ -168,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
170
  - !ruby/object:Gem::Version
169
171
  version: '0'
170
172
  requirements: []
171
- rubygems_version: 3.0.3
173
+ rubygems_version: 3.2.14
172
174
  signing_key:
173
175
  specification_version: 4
174
176
  summary: Use deep_pluck as a shortcut to select one or more attributes and include
data/.travis.yml DELETED
@@ -1,34 +0,0 @@
1
- sudo: false
2
- env:
3
- global:
4
- - CC_TEST_REPORTER_ID=29e69e7da6b55678f27b7de2444b6161a6c98e3c4b22e0e017ebab87ada18fd5
5
- language: ruby
6
- rvm:
7
- - 2.2
8
- - 2.6
9
- gemfile:
10
- - gemfiles/3.2.gemfile
11
- - gemfiles/4.2.gemfile
12
- - gemfiles/5.0.gemfile
13
- - gemfiles/5.1.gemfile
14
- - gemfiles/5.2.gemfile
15
- - gemfiles/6.0.gemfile
16
- matrix:
17
- exclude:
18
- - gemfile: gemfiles/3.2.gemfile
19
- rvm: 2.6
20
- - gemfile: gemfiles/4.0.gemfile
21
- rvm: 2.6
22
- - gemfile: gemfiles/6.0.gemfile
23
- rvm: 2.2
24
- before_install:
25
- - gem i rubygems-update -v '<3' && update_rubygems
26
- - gem install bundler -v 1.17.3
27
- - gem --version
28
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
29
- - chmod +x ./cc-test-reporter
30
- - ./cc-test-reporter before-build
31
- script:
32
- - bundle exec rake test
33
- after_script:
34
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT