filta 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/Rakefile +4 -5
- data/VERSION +1 -1
- data/lib/filta/methods.rb +1 -6
- metadata +19 -166
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64dcdb32639568a2c5491d3ed9197612824a5bee92a3d5e0262dbb30c8acc023
|
4
|
+
data.tar.gz: 3899460eb6c52bc4f3f0d10b173e710494e492c8783e6a54bb07a0bdb45ac1d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de933bbaa3414847087eb6a63309d473805d7569687ef89734a1e2a64246a432e30a17c67fe81b621d7d5b51ad83dfd6d3ddccfb757b726e08f6b5cf8062498
|
7
|
+
data.tar.gz: e9aaf97137e767f24b6add62c0c4656e9233577d42043553f2c5df2b4df5bf91ebffad5feafbf50ba889527bcda29e8318dffd5edae6a915f98cdca12ee043b1
|
data/README.md
CHANGED
@@ -3,7 +3,11 @@
|
|
3
3
|
Super simple filtering for ActiveRecord, inspired by [Justin Weiss' Gist](https://gist.github.com/justinweiss/9065666).
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/filta.svg)](https://badge.fury.io/rb/filta)
|
6
|
-
[![
|
6
|
+
[![CI](https://github.com/boxt/filta/actions/workflows/ci.yml/badge.svg)](https://github.com/boxt/filta/actions/workflows/ci.yml)
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
* Ruby 2.7.3 or above
|
10
|
+
* Rails >= 6, < 8
|
7
11
|
|
8
12
|
## Installation
|
9
13
|
|
@@ -33,17 +37,13 @@ Use like you would any other kind of ActiveRecord scope.
|
|
33
37
|
@filtered = Klass.filta({ title: "Foo", something: "Bar" })
|
34
38
|
```
|
35
39
|
|
36
|
-
The `
|
40
|
+
The `filta` method returns an ActiveRecord relation so you can chain the calls with other methods.
|
37
41
|
|
38
42
|
```ruby
|
39
43
|
Klass.filta({ title: "Foo" }).order("created_at DESC")
|
40
44
|
```
|
41
45
|
|
42
|
-
If using in a controller make sure you use the `params.permit` method to
|
43
|
-
|
44
|
-
## Notes
|
45
|
-
|
46
|
-
The original `.filter` method is deprecated to avoid any confusion
|
46
|
+
If using in a controller make sure you use the `params.permit` method to sanitize what you pass into the `filter` method.
|
47
47
|
|
48
48
|
## Contributing
|
49
49
|
|
data/Rakefile
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rake/testtask"
|
5
|
+
require "rspec/core/rake_task"
|
5
6
|
|
6
|
-
|
7
|
-
t.
|
8
|
-
t.libs << "lib"
|
9
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
+
t.pattern = Dir.glob("spec/**/*_spec.rb")
|
10
9
|
end
|
11
10
|
|
12
|
-
task
|
11
|
+
task test: :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/filta/methods.rb
CHANGED
@@ -11,18 +11,13 @@ module Filta
|
|
11
11
|
results = where(nil)
|
12
12
|
|
13
13
|
by.each do |key, value|
|
14
|
-
next
|
14
|
+
next if value.blank?
|
15
15
|
|
16
16
|
results = results.where(key.to_s.to_sym => value)
|
17
17
|
end
|
18
18
|
|
19
19
|
results
|
20
20
|
end
|
21
|
-
|
22
|
-
# TODO: This method is now deprecated and should be removed at a later date
|
23
|
-
def filter(by)
|
24
|
-
filta(by)
|
25
|
-
end
|
26
21
|
end
|
27
22
|
end
|
28
23
|
end
|
metadata
CHANGED
@@ -1,183 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Boxt Developers
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '5.2'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: boxt_ruby_style_guide
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '4.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
19
|
+
version: '6'
|
20
|
+
- - "<"
|
39
21
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.1'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.13'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.13'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest-bang
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: minitest-fail-fast
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0.1'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0.1'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: minitest-macos-notification
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0.3'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0.3'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: minitest-reporters
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '1.4'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '1.4'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rake
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '13.0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '13.0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: simplecov
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0.17'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0.17'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: sqlite3
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '1.3'
|
160
|
-
type: :development
|
22
|
+
version: '8'
|
23
|
+
type: :runtime
|
161
24
|
prerelease: false
|
162
25
|
version_requirements: !ruby/object:Gem::Requirement
|
163
26
|
requirements:
|
164
|
-
- - "
|
27
|
+
- - ">="
|
165
28
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
167
|
-
-
|
168
|
-
name: with_model
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
29
|
+
version: '6'
|
30
|
+
- - "<"
|
172
31
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '2.0'
|
32
|
+
version: '8'
|
181
33
|
description: Simple filtering for ActiveRecord, inspired by Justin Weiss 'Gist - https://gist.github.com/justinweiss/9065666
|
182
34
|
email:
|
183
35
|
- developers@boxt.co.uk
|
@@ -196,8 +48,9 @@ files:
|
|
196
48
|
homepage: https://github.com/boxt/filta
|
197
49
|
licenses:
|
198
50
|
- MIT
|
199
|
-
metadata:
|
200
|
-
|
51
|
+
metadata:
|
52
|
+
rubygems_mfa_required: 'true'
|
53
|
+
post_install_message:
|
201
54
|
rdoc_options: []
|
202
55
|
require_paths:
|
203
56
|
- lib
|
@@ -205,15 +58,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
58
|
requirements:
|
206
59
|
- - ">="
|
207
60
|
- !ruby/object:Gem::Version
|
208
|
-
version: '
|
61
|
+
version: '2.7'
|
209
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
63
|
requirements:
|
211
64
|
- - ">="
|
212
65
|
- !ruby/object:Gem::Version
|
213
66
|
version: '0'
|
214
67
|
requirements: []
|
215
|
-
rubygems_version: 3.
|
216
|
-
signing_key:
|
68
|
+
rubygems_version: 3.2.22
|
69
|
+
signing_key:
|
217
70
|
specification_version: 4
|
218
71
|
summary: Simple filtering for ActiveRecord
|
219
72
|
test_files: []
|