filter_param 0.1.0 → 0.1.1

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: ff8a89676339b2fb5deed26115ac897d11e77b554ddd10156c746b8313e9626e
4
- data.tar.gz: 7f1f7f22bd1f106fe4818edf3dcc454f34897a0e0f9b73a9110f026424872008
3
+ metadata.gz: 52b10f4534c9bf5eab527c35e7cab383e56c7dcdfb2c531271a38e3818561db3
4
+ data.tar.gz: 815c6681873e7eef0e638cf8d0a98765da5a8098a66b7a04dd49ea3015f9a430
5
5
  SHA512:
6
- metadata.gz: f2cc08c9fdbae1de993f41b9d4204592a1bf80fd35586e45eb684cb5cd1478977e0d55a35b53d9b7d14b49514db93268d8baa9bf5a26be59ea8b4bfe2aa41c5a
7
- data.tar.gz: 1aec98d47ae4177b0061fcaec187ce894cfda9d9d288b6fd0d5c15e9327619139066767fce65489bf0dccc5e84e5b29eae069c10f8f4ae2c0a2a94e4fd08f27b
6
+ metadata.gz: 37e9b67785a663b8534a3cc1ed3fcddcc15b16a446207fa7c4568afd8109eb0b298522711afaa0b6e9f6fd95cee82fb4f488b2adc09152fdf43b8240134703fa
7
+ data.tar.gz: 949338fd3fa5fdcad4f7e3c18773bac49d48cb627b26054a4bb2cca7b785eeabed7d4f8b8a59a54aa7c3f1ebbbc334583f8b172ec0aa356fa3d6231334c43abf
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- MIT License
1
+ The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 Jayson
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 all
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 THE
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,5 +1,7 @@
1
1
  # FilterParam
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/filter_param.svg)](https://badge.fury.io/rb/filter_param) [![CI](https://github.com/jsonb-uy/filter_param/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/jsonb-uy/filter_param/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/jsonb-uy/filter_param/graph/badge.svg?token=9242ULA2DC)](https://codecov.io/gh/jsonb-uy/filter_param) [![Maintainability](https://api.codeclimate.com/v1/badges/fb4df56368843000d1fd/maintainability)](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):
@@ -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 4.2** and above
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: 7-0** <br/><br/> `4-2`,`5-0`,`5-1`,`5-2`,`6-0`,`6-1`,`7-0` |```RAILS_VERSION=5-2 ./bin/setup```<br/><br/>```RAILS_VERSION=5-2 bundle exec rspec```<br/><br/> ```RAILS_VERSION=5-2 ./bin/console```|
164
+ | `RAILS_VERSION` | **Default: 7-1** <br/><br/> `6-0`,`6-1`,`7-0`,`7-1` |```RAILS_VERSION=6-0 ./bin/setup```<br/><br/>```RAILS_VERSION=6-0 bundle exec rspec```<br/><br/> ```RAILS_VERSION=6-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/rotulus.
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
 
@@ -1,7 +1,7 @@
1
1
  module FilterParam
2
2
  module Operators
3
3
  class NotEqual < FieldFilterOperator
4
- operator_tag :neq
4
+ operator_tag :ne
5
5
 
6
6
  def self.sql(field, literal)
7
7
  return "#{field.actual_name} IS NOT NULL" if literal.value.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FilterParam
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.0
4
+ version: 0.1.1
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-05-12 00:00:00.000000000 Z
11
+ date: 2024-05-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: '4.2'
33
+ version: '6.0'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '7.1'
36
+ version: '7.2'
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: '4.2'
43
+ version: '6.0'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '7.1'
46
+ version: '7.2'
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: '4.2'
53
+ version: '6.0'
54
54
  - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: '7.1'
56
+ version: '7.2'
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: '4.2'
63
+ version: '6.0'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: '7.1'
66
+ version: '7.2'
67
67
  description: Filter records using a SCIM inspired filter expression
68
68
  email:
69
69
  - uy.json.dev@gmail.com
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.4.6
139
+ rubygems_version: 3.1.4
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: SCIM-style API filter for ActiveRecord-based apps