smart_search 0.0.72 → 0.0.74
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_search.rb +15 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f17967a51b18de2c290d5c10527b5a4dc1b1d37
|
4
|
+
data.tar.gz: 0420daee9888c98c13e6c752eff2c6ada9c7a115
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36d59f74ea6dc434c595f3a8b84c993eefd49fb90545268218d2e57c40f694465e69061d6c23e6412c9d61256ef5772bc54bd9b751a8d393daf84b2656276b07
|
7
|
+
data.tar.gz: b6906ea972d8f38ae0a47a59de51f4da3ba7b08551716e1e08b95b2dc93dd72facbf6a9fe9b3d23402f3a452aedd0db0f4b890e8347eb955c4af3fbb45b8a7e2
|
data/lib/smart_search.rb
CHANGED
@@ -11,6 +11,9 @@ require "smart_search_tag"
|
|
11
11
|
|
12
12
|
module SmartSearch
|
13
13
|
|
14
|
+
REMOVE_CHARS = Regexp.new("[\|\'\~]")
|
15
|
+
|
16
|
+
|
14
17
|
def self.included(base)
|
15
18
|
base.extend ClassMethods
|
16
19
|
end
|
@@ -31,11 +34,11 @@ module SmartSearch
|
|
31
34
|
|
32
35
|
cattr_accessor :condition_default, :group_default, :tags, :order_default, :enable_similarity, :default_template_path
|
33
36
|
send :include, InstanceMethods
|
34
|
-
self.send(:after_save, :create_search_tags) unless options[:auto] == false
|
37
|
+
self.send(:after_save, :create_search_tags, :if => :update_search_tags?) unless options[:auto] == false
|
35
38
|
self.send(:before_destroy, :clear_search_tags)
|
36
39
|
self.enable_similarity ||= true
|
37
40
|
|
38
|
-
attr_accessor :query_score
|
41
|
+
attr_accessor :query_score, :dont_update_search_tags
|
39
42
|
|
40
43
|
# options zuweisen
|
41
44
|
if options[:conditions].is_a?(String) && !options[:conditions].blank?
|
@@ -72,7 +75,8 @@ module SmartSearch
|
|
72
75
|
self.connection.execute("INSERT INTO `#{::SmartSearchHistory.table_name}` (`query`) VALUES ('#{tags.gsub(/[^a-zA-ZäöüÖÄÜß\ ]/, '')}');")
|
73
76
|
end
|
74
77
|
|
75
|
-
tags = tags.
|
78
|
+
tags = tags.gsub(REMOVE_CHARS, " ")
|
79
|
+
tags = tags.split(/[\ -]/).select {|t| !t.blank? }
|
76
80
|
|
77
81
|
# Fallback for Empty String
|
78
82
|
tags << "#" if tags.empty?
|
@@ -166,6 +170,14 @@ module SmartSearch
|
|
166
170
|
self.class.result_template_path
|
167
171
|
end
|
168
172
|
|
173
|
+
def dont_update_search_tags!
|
174
|
+
self.dont_update_search_tags = true
|
175
|
+
end
|
176
|
+
|
177
|
+
def update_search_tags?
|
178
|
+
!self.dont_update_search_tags
|
179
|
+
end
|
180
|
+
|
169
181
|
# create search tags for this very record based on the attributes defined in ':on' option passed to the 'Class.smart_search' method
|
170
182
|
def create_search_tags
|
171
183
|
tags = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.74
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Eck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -120,3 +120,4 @@ test_files:
|
|
120
120
|
- test/unit/01_smart_search_test.rb
|
121
121
|
- test/unit/02_smart_search_similarity_test.rb
|
122
122
|
- test/unit/03_smart_search_boost_test.rb
|
123
|
+
has_rdoc:
|