has_searcher 0.0.3 → 0.0.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.
- data/lib/app/models/search.rb +4 -4
- data/lib/has_searcher/version.rb +1 -1
- metadata +3 -3
data/lib/app/models/search.rb
CHANGED
@@ -23,7 +23,7 @@ class Search < ActiveRecord::Base
|
|
23
23
|
|
24
24
|
def search
|
25
25
|
klass.search do | search |
|
26
|
-
search.keywords
|
26
|
+
search.keywords keywords if search_columns.delete("keywords")
|
27
27
|
search_columns.each do | column |
|
28
28
|
if column_for_attribute(column).type == :text
|
29
29
|
search.keywords normalize(column), :fields => column
|
@@ -51,14 +51,14 @@ class Search < ActiveRecord::Base
|
|
51
51
|
elsif column_for_attribute(column).type == :integer
|
52
52
|
self[column].try(:zero?) ? nil : self[column]
|
53
53
|
elsif column_for_attribute(column).type == :text && column == "term"
|
54
|
-
|
54
|
+
normalize_term(self[column])
|
55
55
|
else
|
56
56
|
self[column]
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
61
|
-
text.gsub
|
60
|
+
def normalize_term(text)
|
61
|
+
text.gsub /([^[:alnum:]+])/, ' ' if text
|
62
62
|
end
|
63
63
|
|
64
64
|
def klass
|
data/lib/has_searcher/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Dmitry Lihachev
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-04-
|
17
|
+
date: 2011-04-20 00:00:00 +07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|