scoped_search 2.3.5 → 2.3.6
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.
data/lib/scoped_search.rb
CHANGED
@@ -14,7 +14,7 @@ module ScopedSearch
|
|
14
14
|
|
15
15
|
# The current scoped_search version. Do not change thisvalue by hand,
|
16
16
|
# because it will be updated automatically by the gem release script.
|
17
|
-
VERSION = "2.3.
|
17
|
+
VERSION = "2.3.6"
|
18
18
|
|
19
19
|
# The ClassMethods module will be included into the ActiveRecord::Base class
|
20
20
|
# to add the <tt>ActiveRecord::Base.scoped_search</tt> method and the
|
@@ -130,10 +130,11 @@ module ScopedSearch
|
|
130
130
|
return [] if (suggestions.blank?)
|
131
131
|
|
132
132
|
q=query
|
133
|
-
unless q =~ /(\s|\)|,)$/
|
133
|
+
unless q =~ /(\s|\)|,)$/ || last_token_is(COMPARISON_OPERATORS)
|
134
134
|
val = Regexp.escape(tokens.last.to_s).gsub('\*', '.*')
|
135
135
|
suggestions = suggestions.map {|s| s if s.to_s =~ /^"?#{val}"?/i}.compact
|
136
|
-
|
136
|
+
quoted = /("?#{Regexp.escape(tokens.last.to_s)}"?)$/.match(q)
|
137
|
+
q.chomp!(quoted[1]) if quoted
|
137
138
|
end
|
138
139
|
|
139
140
|
# for doted field names compact the suggestions list to be one suggestion
|
@@ -74,7 +74,7 @@ module ScopedSearch
|
|
74
74
|
else raise ScopedSearch::QueryNotSupported, "Cannot handle #{notification.inspect}: #{value.inspect}"
|
75
75
|
end
|
76
76
|
end
|
77
|
-
sql = (keyconditions + (sql.
|
77
|
+
sql = (keyconditions + (sql.blank? ? [] : [sql]) ).map {|c| "(#{c})"}.join(" AND ")
|
78
78
|
# Build hash for ActiveRecord::Base#find for the named scope
|
79
79
|
find_attributes = {}
|
80
80
|
find_attributes[:conditions] = [sql] + keyparameters + parameters unless sql.blank?
|
data/scoped_search.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
|
4
4
|
# Do not change the version and date fields by hand. This will be done
|
5
5
|
# automatically by the gem release script.
|
6
|
-
s.version = "2.3.
|
7
|
-
s.date = "2011-
|
6
|
+
s.version = "2.3.6"
|
7
|
+
s.date = "2011-11-13"
|
8
8
|
|
9
9
|
s.summary = "Easily search you ActiveRecord models with a simple query language using a named scope."
|
10
10
|
s.description = <<-EOS
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoped_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 2.3.
|
9
|
+
- 6
|
10
|
+
version: 2.3.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Willem van Bergen
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-11-13 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|