filter_param 0.1.0 → 0.1.2
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/LICENSE +6 -6
- data/README.md +43 -5
- data/lib/filter_param/operators/not_equal.rb +1 -1
- data/lib/filter_param/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de400285fef06e40c4fecfce5809f779e3e7f6a834bb3ed3eaed0ead52efd23
|
4
|
+
data.tar.gz: bbceeed1263674b164f83fab40cc222dda49c82a347324b179daacf0e2c5a174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea27449e9a1101a71516961bfaccf3a4c985b0a8ea7407e2a2fe0085a84b8ac0c8d2027a23ab76de0c518513b24cc85211704deddb02bb8a2c189bc66e107efc
|
7
|
+
data.tar.gz: 9641a2b718c5ca9acb27dfcb4341f68c0f4d053f477d641259077a6d1c0dab8fc14a5e98bbc5a908b04231cc802dc09aaed013549980fa03c0e7d88ccc8e6bdf
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
MIT License
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2024 jsonb-uy
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
10
10
|
furnished to do so, subject to the following conditions:
|
11
11
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
copies or substantial portions of the Software.
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
14
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
SOFTWARE.
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# FilterParam
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/filter_param) [](https://github.com/jsonb-uy/filter_param/actions/workflows/ci.yml) [](https://codecov.io/gh/jsonb-uy/filter_param) [](https://codeclimate.com/github/jsonb-uy/filter_param/maintainability)
|
4
|
+
|
3
5
|
### Record Filtering for apps built on Rails/ActiveRecord
|
4
6
|
|
5
7
|
Quickly implement record filtering in your APIs using a filter expression inspired by [SCIM Query](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2):
|
6
8
|
|
7
9
|
```ruby
|
8
|
-
https://{some origin}/users?filter=
|
9
|
-
not (active eq false and (birth_date gt '1991-01-01' or birth_date eq null))
|
10
|
+
https://{some origin}/users?filter=first_name eq 'John' and last_name pr and
|
11
|
+
not (active eq false and (birth_date gt '1991-01-01' or birth_date eq null))
|
10
12
|
```
|
11
13
|
|
12
14
|
**TL;DR** See [ sample usage for Rails here ](#rails-usage).
|
@@ -21,8 +23,44 @@ https://{some origin}/users?filter="first_name eq 'John' and last_name pr and
|
|
21
23
|
* Allows custom filter operators
|
22
24
|
* Expression grouping
|
23
25
|
* Supports **MySQL**, **PostgreSQL**, and **SQLite**
|
24
|
-
* Supports **Rails
|
26
|
+
* Supports **Rails 6** and above
|
27
|
+
|
28
|
+
### Field Filter Operators
|
29
|
+
| Operator | Description | Example |
|
30
|
+
| ----------- | ----------- | ----------- |
|
31
|
+
| `eq` | Equal | name eq 'John' |
|
32
|
+
| `eq_ci` | Case-insensitive Equal | name eq_ci 'joHn' |
|
33
|
+
| `ne` | Not Equal | name ne 'john' |
|
34
|
+
| `co` | Contains | name co 'oh' |
|
35
|
+
| `sw ` | Starts With | name sw 'J' |
|
36
|
+
| `pr ` | Present (has value) | name pr |
|
37
|
+
| `gt` | Greater than | age gt 42 |
|
38
|
+
| `ge` | Greater than or equal to | price ge 19.80 |
|
39
|
+
| `lt` | Less than | created_at lt '2023-03-01T08:09:00+07:00' |
|
40
|
+
| `le` | Less than or equal to | birthdate le '1985-05-01' |
|
41
|
+
|
42
|
+
### Logical Operators
|
43
|
+
| Operator | Description |
|
44
|
+
| ----------- | ----------- |
|
45
|
+
| `and` | Logical "and" |
|
46
|
+
| `or` | Logical "or" |
|
47
|
+
| `not` | "Not" function |
|
25
48
|
|
49
|
+
### Grouping Operator
|
50
|
+
| Operator | Description |
|
51
|
+
| ----------- | ----------- |
|
52
|
+
| `()` | Precedence grouping |
|
53
|
+
|
54
|
+
### Literals
|
55
|
+
| Type | Filter Definition Symbol | Examples |
|
56
|
+
|-----------|----------- | ----------- |
|
57
|
+
| Boolean| `:boolean` | `true`, `false` |
|
58
|
+
| Integer| `:integer` | 40012, 100, 0, -51 |
|
59
|
+
| Decimal| `:decimal` | 4002.12, 0.05, -41.13 |
|
60
|
+
| String| `:string` | 'foo bar' |
|
61
|
+
| Date (ISO format) | `:date` | '2024-12-31' |
|
62
|
+
| Timestamp (ISO format) | `:datetime` | '2023-03-01T01:09:01.000Z', '2023-03-01T09:09:00+09:00' |
|
63
|
+
| Null | N/A | null |
|
26
64
|
|
27
65
|
## Installation
|
28
66
|
|
@@ -123,7 +161,7 @@ rel.to_sql
|
|
123
161
|
| Environment Variable | Values | Example |
|
124
162
|
| ----------- | ----------- |----------- |
|
125
163
|
| `DB_ADAPTER` | **Default: :sqlite**. `sqlite`,`mysql2`, or `postgresql` | ```DB_ADAPTER=postgresql bundle exec rspec```<br/><br/> ```DB_ADAPTER=postgresql ./bin/console``` |
|
126
|
-
| `RAILS_VERSION` | **Default:
|
164
|
+
| `RAILS_VERSION` | **Default: 8-0** <br/><br/> `6-0`,`6-1`,`7-0`,`7-1`, `7-2`, `8-0` |```RAILS_VERSION=8-0 ./bin/setup```<br/><br/>```RAILS_VERSION=8-0 bundle exec rspec```<br/><br/> ```RAILS_VERSION=8-0 ./bin/console```|
|
127
165
|
|
128
166
|
|
129
167
|
<br/><br/>
|
@@ -131,7 +169,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
131
169
|
|
132
170
|
## Contributing
|
133
171
|
|
134
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/jsonb-uy/
|
172
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jsonb-uy/filter_param.
|
135
173
|
|
136
174
|
## License
|
137
175
|
|
data/lib/filter_param/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filter_param
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uy Jayson B
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -30,40 +30,40 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '6.0'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '8.1'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '6.0'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '8.1'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '6.0'
|
54
54
|
- - "<"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '8.1'
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '6.0'
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '8.1'
|
67
67
|
description: Filter records using a SCIM inspired filter expression
|
68
68
|
email:
|
69
69
|
- uy.json.dev@gmail.com
|