scoped_search 2.7.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -23
- data/CHANGELOG.rdoc +193 -0
- data/CONTRIBUTING.rdoc +38 -0
- data/{Gemfile.activerecord4 → Gemfile.activerecord40} +1 -1
- data/{Gemfile.activerecord2 → Gemfile.activerecord41} +2 -2
- data/README.rdoc +15 -20
- data/app/assets/stylesheets/scoped_search.scss +0 -4
- data/lib/scoped_search.rb +2 -27
- data/lib/scoped_search/auto_complete_builder.rb +40 -34
- data/lib/scoped_search/definition.rb +7 -5
- data/lib/scoped_search/query_builder.rb +3 -34
- data/lib/scoped_search/query_language.rb +0 -3
- data/lib/scoped_search/rails_helper.rb +45 -46
- data/lib/scoped_search/railtie.rb +11 -6
- data/lib/scoped_search/version.rb +1 -1
- data/scoped_search.gemspec +8 -7
- data/spec/integration/api_spec.rb +2 -41
- data/spec/integration/auto_complete_spec.rb +5 -5
- data/spec/integration/key_value_querying_spec.rb +9 -9
- data/spec/integration/ordinal_querying_spec.rb +46 -48
- data/spec/integration/relation_querying_spec.rb +30 -30
- data/spec/integration/set_query_spec.rb +7 -7
- data/spec/integration/string_querying_spec.rb +48 -50
- data/spec/lib/matchers.rb +2 -2
- data/spec/spec_helper.rb +8 -0
- data/spec/unit/ast_spec.rb +3 -3
- metadata +26 -22
- data/init.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af5bbaee1bcd8c43d9a31e7facd1cbb132b6de4c
|
4
|
+
data.tar.gz: 3f7bbad05696d74941c0f878b5c9aea2f87ad242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1057f7ecafc42146520d82c06ccb045854df6b941b68ffadfae12177888b12582dd79f8ca0d2087a6e22b610545755b77be3e20fa77a7b98ba79bad04f3571b0
|
7
|
+
data.tar.gz: 8a6795724808b89895fe7eaa90d99fd7f3aef5e5afefd8a178ba6ca70d1a6f2ded74585a56d12af7c841eeb2c76d037af7e980ad9df75005a2561ef2c37715aa
|
data/.travis.yml
CHANGED
@@ -1,38 +1,29 @@
|
|
1
|
+
|
1
2
|
language: ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
- mysql -e 'create database scoped_search_test;'
|
3
|
+
|
4
|
+
sudo: false
|
5
|
+
|
6
6
|
rvm:
|
7
|
-
- 1.8.7
|
8
7
|
- 1.9.3
|
9
8
|
- 2.0.0
|
10
9
|
- 2.1.1
|
11
10
|
- ruby-head
|
12
|
-
- jruby-18mode
|
13
11
|
- jruby-19mode
|
14
12
|
- jruby-head
|
13
|
+
|
15
14
|
gemfile:
|
16
|
-
- Gemfile.activerecord2
|
17
15
|
- Gemfile.activerecord3
|
18
|
-
- Gemfile.
|
16
|
+
- Gemfile.activerecord40
|
17
|
+
- Gemfile.activerecord41
|
18
|
+
|
19
|
+
before_script:
|
20
|
+
- psql -c 'create database scoped_search_test;' -U postgres
|
21
|
+
- mysql -e 'create database scoped_search_test;'
|
22
|
+
|
23
|
+
script: bundle exec rake
|
24
|
+
|
19
25
|
matrix:
|
20
26
|
include:
|
21
27
|
allow_failures:
|
22
28
|
- rvm: ruby-head
|
23
29
|
- rvm: jruby-head
|
24
|
-
- rvm: 2.0.0
|
25
|
-
gemfile: Gemfile.activerecord2
|
26
|
-
- rvm: 2.1.1
|
27
|
-
gemfile: Gemfile.activerecord2
|
28
|
-
exclude:
|
29
|
-
- rvm: jruby-18mode
|
30
|
-
gemfile: Gemfile.activerecord2
|
31
|
-
- rvm: jruby-19mode
|
32
|
-
gemfile: Gemfile.activerecord2
|
33
|
-
- rvm: jruby-head
|
34
|
-
gemfile: Gemfile.activerecord2
|
35
|
-
- rvm: 1.8.7
|
36
|
-
gemfile: Gemfile.activerecord4
|
37
|
-
- rvm: jruby-18mode
|
38
|
-
gemfile: Gemfile.activerecord4
|
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
= Changelog
|
2
|
+
|
3
|
+
This page describes the changes that have been made to *scoped_search* over its history.
|
4
|
+
|
5
|
+
Please add an entry to the "Unreleased changes" section in your pull requests.
|
6
|
+
|
7
|
+
=== Unreleased changes
|
8
|
+
|
9
|
+
*Nothing yet*
|
10
|
+
|
11
|
+
=== Version 3.0
|
12
|
+
|
13
|
+
- Add support for ActiveRecord 4.1
|
14
|
+
- Drop support for Ruby 1.8
|
15
|
+
- Drop support for ActiveRecord 2.
|
16
|
+
- No longer require jQuery UI automatically; you have to do this yourself now.
|
17
|
+
- Auto completion: deprecate javascript helpers in favor of asset pipeline.
|
18
|
+
- Remove some deprecated 1.x APIs.
|
19
|
+
- Upgraded to RSpec 3.
|
20
|
+
- Extract Oracle query builder enhancements to plugin gem: https://github.com/wvanbergen/scoped_search-oracle_enhanced
|
21
|
+
- Extract H2 query builder enhancements to plugin gem: https://github.com/wvanbergen/scoped_search-h2
|
22
|
+
|
23
|
+
=== Version 2.7.1
|
24
|
+
|
25
|
+
- Fix order SQL generation issue on PostgreSQL for the autocompleter.
|
26
|
+
|
27
|
+
=== Version 2.7.0
|
28
|
+
|
29
|
+
- Allow setting a default sort order
|
30
|
+
- Fix a sorting bug for field names starting with `desc`.
|
31
|
+
- SQL generation fixes.
|
32
|
+
- Improve test coverage
|
33
|
+
|
34
|
+
=== Version 2.6.5
|
35
|
+
|
36
|
+
- Allow disabling certain fields for autocompletion.
|
37
|
+
|
38
|
+
=== Version 2.6.4
|
39
|
+
|
40
|
+
- jQuery 1.9 support for automplete helpers.
|
41
|
+
|
42
|
+
=== Version 2.6.3
|
43
|
+
|
44
|
+
- Bugfixes in querying plymorphic has many through relations.
|
45
|
+
|
46
|
+
=== Version 2.6.2
|
47
|
+
|
48
|
+
- Add support for querying plymorphic has many through relations.
|
49
|
+
|
50
|
+
=== Version 2.6.1
|
51
|
+
|
52
|
+
- Fix a SQL generation bug.
|
53
|
+
|
54
|
+
=== Version 2.6.0
|
55
|
+
|
56
|
+
- Improve logic for querying one to many relations.
|
57
|
+
- Add a Railtie for better Rails integration.
|
58
|
+
- Project infrastructure changes: remove infinity test, update LICENSE
|
59
|
+
|
60
|
+
=== Version 2.5.1
|
61
|
+
|
62
|
+
- Fixes to asset pipeline for auto completer UI helpers.
|
63
|
+
- Use bundler for gem release management
|
64
|
+
|
65
|
+
=== Version 2.5.0
|
66
|
+
|
67
|
+
- Add support for ActiveRecord 4.0
|
68
|
+
- Add support for Ruby 2.0
|
69
|
+
- Fix encoding bug
|
70
|
+
|
71
|
+
=== Version 2.4.1
|
72
|
+
|
73
|
+
- Add asset pipeline support for autocompleter UI helpers
|
74
|
+
- Fix query parser bug.
|
75
|
+
|
76
|
+
=== Version 2.4.0
|
77
|
+
|
78
|
+
- Raise an appropriate exception when referring to a database field that does not exists.
|
79
|
+
- Drop support for GROUP BY; just use DISTINCT for these use cases
|
80
|
+
- Add support for PostgreSQL full text search.
|
81
|
+
- Many bugfixes.
|
82
|
+
- Improved specs.
|
83
|
+
- Add Travis CI testing for all supported databases.
|
84
|
+
|
85
|
+
=== Version 2.3.7
|
86
|
+
|
87
|
+
- Add support for IN and NOT IN queries.
|
88
|
+
- Bug fix in SQL generation.
|
89
|
+
|
90
|
+
=== Version 2.3.6
|
91
|
+
|
92
|
+
- Minor bugfixes in auto completer.
|
93
|
+
|
94
|
+
=== Version 2.3.5
|
95
|
+
|
96
|
+
- Small bugfixes in auto completer.
|
97
|
+
|
98
|
+
=== Version 2.3.4
|
99
|
+
|
100
|
+
- Small bugfixes.
|
101
|
+
|
102
|
+
=== Version 2.3.3
|
103
|
+
|
104
|
+
- Add filtering and limiting support to autocompleter.
|
105
|
+
- Documentation updates
|
106
|
+
|
107
|
+
=== Version 2.3.2
|
108
|
+
|
109
|
+
<i>Retracted</i>
|
110
|
+
|
111
|
+
=== Version 2.3.1
|
112
|
+
|
113
|
+
- Raise exception when trying to run an invalid query.
|
114
|
+
- Several bug fixes in SQL generation
|
115
|
+
- Several other minor bugfixes.
|
116
|
+
|
117
|
+
=== Version 2.3.0
|
118
|
+
|
119
|
+
- Added support for querying key-value relations.
|
120
|
+
- Improved querying of relations.
|
121
|
+
- Add support for syntax and value autocompletion of queries.
|
122
|
+
- Add Rails UI helpers for autocompletion
|
123
|
+
- Localized handling of dates
|
124
|
+
- Fixed some Ruby 1.9 compatibility issues
|
125
|
+
- Test coverage enhancements
|
126
|
+
- Improved project infrastructure with infinity test and bundler.
|
127
|
+
|
128
|
+
=== Version 2.2.1
|
129
|
+
|
130
|
+
- Fix a parsing bug that would cause exceptions to be raised on certain queries.
|
131
|
+
- Upgrade to RSpec 2
|
132
|
+
- Fixed some Ruby 1.9 compatibility issues
|
133
|
+
|
134
|
+
=== Version 2.2.0
|
135
|
+
|
136
|
+
- Improved gem release management rake tasks.
|
137
|
+
|
138
|
+
=== Version 2.1.1
|
139
|
+
|
140
|
+
- Better handling of <tt>NULL</tt> values when evaluating queries.
|
141
|
+
- Improved support for ActiveRecord 3.0.
|
142
|
+
- Added an incomplete Oracle adapter.
|
143
|
+
|
144
|
+
=== Version 2.1.0
|
145
|
+
|
146
|
+
- Support for multiple search profiles.
|
147
|
+
- Documentation improvements.
|
148
|
+
|
149
|
+
=== Version 2.0.1
|
150
|
+
|
151
|
+
- Improved project infrastructure and documentation
|
152
|
+
|
153
|
+
=== Version 2.0
|
154
|
+
|
155
|
+
- Complete rewrite, to support a more complex query language. It now supports operators, logical constructs including parentheses, NULL checks, searching in a single field only.
|
156
|
+
- More fine-grained control over in what fields should be searched by using a new definition syntax. (The old syntax is still available for backwards compatibility.
|
157
|
+
- Migrated testsuite from Test::Unit to RSpec.
|
158
|
+
|
159
|
+
=== Version 1.2
|
160
|
+
|
161
|
+
- Ruby 1.9 compatibility
|
162
|
+
|
163
|
+
=== Version 1.1
|
164
|
+
|
165
|
+
- Support for integer fields
|
166
|
+
- RCov integrated in testuite
|
167
|
+
|
168
|
+
=== Version 1.0
|
169
|
+
|
170
|
+
- RDoc documentation
|
171
|
+
- Improved testsuite
|
172
|
+
|
173
|
+
=== Version 0.7
|
174
|
+
|
175
|
+
- Use the <tt>ILIKE</tt> operator in PostgreSQL for case insensitive search.
|
176
|
+
- Tests can be run on different DBMSs.
|
177
|
+
|
178
|
+
=== Version 0.6
|
179
|
+
|
180
|
+
- Search in associated models as well using <tt>ActiveRecord</tt> associations.
|
181
|
+
|
182
|
+
=== Version 0.3
|
183
|
+
|
184
|
+
- Detection of column types so they can be handled properly
|
185
|
+
- Date based queries supported on date and time fields
|
186
|
+
|
187
|
+
=== Version 0.2
|
188
|
+
|
189
|
+
- <tt>OR</tt> keyword supported in query language
|
190
|
+
|
191
|
+
=== Version 0.1.0
|
192
|
+
|
193
|
+
- Initial version
|
data/CONTRIBUTING.rdoc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
= Contributing
|
2
|
+
|
3
|
+
Scoped search is an open source project, and hence we are open for contributions from anybody.
|
4
|
+
|
5
|
+
== Reporting issues
|
6
|
+
|
7
|
+
When reporting an issue, make sure to include the following information so we can pinpoint the problem faster:
|
8
|
+
|
9
|
+
- What query did you use?
|
10
|
+
- What is the search definition used on your models?
|
11
|
+
- What do the tables involved in your search definition look like? Please include the type of the fields.
|
12
|
+
- A sample of records. Which one did you expect to be included in the result
|
13
|
+
|
14
|
+
Finally, please include the following information about your environment.
|
15
|
+
|
16
|
+
- What version of scoped search you are using (e.g. 2.0).
|
17
|
+
- What database, including version you are using. (e.g. PostgreSQL 9.3)
|
18
|
+
- What version of ActiveRecord you are using (e.g. 4.1).
|
19
|
+
- What version of Ruby you are using (e.g. MRI 2.1.1)
|
20
|
+
|
21
|
+
Please test your problem with the latest released version first. It's the only version that we support.
|
22
|
+
|
23
|
+
|
24
|
+
== Submitting pull requests
|
25
|
+
|
26
|
+
We will gladly accept contributions to this library. Just fork it, make your changes and open a pull request. In order to keep the quality of this library high, and maintain it in the long run, we will code review your changes before merging. We sometimes do not accept changes if we feel it is outside the scope of the project. Feel free to contact if you are unsure.
|
27
|
+
|
28
|
+
To get started understanding the structure of the library, read https://github.com/wvanbergen/scoped_search/wiki/Design-and-internals. It has a short overview of the different components and how they work together.
|
29
|
+
|
30
|
+
To get your code accepted as quickly as possible, keep the following in mind:
|
31
|
+
|
32
|
+
- Don't break backwards compatibility. If for some reason you really have to, please contact us first.
|
33
|
+
- Follow code conventions. They are not written down, so try to follow the style of the surrounding code.
|
34
|
+
- Make sure RDoc comments for the methods you add or change are up to date. You can use Yardoc extensions.
|
35
|
+
- Add or update specs for the functionality you add or change.
|
36
|
+
- Make sure that the specs pass for every version of ActiveRecord, every version of Ruby, and every database we support. Feel free to rely on Travis CI to do this (https://travis-ci.org/wvanbergen/scoped_search/).
|
37
|
+
- Do <b>not</b> update <tt>ScopedSearch::VERSION</tt>.
|
38
|
+
- Add an short entry describing your changes to the "Unreleased changes" section of <tt>CHANGELOG.rdoc</tt>.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
gem 'activerecord', '~>
|
4
|
+
gem 'activerecord', '~> 4.1.0'
|
5
5
|
|
6
6
|
platforms :jruby do
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter'
|
@@ -11,6 +11,6 @@ end
|
|
11
11
|
|
12
12
|
platforms :ruby do
|
13
13
|
gem 'sqlite3'
|
14
|
-
gem 'mysql2', '~> 0.
|
14
|
+
gem 'mysql2', '~> 0.3.11'
|
15
15
|
gem 'pg'
|
16
16
|
end
|
data/README.rdoc
CHANGED
@@ -11,22 +11,16 @@ auto-completer and a value auto-completer. It also comes with a set of helpers t
|
|
11
11
|
to create a clean web UI with sorting and an ajax auto-completer.
|
12
12
|
|
13
13
|
== Preview
|
14
|
+
|
14
15
|
A demo application using the scoped search can be found here: http://github.com/abenari/scoped_search_demo_app
|
15
16
|
A running version of the demo application can be found here: http://scope-search-demo.heroku.com
|
16
|
-
A Rails 3.2 demo with assets pipeline and twitter bootstrap
|
17
|
+
A Rails 3.2 demo with assets pipeline and twitter bootstrap: theme https://github.com/abenari/search-demo2
|
17
18
|
|
18
19
|
== Installing
|
19
|
-
For a Rails 3 application add the following line in your Gemfile, and run <tt>bundle install</tt>:
|
20
|
-
|
21
|
-
gem "scoped_search"
|
22
20
|
|
23
|
-
|
24
|
-
and run <tt>rake gems:install</tt> to install the gem.:
|
21
|
+
Add the following line in your Gemfile, and run <tt>bundle install</tt>:
|
25
22
|
|
26
|
-
|
27
|
-
...
|
28
|
-
config.gem 'scoped_search'
|
29
|
-
end
|
23
|
+
gem "scoped_search"
|
30
24
|
|
31
25
|
== Usage
|
32
26
|
|
@@ -59,7 +53,7 @@ actually chain the call with other scopes, or with will_paginate. An example:
|
|
59
53
|
|
60
54
|
=== Search profiles
|
61
55
|
|
62
|
-
If you include a :profile option to the
|
56
|
+
If you include a :profile option to the scoped_search call, the fields specified will only
|
63
57
|
be searched when you include this :profile into the search_for command as well:
|
64
58
|
|
65
59
|
class User < ActiveRecord::Base
|
@@ -70,7 +64,7 @@ be searched when you include this :profile into the search_for command as well:
|
|
70
64
|
This will only search the :public_information column:
|
71
65
|
|
72
66
|
User.search_for('blah blah blah')
|
73
|
-
|
67
|
+
|
74
68
|
And this will only search the :private_information column:
|
75
69
|
|
76
70
|
User.search_for('blah blah blah', :profile => :members)
|
@@ -116,17 +110,18 @@ For more info, see the the project wiki: http://github.com/wvanbergen/scoped_sea
|
|
116
110
|
|
117
111
|
== Additional resources
|
118
112
|
|
119
|
-
*
|
120
|
-
*
|
121
|
-
*
|
122
|
-
*
|
123
|
-
|
124
|
-
|
113
|
+
* Project wiki: https://github.com/wvanbergen/scoped_search/wiki
|
114
|
+
* Issue tracker: https://github.com/wvanbergen/scoped_search/issues
|
115
|
+
* RDoc documentations: http://www.rubydoc.info/gems/scoped_search
|
116
|
+
* Source code: https://github.com/wvanbergen/scoped_search
|
117
|
+
|
118
|
+
- See CHANGELOG.rdoc for the changes to this library over time.
|
119
|
+
- See CONTRIBUTING.rdoc if you want to report bugs, or help out on this project.
|
125
120
|
|
126
121
|
== License
|
127
122
|
|
128
123
|
This plugin is released under the MIT license (see LICENSE).
|
129
124
|
|
130
|
-
This plugin was originally developed for Floorplanner.com by Willem van Bergen
|
131
|
-
(https://github.com/wvanbergen) with help from Wes Hays (https://github.com/weshays).
|
125
|
+
This plugin was originally developed for Floorplanner.com by Willem van Bergen
|
126
|
+
(https://github.com/wvanbergen) with help from Wes Hays (https://github.com/weshays).
|
132
127
|
The current maintainer is Amos Benari (https://github.com/abenari).
|
data/lib/scoped_search.rb
CHANGED
@@ -18,6 +18,7 @@ module ScopedSearch
|
|
18
18
|
module ClassMethods
|
19
19
|
|
20
20
|
def self.extended(base)
|
21
|
+
super
|
21
22
|
base.class_attribute :scoped_search_definition
|
22
23
|
end
|
23
24
|
|
@@ -37,31 +38,6 @@ module ScopedSearch
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
# The <tt>BackwardsCompatibility</tt> module can be included into
|
41
|
-
# <tt>ActiveRecord::Base</tt> to provide the <tt>searchable_on</tt> search
|
42
|
-
# field definition syntax that is compatible with scoped_seach 1.x
|
43
|
-
#
|
44
|
-
# Currently, it is included into <tt>ActiveRecord::Base</tt> by default, but
|
45
|
-
# this may change in the future. So, please uodate to the newer syntax as
|
46
|
-
# soon as possible.
|
47
|
-
module BackwardsCompatibility
|
48
|
-
|
49
|
-
# Defines fields to search on using a syntax compatible with scoped_search 1.x
|
50
|
-
def searchable_on(*fields)
|
51
|
-
|
52
|
-
options = fields.last.kind_of?(Hash) ? fields.pop : {}
|
53
|
-
# TODO: handle options?
|
54
|
-
|
55
|
-
fields.each do |field|
|
56
|
-
if relation = self.reflections.keys.detect { |relation| field.to_s =~ Regexp.new("^#{relation}_(\\w+)$") }
|
57
|
-
scoped_search(:in => relation.to_sym, :on => $1.to_sym)
|
58
|
-
else
|
59
|
-
scoped_search(:on => field)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
41
|
# The default scoped_search exception class.
|
66
42
|
class Exception < StandardError
|
67
43
|
end
|
@@ -84,7 +60,7 @@ module ScopedSearch
|
|
84
60
|
end
|
85
61
|
|
86
62
|
# Load all lib files
|
87
|
-
require
|
63
|
+
require 'scoped_search/version'
|
88
64
|
require 'scoped_search/definition'
|
89
65
|
require 'scoped_search/query_language'
|
90
66
|
require 'scoped_search/query_builder'
|
@@ -92,7 +68,6 @@ require 'scoped_search/auto_complete_builder'
|
|
92
68
|
|
93
69
|
# Import the search_on method in the ActiveReocrd::Base class
|
94
70
|
ActiveRecord::Base.send(:extend, ScopedSearch::ClassMethods)
|
95
|
-
ActiveRecord::Base.send(:extend, ScopedSearch::BackwardsCompatibility)
|
96
71
|
|
97
72
|
# Rails & Compass integration
|
98
73
|
require 'scoped_search/railtie' if defined?(::Rails)
|