mongoid-haystack 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +8 -0
- data/lib/mongoid-haystack.rb +1 -1
- data/lib/mongoid-haystack/util.rb +6 -1
- data/mongoid-haystack.gemspec +3 -2
- data/test/mongoid-haystack_test.rb +24 -0
- metadata +3 -2
data/HISTORY
ADDED
data/lib/mongoid-haystack.rb
CHANGED
@@ -60,8 +60,12 @@ module Mongoid
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def words_for(*args)
|
63
|
-
string = args.
|
63
|
+
string = args.join(' ')
|
64
|
+
string.gsub!(/_+/, '-')
|
65
|
+
string.gsub!(/[^\w]/, ' ')
|
66
|
+
|
64
67
|
words = []
|
68
|
+
|
65
69
|
UnicodeUtils.each_word(string) do |word|
|
66
70
|
word = UnicodeUtils.nfkd(word.strip)
|
67
71
|
word.gsub!(/\A(?:[^\w]|_|\s)+/, '') # leading punctuation/spaces
|
@@ -69,6 +73,7 @@ module Mongoid
|
|
69
73
|
next if word.empty?
|
70
74
|
words.push(word)
|
71
75
|
end
|
76
|
+
|
72
77
|
words
|
73
78
|
end
|
74
79
|
|
data/mongoid-haystack.gemspec
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
|
4
4
|
Gem::Specification::new do |spec|
|
5
5
|
spec.name = "mongoid-haystack"
|
6
|
-
spec.version = "1.2.
|
6
|
+
spec.version = "1.2.1"
|
7
7
|
spec.platform = Gem::Platform::RUBY
|
8
8
|
spec.summary = "mongoid-haystack"
|
9
9
|
spec.description = "a mongoid 3 zero-config, zero-integration, POLS pure mongo fulltext solution"
|
10
10
|
|
11
11
|
spec.files =
|
12
|
-
["
|
12
|
+
["HISTORY",
|
13
|
+
"README.md",
|
13
14
|
"Rakefile",
|
14
15
|
"lib",
|
15
16
|
"lib/app",
|
@@ -339,6 +339,30 @@ Testing Mongoid::Haystack do
|
|
339
339
|
assert{ models.is_a?(Array) }
|
340
340
|
end
|
341
341
|
|
342
|
+
##
|
343
|
+
#
|
344
|
+
test '.words_for' do
|
345
|
+
{
|
346
|
+
' cats and dogs ' => %w( cats and dogs ),
|
347
|
+
' cats-and-dogs ' => %w( cats and dogs ),
|
348
|
+
' cats_and_dogs ' => %w( cats and dogs ),
|
349
|
+
' cats!and?dogs ' => %w( cats and dogs ),
|
350
|
+
}.each do |src, dst|
|
351
|
+
assert{ Mongoid::Haystack::words_for(src) == dst }
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
test '.stems_for' do
|
356
|
+
{
|
357
|
+
' cats and dogs ' => %w( cat dog ),
|
358
|
+
' cats!and?dogs ' => %w( cat dog ),
|
359
|
+
' fishing and hunting ' => %w( fish hunt ),
|
360
|
+
' fishing-and-hunting ' => %w( fish hunt ),
|
361
|
+
}.each do |src, dst|
|
362
|
+
assert{ Mongoid::Haystack::stems_for(src) == dst }
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
342
366
|
protected
|
343
367
|
|
344
368
|
def new_klass(&block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-haystack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -129,6 +129,7 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- HISTORY
|
132
133
|
- README.md
|
133
134
|
- Rakefile
|
134
135
|
- lib/app/models/mongoid/haystack/index.rb
|