tiny_filter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +46 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +154 -0
- data/Rakefile +12 -0
- data/lib/tiny_filter/base.rb +32 -0
- data/lib/tiny_filter/concern.rb +15 -0
- data/lib/tiny_filter/filter_finder.rb +28 -0
- data/lib/tiny_filter/generators/tiny_filter/filter/USAGE +8 -0
- data/lib/tiny_filter/generators/tiny_filter/filter/filter_generator.rb +25 -0
- data/lib/tiny_filter/generators/tiny_filter/filter/templates/filter.rb.erb +9 -0
- data/lib/tiny_filter/generators/tiny_filter/install/USAGE +8 -0
- data/lib/tiny_filter/generators/tiny_filter/install/install_generator.rb +16 -0
- data/lib/tiny_filter/generators/tiny_filter/install/templates/application_filter.rb +5 -0
- data/lib/tiny_filter/version.rb +5 -0
- data/lib/tiny_filter.rb +15 -0
- data/sig/tiny_filter.rbs +4 -0
- data/tiny_filter.gemspec +45 -0
- metadata +254 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 52eb68e11715585163330d5f814e72744ad26114320d87dd9dd1cb80326bf3a7
|
4
|
+
data.tar.gz: c57812b379ade0d6dcdd4f262c6cd1e00773c15f9e1d6292594eff133eef4556
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 757d3bc888fc7658bb1c72ce82871be05f4dcf90d50eb48b9cf610267f11f2a44b12e6844b84d074593f19de61462e4daf44cb1e43452ce55117562bebebd5e4
|
7
|
+
data.tar.gz: 59f7ae5777c94a9b01c7f51848ae9e3ee3b365643e44702e836ccd42c3a77d5fc93f21eecd47aefac9a327dee8d644d3f39476c6e114ce1fa1779fbcc9245174
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rails
|
4
|
+
- rubocop-rake
|
5
|
+
- rubocop-rspec
|
6
|
+
|
7
|
+
inherit_gem:
|
8
|
+
rubocop-shopify: rubocop.yml
|
9
|
+
|
10
|
+
AllCops:
|
11
|
+
TargetRubyVersion: 2.6
|
12
|
+
NewCops: enable
|
13
|
+
|
14
|
+
Layout/EmptyLinesAroundAccessModifier:
|
15
|
+
EnforcedStyle: around
|
16
|
+
|
17
|
+
Layout/IndentationConsistency:
|
18
|
+
EnforcedStyle: normal
|
19
|
+
|
20
|
+
Layout/EmptyLinesAroundClassBody:
|
21
|
+
EnforcedStyle: empty_lines_special
|
22
|
+
|
23
|
+
Style/SymbolArray:
|
24
|
+
EnforcedStyle: percent
|
25
|
+
|
26
|
+
Style/WordArray:
|
27
|
+
EnforcedStyle: percent
|
28
|
+
|
29
|
+
Style/MethodCallWithArgsParentheses:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Metrics/BlockLength:
|
33
|
+
Exclude:
|
34
|
+
- "spec/**/*"
|
35
|
+
|
36
|
+
RSpec/ExampleLength:
|
37
|
+
Max: 10
|
38
|
+
|
39
|
+
RSpec/ContextWording:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
RSpec/MultipleExpectations:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Rails/Date:
|
46
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at kirill.usanov.dev@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 LassoID
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
# TinyFilter
|
2
|
+
|
3
|
+
TinyFilter is created to provide a simple object-oriented abstraction layer for filtering collections.
|
4
|
+
It is mainly purposed for ActiveRecord collections, but you can also use it with any enumerable.
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
Post.where(title: "Wow!").filter_by(from: 2.days.ago, to: 1.day.ago).order(:created_at)
|
8
|
+
```
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
1. Install the gem and add to the application's Gemfile by executing:
|
13
|
+
|
14
|
+
```shell
|
15
|
+
bundle add tiny_filter
|
16
|
+
```
|
17
|
+
|
18
|
+
2. Generate an application filter as an entry point to all your future filters:
|
19
|
+
|
20
|
+
```shell
|
21
|
+
bin/rails g tiny_filter:install
|
22
|
+
```
|
23
|
+
|
24
|
+
This will generate `ApplicationFilter` inside `app/filters` directory.
|
25
|
+
This directory is intended to store all your filters.
|
26
|
+
|
27
|
+
## Adding a filter
|
28
|
+
|
29
|
+
To generate a filter class simply run `tiny_filter:filter` command.
|
30
|
+
|
31
|
+
For example, to create a filter class for `Post` with filters `from` and `to`, run:
|
32
|
+
|
33
|
+
```shell
|
34
|
+
bin/rails g tiny_filter:filter post from to
|
35
|
+
```
|
36
|
+
|
37
|
+
This will generate the `PostFilter` class inside the `app/filters` directory with `from` and `to` filters.
|
38
|
+
|
39
|
+
Each filter is defined by calling `filters` method inside class body.
|
40
|
+
|
41
|
+
`filters` accepts two arguments:
|
42
|
+
- `key` - a filter name, used as identifier;
|
43
|
+
- `block` - a block or proc/lambda with filter logic, that returns filtered collection and itself accepts two arguments:
|
44
|
+
- `scope` - a collection that should be filtered;
|
45
|
+
- `value` - a value for filtering.
|
46
|
+
|
47
|
+
When you perform filtering, provided keys indicate filters `key`s and provided `value`s are passed to corresponding filters `block`s.
|
48
|
+
`scope`s receive collections in a pipeline manner:
|
49
|
+
_first_ executed filter receives _original collection_,
|
50
|
+
_second and further_ receive the _return collection_ of the previous filter.
|
51
|
+
|
52
|
+
To execute filtering, simply call `filter` with the initial scope and options provided.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
class UserFilter < ApplicationFilter
|
56
|
+
filters(:name) { |scope, value| scope.where(first_name: value) }
|
57
|
+
filters(:surname) { |scope, value| scope.where(last_name: value) }
|
58
|
+
end
|
59
|
+
|
60
|
+
UserFilter.filter(User, name: "John", surname: "Doe")
|
61
|
+
# It performs like this inside:
|
62
|
+
# User.where(first_name: "John").where(last_name: "Doe")
|
63
|
+
```
|
64
|
+
|
65
|
+
Notice, that your filters _must_ return the same scope type as they accept.
|
66
|
+
It guarantees that scope behaves the same way as in other filters in this class.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
filters(:title) { |scope, value| scope.where("title ILIKE ?", value) }
|
70
|
+
|
71
|
+
# bad - scope is meant to be ActiveRecord collection, but the return value is an array.
|
72
|
+
filters(:from) { |scope, value| scope.select { |e| e.created_at >= value } }
|
73
|
+
|
74
|
+
# good - scope and return value are both ActiveRecord collections.
|
75
|
+
filters(:from) { |scope, value| scope.where("created_at >= ?", value) }
|
76
|
+
```
|
77
|
+
|
78
|
+
So, if the initial scope for filtering is ActiveRecord collection,
|
79
|
+
it is a bad practice for filter to return not an ActiveRecord collection.
|
80
|
+
Otherwise you can face errors depending on the provided options order.
|
81
|
+
|
82
|
+
## ActiveRecord integration
|
83
|
+
|
84
|
+
### Helper
|
85
|
+
|
86
|
+
TinyFilter provides a simple concern, that adds just one method `filter_by`, that can be used in ActiveRecord method chaining.
|
87
|
+
|
88
|
+
Just include `TinyFilter::Concern` in your model and that's all!
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
class Post < ApplicationRecord
|
92
|
+
include TinyFilter::Concern
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
Now you can use filtering everywhere in your model method chaining.
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
Post.where(title: "something interesting").filter_by(from: 2.days.ago, to: 1.day.ago).order(:title)
|
100
|
+
Post.filter_by(from: 1.year.ago)
|
101
|
+
```
|
102
|
+
|
103
|
+
### Naming convention
|
104
|
+
|
105
|
+
By default a filter class and a model are mapped by a _model name_ with a _suffix_ `Filter`.
|
106
|
+
For example, the model `My::Class` by default will use the `My::ClassFilter` as a filter class.
|
107
|
+
|
108
|
+
You can customize this behavior by implementing a `filter_class` class method with an appropriate class as a return value.
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
class My::Class < ApplicationRecord
|
112
|
+
# ...
|
113
|
+
def self.filter_class
|
114
|
+
CustomFilter
|
115
|
+
end
|
116
|
+
# ...
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
### Using with Plain objects
|
121
|
+
|
122
|
+
You can use filters with non-ActiveRecord collections like so:
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
options # filter options, for example: `{ from: 2.days.ago, to: 1.day.ago }`
|
126
|
+
collection # can be any Enumerable: array, hash, your custom collection, etc etc
|
127
|
+
|
128
|
+
MyFilter.filter(collection, options)
|
129
|
+
```
|
130
|
+
|
131
|
+
## Development
|
132
|
+
|
133
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec`/`rspec` to run the tests.
|
134
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
135
|
+
|
136
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
137
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
|
138
|
+
which will create a git tag for the version, push git commits and the created tag,
|
139
|
+
and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
140
|
+
|
141
|
+
## Contributing
|
142
|
+
|
143
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lassoid/tiny_filter.
|
144
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors
|
145
|
+
are expected to adhere to the [code of conduct](https://github.com/lassoid/tiny_filter/blob/main/CODE_OF_CONDUCT.md).
|
146
|
+
|
147
|
+
## License
|
148
|
+
|
149
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
150
|
+
|
151
|
+
## Code of Conduct
|
152
|
+
|
153
|
+
Everyone interacting in the TinyFilter project's codebases, issue trackers, chat rooms and mailing lists
|
154
|
+
is expected to follow the [code of conduct](https://github.com/lassoid/tiny_filter/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TinyFilter
|
4
|
+
class Base
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def filters(key, &block)
|
8
|
+
key = key.to_sym
|
9
|
+
raise AlreadyDefinedError, "filter :#{key} defined more than once in #{self}" if __filters__.key?(key)
|
10
|
+
|
11
|
+
__filters__[key] = block
|
12
|
+
end
|
13
|
+
|
14
|
+
def filter(base_scope, args = {})
|
15
|
+
args.inject(base_scope) do |scope, (key, value)|
|
16
|
+
key = key.to_sym
|
17
|
+
raise NotDefinedError, "unable to find filter :#{key} in #{self}" unless __filters__.key?(key)
|
18
|
+
|
19
|
+
__filters__[key].call(scope, value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def __filters__
|
26
|
+
@__filters__ ||= {}
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TinyFilter
|
4
|
+
module Concern
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
if defined?(ActiveRecord::Base) && self <= ActiveRecord::Base
|
9
|
+
scope :filter_by, ->(args = {}) { TinyFilter::FilterFinder.find(self).filter(self, args) }
|
10
|
+
else
|
11
|
+
raise Error, "unable to include TinyFilter::Concern in #{self} that is not an ActiveRecord::Base descendant"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TinyFilter
|
4
|
+
class FilterFinder
|
5
|
+
SUFFIX = "Filter"
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def find(object)
|
10
|
+
filter_class(object)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def filter_class(object)
|
16
|
+
if object.respond_to?(:filter_class)
|
17
|
+
object.filter_class
|
18
|
+
elsif object.respond_to?(:model_name)
|
19
|
+
"#{object.model_name}#{SUFFIX}".constantize
|
20
|
+
else
|
21
|
+
raise Error, "unable to find appropriate filter class for #{object}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TinyFilter
|
4
|
+
module Generators
|
5
|
+
class FilterGenerator < ::Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
argument :keys, type: :array, required: false, default: []
|
9
|
+
|
10
|
+
desc "This generator creates a filter for provided model"
|
11
|
+
|
12
|
+
def create_filter
|
13
|
+
template_file = File.join("app/filters", class_path, filter_file_name)
|
14
|
+
template "filter.rb.erb", template_file
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def filter_file_name
|
20
|
+
"#{file_name}_filter.rb"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TinyFilter
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
desc "This generator creates an application filter"
|
9
|
+
|
10
|
+
def copy_application_filter
|
11
|
+
template "application_filter.rb", "app/filters/application_filter.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/tiny_filter.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
require "active_support/core_ext/string/inflections"
|
5
|
+
|
6
|
+
require "tiny_filter/version"
|
7
|
+
require "tiny_filter/base"
|
8
|
+
require "tiny_filter/filter_finder"
|
9
|
+
require "tiny_filter/concern"
|
10
|
+
|
11
|
+
module TinyFilter
|
12
|
+
class Error < StandardError; end
|
13
|
+
class NotDefinedError < Error; end
|
14
|
+
class AlreadyDefinedError < Error; end
|
15
|
+
end
|
data/sig/tiny_filter.rbs
ADDED
data/tiny_filter.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/tiny_filter/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "tiny_filter"
|
7
|
+
spec.version = TinyFilter::VERSION
|
8
|
+
spec.authors = ["Kirill Usanov", "LassoID"]
|
9
|
+
spec.email = ["kirill.usanov.dev@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Tiny filtering for Rails."
|
12
|
+
spec.description = "Simple filtering for your Rails models and enumerables."
|
13
|
+
spec.homepage = "https://github.com/lassoid/tiny_filter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/lassoid/tiny_filter"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/lassoid/tiny_filter/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
%x(git ls-files -z).split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Dependencies
|
33
|
+
spec.add_dependency "activesupport", ">= 6.0", "< 7.1"
|
34
|
+
spec.add_development_dependency "activerecord", ">= 6.0", "< 7.1"
|
35
|
+
spec.add_development_dependency "railties", ">= 6.0", "< 7.1"
|
36
|
+
spec.add_development_dependency "rake"
|
37
|
+
spec.add_development_dependency "rspec"
|
38
|
+
spec.add_development_dependency "rubocop"
|
39
|
+
spec.add_development_dependency "rubocop-performance"
|
40
|
+
spec.add_development_dependency "rubocop-rails"
|
41
|
+
spec.add_development_dependency "rubocop-rake"
|
42
|
+
spec.add_development_dependency "rubocop-rspec"
|
43
|
+
spec.add_development_dependency "rubocop-shopify"
|
44
|
+
spec.add_development_dependency "sqlite3"
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,254 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tiny_filter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kirill Usanov
|
8
|
+
- LassoID
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2022-12-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '6.0'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '7.1'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '6.0'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '7.1'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: activerecord
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.0'
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '7.1'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '6.0'
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '7.1'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: railties
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '6.0'
|
61
|
+
- - "<"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '7.1'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '6.0'
|
71
|
+
- - "<"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '7.1'
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: rake
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: rspec
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
type: :development
|
96
|
+
prerelease: false
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: rubocop
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
type: :development
|
110
|
+
prerelease: false
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: rubocop-performance
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
name: rubocop-rails
|
132
|
+
requirement: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
type: :development
|
138
|
+
prerelease: false
|
139
|
+
version_requirements: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
- !ruby/object:Gem::Dependency
|
145
|
+
name: rubocop-rake
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
type: :development
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: rubocop-rspec
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
type: :development
|
166
|
+
prerelease: false
|
167
|
+
version_requirements: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
- !ruby/object:Gem::Dependency
|
173
|
+
name: rubocop-shopify
|
174
|
+
requirement: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
type: :development
|
180
|
+
prerelease: false
|
181
|
+
version_requirements: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
- !ruby/object:Gem::Dependency
|
187
|
+
name: sqlite3
|
188
|
+
requirement: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
type: :development
|
194
|
+
prerelease: false
|
195
|
+
version_requirements: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
description: Simple filtering for your Rails models and enumerables.
|
201
|
+
email:
|
202
|
+
- kirill.usanov.dev@gmail.com
|
203
|
+
executables: []
|
204
|
+
extensions: []
|
205
|
+
extra_rdoc_files: []
|
206
|
+
files:
|
207
|
+
- ".rspec"
|
208
|
+
- ".rubocop.yml"
|
209
|
+
- CHANGELOG.md
|
210
|
+
- CODE_OF_CONDUCT.md
|
211
|
+
- Gemfile
|
212
|
+
- LICENSE
|
213
|
+
- README.md
|
214
|
+
- Rakefile
|
215
|
+
- lib/tiny_filter.rb
|
216
|
+
- lib/tiny_filter/base.rb
|
217
|
+
- lib/tiny_filter/concern.rb
|
218
|
+
- lib/tiny_filter/filter_finder.rb
|
219
|
+
- lib/tiny_filter/generators/tiny_filter/filter/USAGE
|
220
|
+
- lib/tiny_filter/generators/tiny_filter/filter/filter_generator.rb
|
221
|
+
- lib/tiny_filter/generators/tiny_filter/filter/templates/filter.rb.erb
|
222
|
+
- lib/tiny_filter/generators/tiny_filter/install/USAGE
|
223
|
+
- lib/tiny_filter/generators/tiny_filter/install/install_generator.rb
|
224
|
+
- lib/tiny_filter/generators/tiny_filter/install/templates/application_filter.rb
|
225
|
+
- lib/tiny_filter/version.rb
|
226
|
+
- sig/tiny_filter.rbs
|
227
|
+
- tiny_filter.gemspec
|
228
|
+
homepage: https://github.com/lassoid/tiny_filter
|
229
|
+
licenses:
|
230
|
+
- MIT
|
231
|
+
metadata:
|
232
|
+
homepage_uri: https://github.com/lassoid/tiny_filter
|
233
|
+
source_code_uri: https://github.com/lassoid/tiny_filter
|
234
|
+
changelog_uri: https://github.com/lassoid/tiny_filter/blob/main/CHANGELOG.md
|
235
|
+
post_install_message:
|
236
|
+
rdoc_options: []
|
237
|
+
require_paths:
|
238
|
+
- lib
|
239
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: 2.6.0
|
244
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
|
+
requirements:
|
246
|
+
- - ">="
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: '0'
|
249
|
+
requirements: []
|
250
|
+
rubygems_version: 3.3.7
|
251
|
+
signing_key:
|
252
|
+
specification_version: 4
|
253
|
+
summary: Tiny filtering for Rails.
|
254
|
+
test_files: []
|