rad_core_rails 0.4.1 → 0.5.4
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/.gitignore +16 -15
- data/.rspec +3 -3
- data/.travis.yml +5 -5
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +13 -6
- data/LICENSE.txt +21 -21
- data/README.md +44 -44
- data/Rakefile +6 -6
- data/lib/rad_core_rails.rb +15 -14
- data/lib/rad_core_rails/query_generator.rb +241 -161
- data/lib/rad_core_rails/search_terms.rb +30 -30
- data/lib/rad_core_rails/sortable.rb +14 -14
- data/lib/rad_core_rails/version.rb +5 -3
- data/rad_core_rails.gemspec +39 -39
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48f739f3efcd0dbc68c15a40a1342153a8a403b6e7fadc8e17c2ea77b87ebf34
|
4
|
+
data.tar.gz: 5827e62ec17c57d74b43f9027a2fa65989d7df2bee37c1b60c814cc1f2d00998
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af53c0879f5c3bd089fa94a6b1644e2b7548bc8a583de55a838a10824a69f7790b6120360ff922f0c5d57021232a3f0c44c12522e31cb116483b718cb38ea457
|
7
|
+
data.tar.gz: 4f7d2ac6a1ca1056effe24ef813999e0e9b07a70d07ba320f5915471691aca34bacaefa90fffdd0d7740abc8626d7f221a6eee33312005410fd84e90bb03dd12
|
data/.gitignore
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
/.idea/
|
2
|
-
/.bundle/
|
3
|
-
/.yardoc
|
4
|
-
/_yardoc/
|
5
|
-
/coverage/
|
6
|
-
/doc/
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/tmp/
|
10
|
-
Gemfile.lock
|
11
|
-
bin
|
12
|
-
*.gem
|
13
|
-
.rspec_status
|
14
|
-
.ruby-gemset
|
15
|
-
.ruby-version
|
1
|
+
/.idea/
|
2
|
+
/.bundle/
|
3
|
+
/.yardoc
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
Gemfile.lock
|
11
|
+
bin
|
12
|
+
*.gem
|
13
|
+
.rspec_status
|
14
|
+
.ruby-gemset
|
15
|
+
.ruby-version
|
16
|
+
/.byebug_history
|
data/.rspec
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
--format documentation
|
2
|
-
--color
|
3
|
-
--require spec_helper
|
1
|
+
--format documentation
|
2
|
+
--color
|
3
|
+
--require spec_helper
|
data/.travis.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
---
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
rvm:
|
5
|
-
- 2.4.5
|
1
|
+
---
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
rvm:
|
5
|
+
- 2.4.5
|
6
6
|
- 2.7.0
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at sancho.ck@gmail.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: https://contributor-covenant.org
|
74
|
-
[version]: https://contributor-covenant.org/version/1/4/
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at sancho.ck@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in new_gem.gemspec
|
6
|
-
gemspec
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in new_gem.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'byebug'
|
10
|
+
gem 'pg'
|
11
|
+
gem 'database_cleaner-active_record'
|
12
|
+
gem "factory_bot_rails"
|
13
|
+
end
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2020 Oleksandr Poltavets
|
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
|
13
|
-
all 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
|
21
|
-
THE SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Oleksandr Poltavets
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
# RadCoreRails
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rad_core_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'rad_core_rails'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install rad_core_rails
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rad_core_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rad_core_rails/blob/master/CODE_OF_CONDUCT.md).
|
36
|
-
|
37
|
-
|
38
|
-
## License
|
39
|
-
|
40
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
-
|
42
|
-
## Code of Conduct
|
43
|
-
|
44
|
-
Everyone interacting in the RadCoreRails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rad_core_rails/blob/master/CODE_OF_CONDUCT.md).
|
1
|
+
# RadCoreRails
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rad_core_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rad_core_rails'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rad_core_rails
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rad_core_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rad_core_rails/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the RadCoreRails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rad_core_rails/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
task :default => :spec
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
data/lib/rad_core_rails.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
require "rad_core_rails/version"
|
2
|
-
require "active_support/concern"
|
3
|
-
require "
|
4
|
-
require
|
5
|
-
require 'rad_core_rails/
|
6
|
-
require 'rad_core_rails/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
1
|
+
require "rad_core_rails/version"
|
2
|
+
require "active_support/concern"
|
3
|
+
require "active_support/core_ext"
|
4
|
+
require "active_record"
|
5
|
+
require 'rad_core_rails/query_generator'
|
6
|
+
require 'rad_core_rails/search_terms'
|
7
|
+
require 'rad_core_rails/sortable'
|
8
|
+
|
9
|
+
module RadCoreRails
|
10
|
+
def self.included(receiver)
|
11
|
+
receiver.send :include, Sortable, SearchTerms, QueryGenerator
|
12
|
+
end
|
13
|
+
|
14
|
+
class Error < StandardError; end
|
15
|
+
end
|
@@ -1,161 +1,241 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
arguments
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
arguments
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
[str, args]
|
136
|
-
end
|
137
|
-
|
138
|
-
def
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RadCoreRails
|
4
|
+
module QueryGenerator
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
class_methods do
|
8
|
+
attr_reader :searchable_columns
|
9
|
+
|
10
|
+
def searchable(columns = [])
|
11
|
+
@searchable_columns = handle_columns(columns)
|
12
|
+
end
|
13
|
+
|
14
|
+
def joins_clause
|
15
|
+
<<-SQL
|
16
|
+
SQL
|
17
|
+
end
|
18
|
+
|
19
|
+
def filter_manifest
|
20
|
+
{}.with_indifferent_access
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_filters(search, filters)
|
24
|
+
query = []
|
25
|
+
args = []
|
26
|
+
clause, arguments = generate_search_clause(search)
|
27
|
+
query << clause
|
28
|
+
arguments.each do |arg|
|
29
|
+
args << arg
|
30
|
+
end
|
31
|
+
filters.map do |filter|
|
32
|
+
clause, arguments = filter_manifest[filter[:key]].call(filter)
|
33
|
+
query << clause
|
34
|
+
arguments.each do |arg|
|
35
|
+
args << arg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
[query.reject(&:blank?).join(' AND '), args]
|
39
|
+
end
|
40
|
+
|
41
|
+
# def generate_search_clause(search)
|
42
|
+
# and_args = []
|
43
|
+
# or_args = []
|
44
|
+
# if search.present? && searchable_columns.is_a?(Array)
|
45
|
+
# # search_term_size = search.split(' ').length
|
46
|
+
# and_terms = search.split(' ').select { |term| !term.include?('+') }
|
47
|
+
# or_terms = search.split(' ').select { |term| term.include?('+') }
|
48
|
+
# and_columns = []
|
49
|
+
# or_columns = []
|
50
|
+
# # just_ors = search_term_size == or_term_size
|
51
|
+
# # operand = just_ors ? 'OR' : 'AND'
|
52
|
+
# # search_terms = just_ors == true ? search.split(' ') : search.split(' ').select { |term| !term.include?('+') }
|
53
|
+
# and_terms.each do |term|
|
54
|
+
# columns = []
|
55
|
+
# and_terms.each do |col|
|
56
|
+
# and_columns.push("(LOWER(#{col}) ILIKE ?)")
|
57
|
+
# and_args.push '%' + term.downcase.strip + '%'
|
58
|
+
# end
|
59
|
+
# or_terms.each do |col|
|
60
|
+
# columns.push("(LOWER(#{col}) ILIKE ?)")
|
61
|
+
# or_args.push '%' + term[1, term.length].downcase.strip + '%'
|
62
|
+
# end
|
63
|
+
# clause = if or_columns.empty?
|
64
|
+
# '(' + and_columns.join(' OR ') + ')'
|
65
|
+
# else
|
66
|
+
# '(' + '(' + and_columns.join(' OR ') + ')' + 'AND' + '(' + or_columns.join(' OR ') + ')' + ')'
|
67
|
+
# end
|
68
|
+
# end
|
69
|
+
# [clause, and_args + or_args]
|
70
|
+
# else
|
71
|
+
# ['', []]
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
|
75
|
+
# @searchable_columns, is an array of column names that you can compare to your terms.
|
76
|
+
#
|
77
|
+
def generate_search_clause(search)
|
78
|
+
if search.present? && searchable_columns.is_a?(Array)
|
79
|
+
# holds all of the sql from sanitized_and_terms
|
80
|
+
and_args = []
|
81
|
+
# holds all the table columns sql for all the AND terms
|
82
|
+
and_clause = []
|
83
|
+
# holds all of the sql from sanitized_or_terms
|
84
|
+
or_args = []
|
85
|
+
# holds all the table columns sql for all the OR terms
|
86
|
+
or_clause = []
|
87
|
+
# extract and terms, remove casing, and add ILIKE '%' comparisions
|
88
|
+
sanitized_and_terms = search.split(' ')
|
89
|
+
.reject { |term| term.include?('+') }
|
90
|
+
.map { |term| '%' + term.downcase.strip + '%' }
|
91
|
+
# extract or terms, remove casing, and add ILIKE '%' comparisions
|
92
|
+
sanitized_or_terms = search.split(' ')
|
93
|
+
.select { |term| term.include?('+') }
|
94
|
+
.map { |term| '%' + term[1, term.length].downcase.strip + '%' }
|
95
|
+
# loop through sanitized_and_terms to find all possible columns.
|
96
|
+
sanitized_and_terms.each do |sanitized_term|
|
97
|
+
columns = []
|
98
|
+
# all possible columns where this should be searched
|
99
|
+
searchable_columns.each do |col|
|
100
|
+
columns.push("(LOWER(#{col}) ILIKE ?)")
|
101
|
+
and_args.push sanitized_term
|
102
|
+
end
|
103
|
+
and_clause.push '(' + columns.join(' OR ') + ')'
|
104
|
+
end
|
105
|
+
# loop through sanitized_or_terms to find all possible columns.
|
106
|
+
sanitized_or_terms.each do |sanitized_term|
|
107
|
+
columns = []
|
108
|
+
# all possible columns where this should be searched
|
109
|
+
searchable_columns.each do |col|
|
110
|
+
columns.push("(LOWER(#{col}) ILIKE ?)")
|
111
|
+
or_args.push sanitized_term
|
112
|
+
end
|
113
|
+
or_clause.push '(' + columns.join(' OR ') + ')'
|
114
|
+
end
|
115
|
+
if or_clause.empty? && and_clause.empty?
|
116
|
+
['', []]
|
117
|
+
elsif or_clause.empty?
|
118
|
+
['(' + and_clause.join(' AND ') + ')', and_args]
|
119
|
+
elsif and_clause.empty?
|
120
|
+
['(' + or_clause.join(' OR ') + ')', or_args]
|
121
|
+
else
|
122
|
+
['((' + and_clause.join(' AND ') + ') AND (' + or_clause.join(' OR ') + '))', and_args + or_args]
|
123
|
+
end
|
124
|
+
else
|
125
|
+
['', []]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Generate Boolean clause
|
130
|
+
def generate_boolean_clause(column_name, filter)
|
131
|
+
str = "#{column_name} = ?"
|
132
|
+
args = []
|
133
|
+
args << filter[:values][0]
|
134
|
+
|
135
|
+
[str, args]
|
136
|
+
end
|
137
|
+
|
138
|
+
def generate_model_clause(column_name, filter, optional_exclusion_clause = nil)
|
139
|
+
str = if optional_exclusion_clause.present? && filter[:option] == '!='
|
140
|
+
optional_exclusion_clause
|
141
|
+
else
|
142
|
+
# probably should fix this.
|
143
|
+
# somtimes we arent sending a filter option, so just default it to =
|
144
|
+
"(#{column_name} #{filter[:option] || '='} ANY(ARRAY[?]))"
|
145
|
+
end
|
146
|
+
args = [filter[:values]]
|
147
|
+
|
148
|
+
[str, args]
|
149
|
+
end
|
150
|
+
|
151
|
+
def generate_array_clause(column_name, filter)
|
152
|
+
str = "(#{column_name} && ARRAY[?])"
|
153
|
+
args = [filter[:values]]
|
154
|
+
|
155
|
+
[str, args]
|
156
|
+
end
|
157
|
+
|
158
|
+
def generate_reference_link_clause(link_out_type, filter)
|
159
|
+
str = "(reference_links.link_out_type = '#{link_out_type}' AND reference_links.link_out_id = ANY(?))"
|
160
|
+
args = [filter[:values]]
|
161
|
+
|
162
|
+
[str, args]
|
163
|
+
end
|
164
|
+
|
165
|
+
def generate_jsonb_array_clause(unique_filter_key, column_name, filter)
|
166
|
+
str = "(#{column_name} ?| ARRAY[:#{unique_filter_key}])"
|
167
|
+
args = [{ "#{unique_filter_key}": filter[:values] }]
|
168
|
+
|
169
|
+
[str, args]
|
170
|
+
end
|
171
|
+
|
172
|
+
def generate_number_clause(column_name, filter)
|
173
|
+
option = filter[:option]
|
174
|
+
values = filter[:values]
|
175
|
+
str = ''
|
176
|
+
args = []
|
177
|
+
|
178
|
+
case option
|
179
|
+
when '='
|
180
|
+
str = "#{column_name} = ?"
|
181
|
+
args << values[0]
|
182
|
+
when '>'
|
183
|
+
str = "#{column_name} > ?"
|
184
|
+
args << values[0]
|
185
|
+
when '<'
|
186
|
+
str = "#{column_name} < ?"
|
187
|
+
args << values[0]
|
188
|
+
when '..'
|
189
|
+
str = "(#{column_name} BETWEEN ? AND ?)"
|
190
|
+
args << values[0]
|
191
|
+
args << values[1]
|
192
|
+
end
|
193
|
+
[str, args]
|
194
|
+
end
|
195
|
+
|
196
|
+
def generate_date_clause(column_name, filter)
|
197
|
+
option = filter[:option]
|
198
|
+
values = filter[:values]
|
199
|
+
str = ''
|
200
|
+
args = []
|
201
|
+
|
202
|
+
case option
|
203
|
+
when '='
|
204
|
+
str = "#{column_name}::date = ?::date"
|
205
|
+
args << values[0]
|
206
|
+
when '>'
|
207
|
+
str = "#{column_name}::date > ?::date"
|
208
|
+
args << values[0]
|
209
|
+
when '<'
|
210
|
+
str = "#{column_name}::date < ?::date"
|
211
|
+
args << values[0]
|
212
|
+
when '..'
|
213
|
+
str = "(#{column_name}::date BETWEEN ?::date AND ?::date)"
|
214
|
+
args << values[0]
|
215
|
+
args << values[1]
|
216
|
+
end
|
217
|
+
[str, args]
|
218
|
+
end
|
219
|
+
|
220
|
+
def sort_direction(direction)
|
221
|
+
direction == 'asc' ? 'ASC' : 'DESC'
|
222
|
+
end
|
223
|
+
|
224
|
+
private
|
225
|
+
|
226
|
+
def handle_columns(columns)
|
227
|
+
return self.columns.select { |c| c.type == :string }.map { |c| "#{table_name}.#{c.name}" } if columns.empty?
|
228
|
+
|
229
|
+
columns.map do |c|
|
230
|
+
splitted_c = c.split('.')
|
231
|
+
|
232
|
+
if splitted_c.size == 1 && splitted_c.first != table_name
|
233
|
+
"#{table_name}.#{c}"
|
234
|
+
else
|
235
|
+
c
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
@@ -1,31 +1,31 @@
|
|
1
|
-
module RadCoreRails
|
2
|
-
module SearchTerms
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
class_methods do
|
6
|
-
def _terms(column, search = '')
|
7
|
-
if search.present?
|
8
|
-
if column.is_a?(Array)
|
9
|
-
terms = []
|
10
|
-
search.split(' ').each do |term|
|
11
|
-
columns = []
|
12
|
-
column.each do |col|
|
13
|
-
columns.push("(replace(lower(#{Arel.sql(col)}), ' ', '') ILIKE '%#{Arel.sql(term.downcase)}%')")
|
14
|
-
end
|
15
|
-
terms.push '(' + columns.join(' OR ') + ')'
|
16
|
-
end
|
17
|
-
'(' + terms.join(' AND ') + ')'
|
18
|
-
else
|
19
|
-
terms = []
|
20
|
-
search.split(' ').each do |term|
|
21
|
-
terms.push("(replace(lower(#{Arel.sql(column)}), ' ', '') ILIKE '%#{Arel.sql(term.downcase)}%')")
|
22
|
-
end
|
23
|
-
'(' + terms.join(' AND ') + ')'
|
24
|
-
end
|
25
|
-
else
|
26
|
-
'1 = 1'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
module RadCoreRails
|
2
|
+
module SearchTerms
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
class_methods do
|
6
|
+
def _terms(column, search = '')
|
7
|
+
if search.present?
|
8
|
+
if column.is_a?(Array)
|
9
|
+
terms = []
|
10
|
+
search.split(' ').each do |term|
|
11
|
+
columns = []
|
12
|
+
column.each do |col|
|
13
|
+
columns.push("(replace(lower(#{Arel.sql(col)}), ' ', '') ILIKE '%#{Arel.sql(term.downcase)}%')")
|
14
|
+
end
|
15
|
+
terms.push '(' + columns.join(' OR ') + ')'
|
16
|
+
end
|
17
|
+
'(' + terms.join(' AND ') + ')'
|
18
|
+
else
|
19
|
+
terms = []
|
20
|
+
search.split(' ').each do |term|
|
21
|
+
terms.push("(replace(lower(#{Arel.sql(column)}), ' ', '') ILIKE '%#{Arel.sql(term.downcase)}%')")
|
22
|
+
end
|
23
|
+
'(' + terms.join(' AND ') + ')'
|
24
|
+
end
|
25
|
+
else
|
26
|
+
'1 = 1'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
31
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module RadCoreRails
|
3
|
-
module Sortable
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
scope :sort_order, ->(column, direction) { order(self.sort_column(column, direction)) }
|
8
|
-
|
9
|
-
def self.sort_column(column, direction)
|
10
|
-
"#{Arel.sql(column)} #{sort_direction(direction)}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module RadCoreRails
|
3
|
+
module Sortable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
scope :sort_order, ->(column, direction) { order(self.sort_column(column, direction)) }
|
8
|
+
|
9
|
+
def self.sort_column(column, direction)
|
10
|
+
"#{Arel.sql(column)} #{sort_direction(direction)}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/rad_core_rails.gemspec
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
require_relative 'lib/rad_core_rails/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "rad_core_rails"
|
5
|
-
spec.version = RadCoreRails::VERSION
|
6
|
-
spec.authors = ["Oleksandr Poltavets, James Marrs"]
|
7
|
-
spec.email = ["sancho.ck@gmail.com"]
|
8
|
-
|
9
|
-
spec.summary = %q{RadCoreRails}
|
10
|
-
spec.description = %q{RadCoreRails lib}
|
11
|
-
spec.homepage = "https://github.com/jamesmarrs/rad-core-rails"
|
12
|
-
spec.license = "MIT"
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
-
|
15
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
-
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://rubygems.org/gems/rad_core_rails"
|
19
|
-
spec.metadata["changelog_uri"] = "https://rubygems.org/gems/rad_core_rails"
|
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(File.expand_path('..', __FILE__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
end
|
26
|
-
spec.bindir = "exe"
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = ["lib"]
|
29
|
-
|
30
|
-
spec.add_dependency "activesupport", '>= 4.2'
|
31
|
-
spec.add_dependency "activemodel", '>= 4.2'
|
32
|
-
spec.add_dependency "activerecord", '>= 4.2'
|
33
|
-
# spec.add_dependency 'pg', '>= 0.17.1'
|
34
|
-
spec.add_development_dependency "actionpack", '>= 4.2'
|
35
|
-
spec.add_development_dependency "bundler", '>= 1.17.3'
|
36
|
-
spec.add_development_dependency "rake"
|
37
|
-
spec.add_development_dependency "rspec", '>= 3.0'
|
38
|
-
# spec.add_development_dependency "simplecov", '~> 0.17', '>= 0.18.5'
|
39
|
-
end
|
1
|
+
require_relative 'lib/rad_core_rails/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "rad_core_rails"
|
5
|
+
spec.version = RadCoreRails::VERSION
|
6
|
+
spec.authors = ["Oleksandr Poltavets, James Marrs"]
|
7
|
+
spec.email = ["sancho.ck@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{RadCoreRails}
|
10
|
+
spec.description = %q{RadCoreRails lib}
|
11
|
+
spec.homepage = "https://github.com/jamesmarrs/rad-core-rails"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://rubygems.org/gems/rad_core_rails"
|
19
|
+
spec.metadata["changelog_uri"] = "https://rubygems.org/gems/rad_core_rails"
|
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(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "activesupport", '>= 4.2'
|
31
|
+
spec.add_dependency "activemodel", '>= 4.2'
|
32
|
+
spec.add_dependency "activerecord", '>= 4.2'
|
33
|
+
# spec.add_dependency 'pg', '>= 0.17.1'
|
34
|
+
spec.add_development_dependency "actionpack", '>= 4.2'
|
35
|
+
spec.add_development_dependency "bundler", '>= 1.17.3'
|
36
|
+
spec.add_development_dependency "rake"
|
37
|
+
spec.add_development_dependency "rspec", '>= 3.0'
|
38
|
+
# spec.add_development_dependency "simplecov", '~> 0.17', '>= 0.18.5'
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rad_core_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleksandr Poltavets, James Marrs
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -137,7 +137,7 @@ metadata:
|
|
137
137
|
homepage_uri: https://github.com/jamesmarrs/rad-core-rails
|
138
138
|
source_code_uri: https://rubygems.org/gems/rad_core_rails
|
139
139
|
changelog_uri: https://rubygems.org/gems/rad_core_rails
|
140
|
-
post_install_message:
|
140
|
+
post_install_message:
|
141
141
|
rdoc_options: []
|
142
142
|
require_paths:
|
143
143
|
- lib
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
155
|
rubygems_version: 3.1.2
|
156
|
-
signing_key:
|
156
|
+
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: RadCoreRails
|
159
159
|
test_files: []
|