scoped_search 3.0.0 → 3.0.1
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/.travis.yml +1 -0
- data/README.rdoc +8 -8
- data/lib/scoped_search/definition.rb +2 -2
- data/lib/scoped_search/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43261f39db1d9b12979b0a8ac09d325b89c31335
|
4
|
+
data.tar.gz: 65f7f0cf411208478aee6aa9c7bb11d13036bd88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96ec7c114d8d6cde7413eb1a3247540f181694acbaba09044d6d97a65405a87f44f55101b6c868108e8502254762a8a689290038f63ba743c2f67948f5a288ff
|
7
|
+
data.tar.gz: 26dc0c35c2547547af5759ba31128dce71784f93f70cecdff67c1cf5c108c81504f827a382249f7e076050fc2ede54ea5330bf1b10cf2fe3993de378466f64f6
|
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Scoped search {<img src="https://secure.travis-ci.org/wvanbergen/scoped_search.png" />}[http://travis-ci.org/wvanbergen/scoped_search]
|
2
2
|
|
3
|
-
The <b>scoped_search</b>
|
3
|
+
The <b>scoped_search</b> gem makes it easy to search your ActiveRecord
|
4
4
|
models. Searching is performed using a query string, which should be passed to
|
5
5
|
the named_scope <tt>search_for</tt>. Based on a definition in what fields to
|
6
6
|
look, it will build query conditions and return those as a named scope.
|
@@ -27,7 +27,7 @@ Add the following line in your Gemfile, and run <tt>bundle install</tt>:
|
|
27
27
|
Scoped search requires you to define the fields you want to search in:
|
28
28
|
|
29
29
|
class User < ActiveRecord::Base
|
30
|
-
scoped_search :
|
30
|
+
scoped_search on: [:first_name, :last_name]
|
31
31
|
end
|
32
32
|
|
33
33
|
For more information about options and using fields from relations, see the
|
@@ -44,12 +44,12 @@ The result is returned as <tt>named_scope</tt>. Because of this, you can
|
|
44
44
|
actually chain the call with other scopes, or with will_paginate. An example:
|
45
45
|
|
46
46
|
class Project < ActiveRecord::Base
|
47
|
-
|
48
|
-
named_scope :public, :
|
47
|
+
scoped_search on: [:name, :description]
|
48
|
+
named_scope :public, conditions: { public: true }
|
49
49
|
end
|
50
50
|
|
51
51
|
# using chained named_scopes and will_paginate in your controller
|
52
|
-
Project.public.search_for(params[:q]).paginate(:
|
52
|
+
Project.public.search_for(params[:q]).paginate(page: params[:page], include: :tasks)
|
53
53
|
|
54
54
|
=== Search profiles
|
55
55
|
|
@@ -57,8 +57,8 @@ If you include a :profile option to the scoped_search call, the fields specified
|
|
57
57
|
be searched when you include this :profile into the search_for command as well:
|
58
58
|
|
59
59
|
class User < ActiveRecord::Base
|
60
|
-
scoped_search :
|
61
|
-
scoped_search :
|
60
|
+
scoped_search on: :public_information
|
61
|
+
scoped_search on: :private_information, profile: :members
|
62
62
|
end
|
63
63
|
|
64
64
|
This will only search the :public_information column:
|
@@ -67,7 +67,7 @@ This will only search the :public_information column:
|
|
67
67
|
|
68
68
|
And this will only search the :private_information column:
|
69
69
|
|
70
|
-
User.search_for('blah blah blah', :
|
70
|
+
User.search_for('blah blah blah', profile: :members)
|
71
71
|
|
72
72
|
=== More information
|
73
73
|
|
@@ -222,8 +222,8 @@ module ScopedSearch
|
|
222
222
|
def parse_temporal(value)
|
223
223
|
return Date.current if value =~ /\btoday\b/i
|
224
224
|
return 1.day.ago.to_date if value =~ /\byesterday\b/i
|
225
|
-
return (eval(
|
226
|
-
return (eval(
|
225
|
+
return (eval($1.strip.gsub(/\s+/,'.').downcase)).to_datetime if value =~ /\A\s*(\d+\s+\b(?:hours?|minutes?)\b\s+\bago)\b\s*\z/i
|
226
|
+
return (eval($1.strip.gsub(/\s+/,'.').downcase)).to_date if value =~ /\A\s*(\d+\s+\b(?:days?|weeks?|months?|years?)\b\s+\bago)\b\s*\z/i
|
227
227
|
DateTime.parse(value, true) rescue nil
|
228
228
|
end
|
229
229
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoped_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amos Benari
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|