ransack 1.6.6 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.travis.yml +35 -53
- data/CHANGELOG.md +530 -9
- data/CONTRIBUTING.md +63 -26
- data/Gemfile +24 -24
- data/README.md +371 -96
- data/Rakefile +6 -29
- data/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb +24 -0
- data/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb +79 -0
- data/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +11 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +80 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +1 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +74 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +93 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +1 -0
- data/lib/polyamorous/join.rb +70 -0
- data/lib/polyamorous/polyamorous.rb +24 -0
- data/lib/polyamorous/swapping_reflection_class.rb +11 -0
- data/lib/polyamorous/tree_node.rb +7 -0
- data/lib/ransack/adapters/active_record/base.rb +23 -2
- data/lib/ransack/adapters/active_record/context.rb +206 -139
- data/lib/ransack/adapters/active_record/ransack/constants.rb +70 -55
- data/lib/ransack/adapters/active_record/ransack/context.rb +10 -18
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +43 -36
- data/lib/ransack/adapters/active_record/ransack/translate.rb +1 -5
- data/lib/ransack/adapters/active_record/ransack/visitor.rb +23 -0
- data/lib/ransack/adapters/active_record.rb +11 -10
- data/lib/ransack/adapters.rb +64 -0
- data/lib/ransack/configuration.rb +91 -4
- data/lib/ransack/constants.rb +13 -26
- data/lib/ransack/context.rb +45 -40
- data/lib/ransack/helpers/form_builder.rb +21 -12
- data/lib/ransack/helpers/form_helper.rb +99 -69
- data/lib/ransack/locale/ar.yml +70 -0
- data/lib/ransack/locale/az.yml +70 -0
- data/lib/ransack/locale/bg.yml +70 -0
- data/lib/ransack/locale/ca.yml +70 -0
- data/lib/ransack/locale/da.yml +70 -0
- data/lib/ransack/locale/de.yml +70 -0
- data/lib/ransack/locale/el.yml +70 -0
- data/lib/ransack/locale/es.yml +22 -22
- data/lib/ransack/locale/fa.yml +70 -0
- data/lib/ransack/locale/fi.yml +71 -0
- data/lib/ransack/locale/id.yml +70 -0
- data/lib/ransack/locale/it.yml +70 -0
- data/lib/ransack/locale/ja.yml +70 -0
- data/lib/ransack/locale/nl.yml +4 -4
- data/lib/ransack/locale/pt-BR.yml +70 -0
- data/lib/ransack/locale/ru.yml +70 -0
- data/lib/ransack/locale/sk.yml +70 -0
- data/lib/ransack/locale/tr.yml +70 -0
- data/lib/ransack/locale/{zh.yml → zh-CN.yml} +13 -13
- data/lib/ransack/locale/zh-TW.yml +70 -0
- data/lib/ransack/nodes/attribute.rb +6 -3
- data/lib/ransack/nodes/bindable.rb +18 -6
- data/lib/ransack/nodes/condition.rb +85 -24
- data/lib/ransack/nodes/grouping.rb +17 -11
- data/lib/ransack/nodes/sort.rb +9 -5
- data/lib/ransack/nodes/value.rb +74 -68
- data/lib/ransack/nodes.rb +2 -3
- data/lib/ransack/predicate.rb +17 -20
- data/lib/ransack/search.rb +15 -15
- data/lib/ransack/translate.rb +115 -115
- data/lib/ransack/version.rb +1 -1
- data/lib/ransack/visitor.rb +1 -12
- data/lib/ransack.rb +11 -17
- data/logo/ransack-h.png +0 -0
- data/logo/ransack-h.svg +34 -0
- data/logo/ransack-v.png +0 -0
- data/logo/ransack-v.svg +34 -0
- data/logo/ransack.png +0 -0
- data/logo/ransack.svg +21 -0
- data/ransack.gemspec +9 -27
- data/spec/console.rb +4 -0
- data/spec/helpers/polyamorous_helper.rb +19 -0
- data/spec/polyamorous/join_association_spec.rb +35 -0
- data/spec/polyamorous/join_dependency_spec.rb +97 -0
- data/spec/polyamorous/join_spec.rb +19 -0
- data/spec/ransack/adapters/active_record/base_spec.rb +380 -91
- data/spec/ransack/adapters/active_record/context_spec.rb +72 -33
- data/spec/ransack/configuration_spec.rb +87 -14
- data/spec/ransack/helpers/form_builder_spec.rb +2 -11
- data/spec/ransack/helpers/form_helper_spec.rb +481 -113
- data/spec/ransack/nodes/condition_spec.rb +25 -1
- data/spec/ransack/nodes/grouping_spec.rb +62 -6
- data/spec/ransack/predicate_spec.rb +79 -5
- data/spec/ransack/search_spec.rb +159 -79
- data/spec/spec_helper.rb +8 -0
- data/spec/support/schema.rb +99 -37
- metadata +57 -184
- data/lib/ransack/adapters/active_record/3.0/compat.rb +0 -179
- data/lib/ransack/adapters/active_record/3.0/context.rb +0 -205
- data/lib/ransack/adapters/active_record/3.1/context.rb +0 -219
- data/lib/ransack/adapters/active_record/3.2/context.rb +0 -44
- data/lib/ransack/adapters/active_record/compat.rb +0 -14
- data/lib/ransack/adapters/mongoid/3.2/.gitkeep +0 -0
- data/lib/ransack/adapters/mongoid/attributes/attribute.rb +0 -37
- data/lib/ransack/adapters/mongoid/attributes/order_predications.rb +0 -17
- data/lib/ransack/adapters/mongoid/attributes/predications.rb +0 -141
- data/lib/ransack/adapters/mongoid/base.rb +0 -126
- data/lib/ransack/adapters/mongoid/context.rb +0 -208
- data/lib/ransack/adapters/mongoid/inquiry_hash.rb +0 -23
- data/lib/ransack/adapters/mongoid/ransack/constants.rb +0 -88
- data/lib/ransack/adapters/mongoid/ransack/context.rb +0 -60
- data/lib/ransack/adapters/mongoid/ransack/nodes/condition.rb +0 -27
- data/lib/ransack/adapters/mongoid/ransack/translate.rb +0 -13
- data/lib/ransack/adapters/mongoid/ransack/visitor.rb +0 -24
- data/lib/ransack/adapters/mongoid/table.rb +0 -35
- data/lib/ransack/adapters/mongoid.rb +0 -13
- data/spec/mongoid/adapters/mongoid/base_spec.rb +0 -276
- data/spec/mongoid/adapters/mongoid/context_spec.rb +0 -56
- data/spec/mongoid/configuration_spec.rb +0 -102
- data/spec/mongoid/dependencies_spec.rb +0 -8
- data/spec/mongoid/helpers/ransack_helper.rb +0 -11
- data/spec/mongoid/nodes/condition_spec.rb +0 -34
- data/spec/mongoid/nodes/grouping_spec.rb +0 -13
- data/spec/mongoid/predicate_spec.rb +0 -155
- data/spec/mongoid/search_spec.rb +0 -446
- data/spec/mongoid/support/mongoid.yml +0 -6
- data/spec/mongoid/support/schema.rb +0 -128
- data/spec/mongoid/translate_spec.rb +0 -14
- data/spec/mongoid_spec_helper.rb +0 -59
- data/spec/ransack/dependencies_spec.rb +0 -10
data/CONTRIBUTING.md
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
# Contributing to Ransack
|
2
2
|
|
3
|
-
Please take a moment to review this document
|
4
|
-
|
3
|
+
Please take a moment to review this document to make contributing easy and
|
4
|
+
effective for everyone involved!
|
5
5
|
|
6
6
|
Ransack is an open source project and we encourage contributions.
|
7
7
|
|
8
|
+
Please do not use the issue tracker for personal support requests. Stack
|
9
|
+
Overflow is a better place for that where a wider community can help you!
|
10
|
+
|
8
11
|
## Filing an issue
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
Good issue reports are extremely helpful! Please only open an issue if a bug
|
14
|
+
is caused by Ransack, is new (has not already been reported), and can be
|
15
|
+
reproduced from the information you provide.
|
12
16
|
|
13
|
-
|
17
|
+
Steps:
|
14
18
|
|
15
19
|
1. **Use the GitHub issue search** — check if the issue has already been
|
16
20
|
reported.
|
@@ -18,18 +22,25 @@ Guidelines for bug reports:
|
|
18
22
|
2. **Check if the issue has been fixed** — try to reproduce it using the
|
19
23
|
`master` branch in the repository.
|
20
24
|
|
21
|
-
3. **Isolate
|
22
|
-
|
25
|
+
3. **Isolate the real problem** — make sure the issue is really a bug in
|
26
|
+
Ransack and not in your code or another gem.
|
27
|
+
|
28
|
+
4. **Report the issue** by providing the link to a self-contained
|
29
|
+
gist like [this](https://gist.github.com/jonatack/63048bc5062a84ba9e09) or
|
30
|
+
[this](https://gist.github.com/jonatack/5df41a0edb53b7bad989). Please use
|
31
|
+
these code examples as a bug-report template for your Ransack issue!
|
23
32
|
|
24
|
-
|
33
|
+
If you do not provide a self-contained gist and would like your issue to be reviewed, do provide at a minimum:
|
25
34
|
|
26
|
-
* A comprehensive list of steps to reproduce the issue, or
|
27
|
-
|
35
|
+
* A comprehensive list of steps to reproduce the issue, or even better, a
|
36
|
+
passing/failing test spec.
|
37
|
+
* Whether you are using Ransack through another gem like ActiveAdmin,
|
38
|
+
SimpleForm, etc.
|
39
|
+
* The versions of Ruby, Rails, Ransack and the database.
|
28
40
|
* Any relevant stack traces ("Full trace" preferred).
|
29
41
|
|
30
|
-
|
31
|
-
|
32
|
-
if the information requested is provided.
|
42
|
+
Issues filed without the above information or that remain open without activity
|
43
|
+
for 14 days will be closed. They can be re-opened if actionable information to reproduce the issue is provided.
|
33
44
|
|
34
45
|
## Pull requests
|
35
46
|
|
@@ -53,6 +64,9 @@ Here's a quick guide:
|
|
53
64
|
2. Create a thoughtfully-named branch for your changes (`git checkout -b my-new-feature`).
|
54
65
|
|
55
66
|
3. Install the development dependencies by running `bundle install`.
|
67
|
+
To install rails other than latest (set in Gemfile): `RAILS='5-2-stable' bundle install`
|
68
|
+
|
69
|
+
$ RAILS='5-2-stable' bundle install
|
56
70
|
|
57
71
|
4. Begin by running the tests. We only take pull requests with passing tests,
|
58
72
|
and it's great to know that you have a clean slate:
|
@@ -61,11 +75,30 @@ Here's a quick guide:
|
|
61
75
|
|
62
76
|
The test suite runs by default with SQLite3. To run the test suite with PostgreSQL or MySQL, use:
|
63
77
|
|
64
|
-
$ DB=
|
78
|
+
$ DB=pg bundle exec rake spec (`DB=postgres` & `DB=postgresql` work too)
|
65
79
|
$ DB=mysql bundle exec rake spec
|
66
80
|
|
67
|
-
|
68
|
-
|
81
|
+
For Postgres and MySQL, databases are expected to exist, called 'ransack'. To create use these commands (assuming OS X and Homebrew):
|
82
|
+
|
83
|
+
### Postgres
|
84
|
+
$ createdb ransack
|
85
|
+
|
86
|
+
### MySQL
|
87
|
+
$ mysql -u root
|
88
|
+
mysql> create database ransack;
|
89
|
+
|
90
|
+
The test suite runs by default
|
91
|
+
|
92
|
+
To run only the tests in a particular file: `bundle exec rspec <path/to/filename>`
|
93
|
+
|
94
|
+
$ bundle exec rspec spec/ransack/search_spec.rb
|
95
|
+
|
96
|
+
To run a single test in that file: `bundle exec rspec <path/to/filename> -e "test name"`
|
97
|
+
|
98
|
+
$ bundle exec rspec spec/ransack/search_spec.rb -e "accepts a context option"
|
99
|
+
|
100
|
+
5. Hack away! Please use Ruby features that are compatible down to Ruby 2.3.
|
101
|
+
Since version 2.3.1, Ransack no longer maintains Ruby 2.2 compatibility.
|
69
102
|
|
70
103
|
6. Add tests for your changes. Only refactoring and documentation changes
|
71
104
|
require no new tests. If you are adding functionality or fixing a bug, we
|
@@ -76,20 +109,24 @@ Here's a quick guide:
|
|
76
109
|
8. Update the Change Log. If you are adding new functionality, document it in
|
77
110
|
the README.
|
78
111
|
|
79
|
-
9.
|
112
|
+
9. Make sure git knows your name and email address in your `~/.gitconfig` file:
|
113
|
+
|
114
|
+
$ git config --global user.name "Your Name"
|
115
|
+
$ git config --global user.email "contributor@example.com"
|
80
116
|
|
81
|
-
10.
|
117
|
+
10. Commit your changes (`git commit -am 'Add feature/fix bug/improve docs'`).
|
118
|
+
If your pull request only contains documentation changes, please remember
|
119
|
+
to add `[skip ci]` to the beginning of your commit message so the Travis
|
120
|
+
test suite doesn't :runner: needlessly.
|
121
|
+
|
122
|
+
11. If necessary, rebase your commits into logical chunks, without errors. To
|
82
123
|
interactively rebase and cherry-pick from, say, the last 10 commits:
|
83
124
|
`git rebase -i HEAD~10`, then `git push -f`.
|
84
125
|
|
85
|
-
|
86
|
-
(`git push origin my-new-feature`) and from
|
126
|
+
12. Push the branch up to your fork on GitHub
|
127
|
+
(`git push origin my-new-feature`) and from GitHub submit a pull request to
|
87
128
|
Ransack's `master` branch.
|
88
129
|
|
89
|
-
12. If your pull request only contains documentation changes, please remember
|
90
|
-
to add `[skip ci]` to the beginning of your commit message so the Travis
|
91
|
-
test suite doesn't :runner: needlessly.
|
92
|
-
|
93
130
|
At this point you're waiting on us. We like to at least comment on, if not
|
94
131
|
accept, pull requests within three business days (and, typically, one business
|
95
132
|
day). We may suggest some changes or improvements or alternatives.
|
@@ -107,11 +144,11 @@ Syntax:
|
|
107
144
|
* 80 characters per line.
|
108
145
|
* No trailing whitespace. Blank lines should not have any space.
|
109
146
|
* Prefer `&&`/`||` over `and`/`or`.
|
110
|
-
* `MyClass.my_method(my_arg)` not `my_method( my_arg )` or my_method my_arg
|
147
|
+
* `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
|
111
148
|
* `a = b` and not `a=b`.
|
112
149
|
* `a_method { |block| ... }` and not `a_method { | block | ... }` or
|
113
150
|
`a_method{|block| ...}`.
|
114
151
|
* Prefer simplicity, readability, and maintainability over terseness.
|
115
152
|
* Follow the conventions you see used in the code already.
|
116
153
|
|
117
|
-
And in case we didn't emphasize it enough:
|
154
|
+
And in case we didn't emphasize it enough: We love tests!
|
data/Gemfile
CHANGED
@@ -3,49 +3,49 @@ gemspec
|
|
3
3
|
|
4
4
|
gem 'rake'
|
5
5
|
|
6
|
-
rails = ENV['RAILS'] || '
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
gem '
|
6
|
+
rails = ENV['RAILS'] || '6-0-stable'
|
7
|
+
|
8
|
+
rails_version = case rails
|
9
|
+
when /\// # A path
|
10
|
+
File.read(File.join(rails, "RAILS_VERSION"))
|
11
|
+
when /^v/ # A tagged version
|
12
|
+
rails.gsub(/^v/, '')
|
13
|
+
else
|
14
|
+
rails
|
15
|
+
end
|
16
|
+
|
17
|
+
gem 'faker', '~> 1.0'
|
18
|
+
gem 'sqlite3', ::Gem::Version.new(rails_version) >= ::Gem::Version.new('6-0-stable') ? '~> 1.4.1' : '~> 1.3.3'
|
19
|
+
gem 'pg', '~> 1.0'
|
20
|
+
gem 'pry', '~> 0.12.2'
|
21
|
+
gem 'byebug'
|
19
22
|
|
20
23
|
case rails
|
21
24
|
when /\// # A path
|
22
25
|
gem 'activesupport', path: "#{rails}/activesupport"
|
26
|
+
gem 'activemodel', path: "#{rails}/activemodel"
|
23
27
|
gem 'activerecord', path: "#{rails}/activerecord", require: false
|
24
28
|
gem 'actionpack', path: "#{rails}/actionpack"
|
29
|
+
gem 'actionview', path: "#{rails}/actionview"
|
25
30
|
when /^v/ # A tagged version
|
26
|
-
git '
|
31
|
+
git 'https://github.com/rails/rails.git', :tag => rails do
|
27
32
|
gem 'activesupport'
|
28
33
|
gem 'activemodel'
|
29
34
|
gem 'activerecord', require: false
|
30
35
|
gem 'actionpack'
|
31
36
|
end
|
32
37
|
else
|
33
|
-
git '
|
38
|
+
git 'https://github.com/rails/rails.git', :branch => rails do
|
34
39
|
gem 'activesupport'
|
35
40
|
gem 'activemodel'
|
36
41
|
gem 'activerecord', require: false
|
37
42
|
gem 'actionpack'
|
38
43
|
end
|
39
|
-
if rails == '3-0-stable'
|
40
|
-
gem 'mysql2', '< 0.3'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if ENV['DB'] =~ /mongodb/
|
45
|
-
gem 'mongoid', '~> 4.0.0', require: false
|
46
44
|
end
|
45
|
+
gem 'mysql2', '~> 0.5.2'
|
47
46
|
|
48
|
-
# Removed from Ruby 2.2 but needed for testing Rails 3.x.
|
49
47
|
group :test do
|
50
|
-
gem '
|
48
|
+
gem 'machinist', '~> 1.0.6'
|
49
|
+
gem 'rspec', '~> 3'
|
50
|
+
gem 'simplecov', :require => false
|
51
51
|
end
|