mongoid_search 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaeb19566825291c03bd018b9013d0c06a8b01c4
4
- data.tar.gz: 2b930fec009de9031350c4b7fbc658c928224eed
3
+ metadata.gz: 832d506c4a4b192adabbc3858899481804da533e
4
+ data.tar.gz: ee2c35e2dc25e5de7cc7bb02c149260ff487ff04
5
5
  SHA512:
6
- metadata.gz: 3111148a9311c26712eb3bbbccf7ec3c8c8d1db7283ac3e8435244558a16d157cdc22e039715bef5192234dc1a1ca80308d2a3805f7a8479eb27d8de4f689b92
7
- data.tar.gz: 9ed30923429cba88f73916057671a598ecc0589ea67016817b74ffb68b4721ded77c58c07af285914dcad92998c70b69c5a5f64d81fc53670a15ef73c6e3e9f4
6
+ metadata.gz: 7f40a5e5437f1865b71bd929ff3c861c33f35197e5c561bfaff6d0ffd31671983c1c0c5699ccbe0f9fb9af7c3af253ff9b704f6b93c186be8c13168ea6dc03b4
7
+ data.tar.gz: 63e5ee87ed079f03373951efc4cc6eb6accf13cf48ab4e8f53b76bcd689fb04bb097fbe2a2e66db6eccd71438db0876b4abd1f8e61608d23ff37aabc92a3eb8c
data/README.md CHANGED
@@ -166,6 +166,12 @@ Alternatively, you can create an initializer to setup those options:
166
166
  # http://en.wikipedia.org/wiki/Typographic_ligature
167
167
  config.ligatures = { "œ"=>"oe", "æ"=>"ae" }
168
168
 
169
+ # Strip symbols regex to be replaced. These symbols will be replaced by space
170
+ config.strip_symbols = /[._:;'\"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/
171
+
172
+ # Strip accents regex to be replaced. These sybols will be removed after strip_symbols replacing
173
+ config.strip_accents = /[^\s\p{Alnum}]/
174
+
169
175
  # Minimum word size. Words smaller than it won't be indexed
170
176
  config.minimum_word_size = 2
171
177
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -60,6 +60,14 @@ module Mongoid::Search
60
60
  mattr_accessor :minimum_word_size
61
61
  @@minimum_word_size = 2
62
62
 
63
+ # Strip special symbols
64
+ mattr_accessor :strip_symbols
65
+ @@strip_symbols = /[._:;'\"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/
66
+
67
+ # Strip accents
68
+ mattr_accessor :strip_accents
69
+ @@strip_accents = /[^\s\p{Alnum}]/
70
+
63
71
  def self.setup
64
72
  yield self
65
73
  end
@@ -34,6 +34,8 @@ module Mongoid::Search::Util
34
34
  ignore_list = Mongoid::Search.ignore_list
35
35
  stem_keywords = Mongoid::Search.stem_keywords
36
36
  stem_proc = Mongoid::Search.stem_proc
37
+ strip_symbols = Mongoid::Search.strip_symbols
38
+ strip_accents = Mongoid::Search.strip_accents
37
39
 
38
40
  return [] if text.blank?
39
41
  text = text.to_s.
@@ -41,8 +43,8 @@ module Mongoid::Search::Util
41
43
  normalize(:kd).
42
44
  downcase.
43
45
  to_s.
44
- gsub(/[._:;'"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/, ' '). # strip punctuation
45
- gsub(/[^\s\p{Alnum}]/,''). # strip accents
46
+ gsub(strip_symbols, ' '). # strip symbols
47
+ gsub(strip_accents, ''). # strip accents
46
48
  gsub(/[#{ligatures.keys.join("")}]/) {|c| ligatures[c]}.
47
49
  split(' ').
48
50
  reject { |word| word.size < Mongoid::Search.minimum_word_size }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Zaffari