mongomapper_ext 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mongomapper_ext.rb +0 -1
- data/lib/mongomapper_ext/file.rb +2 -1
- data/lib/mongomapper_ext/filter.rb +12 -4
- data/mongomapper_ext.gemspec +2 -2
- data/test/test_filter.rb +11 -3
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/mongomapper_ext.rb
CHANGED
data/lib/mongomapper_ext/file.rb
CHANGED
@@ -114,10 +114,18 @@ module MongoMapperExt
|
|
114
114
|
stem = stemmer.stem(word)
|
115
115
|
end
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
words <<
|
117
|
+
normalized=word.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n, '').to_s
|
118
|
+
|
119
|
+
if word != normalized
|
120
|
+
words << normalized
|
121
|
+
end
|
122
|
+
|
123
|
+
words << word
|
124
|
+
if stem
|
125
|
+
normalized=stem.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n, '').to_s
|
126
|
+
|
127
|
+
words << normalized if stem != normalized
|
128
|
+
words << stem if stem != word
|
121
129
|
end
|
122
130
|
end
|
123
131
|
end
|
data/mongomapper_ext.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongomapper_ext}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David A. Cuadrado"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-08}
|
13
13
|
s.description = %q{MongoMapper extensions}
|
14
14
|
s.email = %q{krawek@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_filter.rb
CHANGED
@@ -4,9 +4,12 @@ class TestFilter < Test::Unit::TestCase
|
|
4
4
|
context "filtering data" do
|
5
5
|
setup do
|
6
6
|
BlogPost.delete_all
|
7
|
-
@blogpost = BlogPost.create(:title => "%How dOEs tHIs Work?!",
|
8
|
-
|
9
|
-
|
7
|
+
@blogpost = BlogPost.create!(:title => "%How dOEs tHIs Work?!",
|
8
|
+
:body => "HeRe is tHe Body of the bLog pOsT",
|
9
|
+
:tags => ["my", "list", "of", "tags"])
|
10
|
+
@entradablog = BlogPost.create!(:title => "sobre las piña",
|
11
|
+
:body => "la piña no es un árbol",
|
12
|
+
:tags => ["frutas"])
|
10
13
|
end
|
11
14
|
|
12
15
|
should "be case insensitive" do
|
@@ -33,6 +36,11 @@ class TestFilter < Test::Unit::TestCase
|
|
33
36
|
BlogPost.filter("work lalala").should == [@blogpost]
|
34
37
|
end
|
35
38
|
|
39
|
+
should "normalize the text" do
|
40
|
+
BlogPost.filter("pina").should == [@entradablog]
|
41
|
+
BlogPost.filter("arbol").should == [@entradablog]
|
42
|
+
end
|
43
|
+
|
36
44
|
should "allow to paginate results" do
|
37
45
|
results = BlogPost.filter("tag", :per_page => 1, :page => 1)
|
38
46
|
results.should == [@blogpost]
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David A. Cuadrado
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-08 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|