filterameter 1.0.2 → 1.0.3
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/README.md +9 -11
- data/lib/filterameter/declarative_filters.rb +1 -1
- data/lib/filterameter/version.rb +1 -1
- metadata +9 -65
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50c824121830196b05ccb71f43495ad4d5197f85fe9d31456edc549fd2462a59
|
|
4
|
+
data.tar.gz: 4bb268b89c285e6542b0347bb3c52ca903f4d9be517f33b6303a76200b36f6c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21e92b0610890ed0ccbd8e3bdba68864de0c28d1c1ea42af40e51e696b0950c0ed6dd2d085673e493f400ca875d0307eeaaf9b844d021f1ae0d2fe11d53420c7
|
|
7
|
+
data.tar.gz: 77edd1277a98e49ab6c6425fe387404176477afc9050bafbb4d3d0eb34268d0e0e4a1f2983fb3b4951a0c9e7c88a0309464ab11112d67ae401ebcb75f7a74617
|
data/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
[](https://badge.fury.io/rb/filterameter)
|
|
2
2
|
[](https://github.com/RockSolt/filterameter/actions?query=workflow%3ARuboCop)
|
|
3
3
|
[](https://github.com/RockSolt/filterameter/actions?query=workflow%3ARSpec)
|
|
4
|
-
[](https://codeclimate.com/github/RockSolt/filterameter/maintainability)
|
|
5
4
|
|
|
6
5
|
# Filterameter
|
|
7
6
|
Filterameter provides declarative filters for Rails controllers to reduce boilerplate code and increase readability. How many times have you seen (or written) this controller action?
|
|
@@ -147,7 +146,7 @@ There are two shortcuts: : the partial option can be declared with `true`, which
|
|
|
147
146
|
```ruby
|
|
148
147
|
filter :description, partial: true
|
|
149
148
|
filter :department_name, partial: :from_start
|
|
150
|
-
filter :reason, partial: { match: :dynamic, case_sensitive: true }
|
|
149
|
+
filter :reason, partial: { match: :dynamic, case_sensitive: true }
|
|
151
150
|
```
|
|
152
151
|
|
|
153
152
|
The `match` options defines where you are searching (which then controls where the wildcard(s) appear):
|
|
@@ -267,7 +266,7 @@ There are two ways to apply the filters and build the query, depending on how mu
|
|
|
267
266
|
|
|
268
267
|
Add before action callback `build_filtered_query` for controller actions that should build the query. This can be done either in the `ApplicationController` or on a case-by-case basis.
|
|
269
268
|
|
|
270
|
-
When using the callback, the variable name is the pluralized model name. For example, the Photo model will use the variable `@photos` to store the query. The variable name can be explicitly specified with
|
|
269
|
+
When using the callback, the variable name is the pluralized model name. For example, the Photo model will use the variable `@photos` to store the query. The variable name can be explicitly specified with `filter_query_var_name`. For example, if the query is stored as `@data`, use the following:
|
|
271
270
|
|
|
272
271
|
```ruby
|
|
273
272
|
filter_query_var_name :data
|
|
@@ -338,7 +337,7 @@ Note that the starting query provides the model, so the model is not looked up a
|
|
|
338
337
|
|
|
339
338
|
### Specifying the Model
|
|
340
339
|
|
|
341
|
-
Rails conventions are used to determine the controller's model. For example, the PhotosController builds a query against the Photo model. If a controller is namespaced, the model will first be looked up without the namespace, then with the namespace.
|
|
340
|
+
Rails conventions are used to determine the controller's model. For example, the PhotosController builds a query against the Photo model. If a controller is namespaced, the model will first be looked up without the namespace, then with the namespace.
|
|
342
341
|
|
|
343
342
|
**If the conventions do not provide the correct model**, the model can be named explicitly with the following:
|
|
344
343
|
|
|
@@ -356,7 +355,7 @@ There are three configuration options:
|
|
|
356
355
|
- action_on_validation_failure
|
|
357
356
|
- filter_key
|
|
358
357
|
|
|
359
|
-
The configuration options can be set in an initializer, an environment file, or in `application.rb`.
|
|
358
|
+
The configuration options can be set in an initializer, an environment file, or in `application.rb`.
|
|
360
359
|
|
|
361
360
|
The options can be set directly...
|
|
362
361
|
|
|
@@ -367,7 +366,7 @@ The options can be set directly...
|
|
|
367
366
|
```ruby
|
|
368
367
|
Filterameter.configure do |config|
|
|
369
368
|
config.action_on_undeclared_parameters = :log
|
|
370
|
-
config.
|
|
369
|
+
config.action_on_validation_failure = :log
|
|
371
370
|
config.filter_key = :f
|
|
372
371
|
end
|
|
373
372
|
```
|
|
@@ -433,7 +432,7 @@ The sort is also nested underneath the filter key:
|
|
|
433
432
|
|
|
434
433
|
Use an array to pass multiple sorts. The order of the parameters is the order the sorts will be applied. For example, the following sorts first by size then by color:
|
|
435
434
|
|
|
436
|
-
`/widgets?filter[sort]=size&filter[sort]=color`
|
|
435
|
+
`/widgets?filter[sort][]=size&filter[sort][]=color`
|
|
437
436
|
|
|
438
437
|
Sorts are ascending by default, but can use a prefix can be added to control the sort:
|
|
439
438
|
|
|
@@ -446,7 +445,7 @@ For example, the following sorts by size descending:
|
|
|
446
445
|
|
|
447
446
|
## Contribute
|
|
448
447
|
|
|
449
|
-
Feedback, feature requests, and proposed changes are welcomed. Please use the [issue tracker](https://github.com/RockSolt/filterameter/issues)
|
|
448
|
+
Feedback, feature requests, and proposed changes are welcomed. Please use the [issue tracker](https://github.com/RockSolt/filterameter/issues)
|
|
450
449
|
for feedback and feature requests. To propose a change directly, please fork the repo and open a pull request. Keep an eye on the actions to make
|
|
451
450
|
sure the tests and Rubocop are passing. [Code Climate](https://codeclimate.com/github/RockSolt/filterameter) is also used manually to assess the codeline.
|
|
452
451
|
|
|
@@ -460,11 +459,10 @@ Gold stars will be awarded if you are able to [replicate the issue with a test](
|
|
|
460
459
|
|
|
461
460
|
### Running Tests
|
|
462
461
|
|
|
463
|
-
Tests are written in RSpec
|
|
464
|
-
database. It is a one-time step before running the tests.
|
|
462
|
+
Tests are written in RSpec.
|
|
465
463
|
|
|
466
464
|
```bash
|
|
467
|
-
bin/
|
|
465
|
+
bin/prepare_db.sh
|
|
468
466
|
bundle exec rspec
|
|
469
467
|
```
|
|
470
468
|
|
|
@@ -93,7 +93,7 @@ module Filterameter
|
|
|
93
93
|
|
|
94
94
|
# Declares a list of sorts without options. Sorts that require options must be declared with `sort`.
|
|
95
95
|
def sorts(*parameter_names)
|
|
96
|
-
parameter_names.each { |parameter_name|
|
|
96
|
+
parameter_names.each { |parameter_name| sort(parameter_name) }
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# Declares a default sort order for the query. Specify a list of sort names and directions as pairs.
|
data/lib/filterameter/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: filterameter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Todd Kummer
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-03-31 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rails
|
|
@@ -37,62 +37,6 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: 2.5.0
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: guard
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '2.16'
|
|
47
|
-
type: :development
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '2.16'
|
|
54
|
-
- !ruby/object:Gem::Dependency
|
|
55
|
-
name: guard-rspec
|
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '4.7'
|
|
61
|
-
type: :development
|
|
62
|
-
prerelease: false
|
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - "~>"
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: '4.7'
|
|
68
|
-
- !ruby/object:Gem::Dependency
|
|
69
|
-
name: guard-rubocop
|
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - "~>"
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: 1.5.0
|
|
75
|
-
type: :development
|
|
76
|
-
prerelease: false
|
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - "~>"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: 1.5.0
|
|
82
|
-
- !ruby/object:Gem::Dependency
|
|
83
|
-
name: pg
|
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - "~>"
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: 1.5.4
|
|
89
|
-
type: :development
|
|
90
|
-
prerelease: false
|
|
91
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - "~>"
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: 1.5.4
|
|
96
40
|
- !ruby/object:Gem::Dependency
|
|
97
41
|
name: rspec-rails
|
|
98
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -127,14 +71,14 @@ dependencies:
|
|
|
127
71
|
requirements:
|
|
128
72
|
- - "~>"
|
|
129
73
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: 0.
|
|
74
|
+
version: '0.6'
|
|
131
75
|
type: :development
|
|
132
76
|
prerelease: false
|
|
133
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
134
78
|
requirements:
|
|
135
79
|
- - "~>"
|
|
136
80
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: 0.
|
|
81
|
+
version: '0.6'
|
|
138
82
|
- !ruby/object:Gem::Dependency
|
|
139
83
|
name: rubocop-rails
|
|
140
84
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -155,28 +99,28 @@ dependencies:
|
|
|
155
99
|
requirements:
|
|
156
100
|
- - "~>"
|
|
157
101
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: 3.
|
|
102
|
+
version: '3.9'
|
|
159
103
|
type: :development
|
|
160
104
|
prerelease: false
|
|
161
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
162
106
|
requirements:
|
|
163
107
|
- - "~>"
|
|
164
108
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: 3.
|
|
109
|
+
version: '3.9'
|
|
166
110
|
- !ruby/object:Gem::Dependency
|
|
167
111
|
name: rubocop-rspec_rails
|
|
168
112
|
requirement: !ruby/object:Gem::Requirement
|
|
169
113
|
requirements:
|
|
170
114
|
- - "~>"
|
|
171
115
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: 2.
|
|
116
|
+
version: '2.32'
|
|
173
117
|
type: :development
|
|
174
118
|
prerelease: false
|
|
175
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
176
120
|
requirements:
|
|
177
121
|
- - "~>"
|
|
178
122
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: 2.
|
|
123
|
+
version: '2.32'
|
|
180
124
|
- !ruby/object:Gem::Dependency
|
|
181
125
|
name: simplecov
|
|
182
126
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -267,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
267
211
|
- !ruby/object:Gem::Version
|
|
268
212
|
version: '0'
|
|
269
213
|
requirements: []
|
|
270
|
-
rubygems_version: 3.6.
|
|
214
|
+
rubygems_version: 3.6.9
|
|
271
215
|
specification_version: 4
|
|
272
216
|
summary: Declarative Filter Parameters
|
|
273
217
|
test_files: []
|