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 CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.3.0
@@ -5,7 +5,6 @@ if RUBY_VERSION =~ /^1\.8/
5
5
  end
6
6
 
7
7
  require 'mongo_mapper'
8
- require 'mongo/gridfs'
9
8
  require 'uuidtools'
10
9
  require 'active_support/inflector'
11
10
 
@@ -36,8 +36,9 @@ module MongoMapperExt
36
36
  end
37
37
  end
38
38
 
39
+ options[:filename] = grid_filename
39
40
  gridfs.delete(grid_filename)
40
- gridfs.put(io, grid_filename, options).inspect
41
+ gridfs.put(io, options)
41
42
  end
42
43
 
43
44
  def get
@@ -114,10 +114,18 @@ module MongoMapperExt
114
114
  stem = stemmer.stem(word)
115
115
  end
116
116
 
117
- if stem && stem != word
118
- words += [stem, word]
119
- else
120
- words << word
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
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongomapper_ext}
8
- s.version = "0.2.4"
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-04-27}
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 = [
@@ -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
- :body => "HeRe is tHe Body of the bLog pOsT",
9
- :tags => ["my", "list", "of", "tags"])
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
- - 2
8
- - 4
9
- version: 0.2.4
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-04-27 00:00:00 -05:00
17
+ date: 2010-05-08 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency