filterable-by 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +3 -0
- data/Gemfile.lock +9 -9
- data/Gemfile.rails6 +4 -0
- data/Gemfile.rails6.lock +91 -0
- data/filterable-by.gemspec +1 -1
- data/lib/filterable_by.rb +6 -1
- data/spec/active_record/filterable_by_spec.rb +6 -0
- data/spec/spec_helper.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0b24315b28f7b165d4158fe6ef43860a346e342732ef53ffd02595bbd34e511
|
4
|
+
data.tar.gz: 90b3ec26188bf9337758320f222730bfaf19f0b2525bfec8b25080f0c6d5f258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c84a6573838b6acd0f7c9136cfdd2853146edaff7dd9e9fb74967bd7dedce782a54ed800674489717ade4b6923d882de9f53ba4ad0ff3d7e8444807e925435a0
|
7
|
+
data.tar.gz: 11aa00c16d9e85daab300757381e783d6006fa874d3a33a7f40a412c176a6ca75120cee413409a1434c59d33658443f2f3af68168abfaa99eb6287db29509ee6
|
data/.github/workflows/test.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
filterable-by (0.6.
|
4
|
+
filterable-by (0.6.1)
|
5
5
|
activerecord
|
6
6
|
activesupport
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (7.0.2.
|
12
|
-
activesupport (= 7.0.2.
|
13
|
-
activerecord (7.0.2.
|
14
|
-
activemodel (= 7.0.2.
|
15
|
-
activesupport (= 7.0.2.
|
16
|
-
activesupport (7.0.2.
|
11
|
+
activemodel (7.0.2.3)
|
12
|
+
activesupport (= 7.0.2.3)
|
13
|
+
activerecord (7.0.2.3)
|
14
|
+
activemodel (= 7.0.2.3)
|
15
|
+
activesupport (= 7.0.2.3)
|
16
|
+
activesupport (7.0.2.3)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 1.6, < 2)
|
19
19
|
minitest (>= 5.1)
|
@@ -44,13 +44,13 @@ GEM
|
|
44
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
45
|
rspec-support (~> 3.11.0)
|
46
46
|
rspec-support (3.11.0)
|
47
|
-
rubocop (1.
|
47
|
+
rubocop (1.26.0)
|
48
48
|
parallel (~> 1.10)
|
49
49
|
parser (>= 3.1.0.0)
|
50
50
|
rainbow (>= 2.2.2, < 4.0)
|
51
51
|
regexp_parser (>= 1.8, < 3.0)
|
52
52
|
rexml
|
53
|
-
rubocop-ast (>= 1.
|
53
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
54
54
|
ruby-progressbar (~> 1.7)
|
55
55
|
unicode-display_width (>= 1.4.0, < 3.0)
|
56
56
|
rubocop-ast (1.16.0)
|
data/Gemfile.rails6
ADDED
data/Gemfile.rails6.lock
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
filterable-by (0.6.1)
|
5
|
+
activerecord
|
6
|
+
activesupport
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (6.1.4.7)
|
12
|
+
activesupport (= 6.1.4.7)
|
13
|
+
activerecord (6.1.4.7)
|
14
|
+
activemodel (= 6.1.4.7)
|
15
|
+
activesupport (= 6.1.4.7)
|
16
|
+
activesupport (6.1.4.7)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (>= 1.6, < 2)
|
19
|
+
minitest (>= 5.1)
|
20
|
+
tzinfo (~> 2.0)
|
21
|
+
zeitwerk (~> 2.3)
|
22
|
+
ast (2.4.2)
|
23
|
+
concurrent-ruby (1.1.9)
|
24
|
+
diff-lcs (1.5.0)
|
25
|
+
i18n (1.10.0)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
minitest (5.15.0)
|
28
|
+
parallel (1.21.0)
|
29
|
+
parser (3.1.1.0)
|
30
|
+
ast (~> 2.4.1)
|
31
|
+
rainbow (3.1.1)
|
32
|
+
rake (13.0.6)
|
33
|
+
regexp_parser (2.2.1)
|
34
|
+
rexml (3.2.5)
|
35
|
+
rspec (3.11.0)
|
36
|
+
rspec-core (~> 3.11.0)
|
37
|
+
rspec-expectations (~> 3.11.0)
|
38
|
+
rspec-mocks (~> 3.11.0)
|
39
|
+
rspec-core (3.11.0)
|
40
|
+
rspec-support (~> 3.11.0)
|
41
|
+
rspec-expectations (3.11.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.11.0)
|
44
|
+
rspec-mocks (3.11.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.11.0)
|
47
|
+
rspec-support (3.11.0)
|
48
|
+
rubocop (1.26.0)
|
49
|
+
parallel (~> 1.10)
|
50
|
+
parser (>= 3.1.0.0)
|
51
|
+
rainbow (>= 2.2.2, < 4.0)
|
52
|
+
regexp_parser (>= 1.8, < 3.0)
|
53
|
+
rexml
|
54
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
55
|
+
ruby-progressbar (~> 1.7)
|
56
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
57
|
+
rubocop-ast (1.16.0)
|
58
|
+
parser (>= 3.1.1.0)
|
59
|
+
rubocop-bsm (0.6.0)
|
60
|
+
rubocop (~> 1.0)
|
61
|
+
rubocop-performance
|
62
|
+
rubocop-rake
|
63
|
+
rubocop-rspec
|
64
|
+
rubocop-performance (1.13.3)
|
65
|
+
rubocop (>= 1.7.0, < 2.0)
|
66
|
+
rubocop-ast (>= 0.4.0)
|
67
|
+
rubocop-rake (0.6.0)
|
68
|
+
rubocop (~> 1.0)
|
69
|
+
rubocop-rspec (2.9.0)
|
70
|
+
rubocop (~> 1.19)
|
71
|
+
ruby-progressbar (1.11.0)
|
72
|
+
sqlite3 (1.4.2)
|
73
|
+
tzinfo (2.0.4)
|
74
|
+
concurrent-ruby (~> 1.0)
|
75
|
+
unicode-display_width (2.1.0)
|
76
|
+
zeitwerk (2.5.4)
|
77
|
+
|
78
|
+
PLATFORMS
|
79
|
+
x86_64-linux
|
80
|
+
|
81
|
+
DEPENDENCIES
|
82
|
+
activerecord (~> 6.1)
|
83
|
+
bundler
|
84
|
+
filterable-by!
|
85
|
+
rake
|
86
|
+
rspec
|
87
|
+
rubocop-bsm
|
88
|
+
sqlite3
|
89
|
+
|
90
|
+
BUNDLED WITH
|
91
|
+
2.3.9
|
data/filterable-by.gemspec
CHANGED
data/lib/filterable_by.rb
CHANGED
@@ -29,7 +29,12 @@ module ActiveRecord
|
|
29
29
|
sub = block.arity == 2 ? yield(unscoped, negative, **opts) : yield(negative, **opts)
|
30
30
|
return nil unless sub
|
31
31
|
|
32
|
-
|
32
|
+
if sub.respond_to?(:invert_where)
|
33
|
+
sub = sub.invert_where
|
34
|
+
else
|
35
|
+
sub.where_clause = sub.where_clause.invert
|
36
|
+
end
|
37
|
+
scope = scope.merge(sub)
|
33
38
|
end
|
34
39
|
|
35
40
|
scope
|
@@ -61,6 +61,12 @@ describe ActiveRecord::FilterableBy do
|
|
61
61
|
it 'combines with other scopes' do
|
62
62
|
scope = Comment.where(author_id: alice.id).filter_by('post_id' => apost.id)
|
63
63
|
expect(scope.pluck(:title)).to match_array(['AA'])
|
64
|
+
|
65
|
+
expect(alice.posts.filter_by('post_id' => apost.id).count).to be(1)
|
66
|
+
expect(alice.posts.filter_by('author_id' => alice.id).count).to be(1)
|
67
|
+
expect(alice.posts.filter_by('author_id_not' => bob.id).count).to be(1)
|
68
|
+
expect(alice.posts.filter_by('author_id' => bob.id).count).to be_zero
|
69
|
+
expect(alice.posts.filter_by('author_id_not' => alice.id).count).to be_zero
|
64
70
|
end
|
65
71
|
|
66
72
|
it 'allows custom options' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filterable-by
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -120,6 +120,8 @@ files:
|
|
120
120
|
- ".rubocop.yml"
|
121
121
|
- Gemfile
|
122
122
|
- Gemfile.lock
|
123
|
+
- Gemfile.rails6
|
124
|
+
- Gemfile.rails6.lock
|
123
125
|
- LICENSE
|
124
126
|
- README.md
|
125
127
|
- Rakefile
|