psq-dm-xapian 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +4 -1
- data/Rakefile +1 -1
- data/lib/dm-xapian.rb +3 -2
- data/lib/remove_accents.rb +36 -0
- metadata +2 -1
data/CHANGES.txt
CHANGED
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'merb-core/version'
|
|
6
6
|
require 'merb-core/tasks/merb_rake_helper'
|
7
7
|
|
8
8
|
NAME = "dm-xapian"
|
9
|
-
GEM_VERSION = "0.
|
9
|
+
GEM_VERSION = "0.5"
|
10
10
|
AUTHOR = "Joshaven Potter, Pascal Belloncle"
|
11
11
|
EMAIL = "yourtech@gmail.com, psq@nanorails.com"
|
12
12
|
HOMEPAGE = "http://github.com/psq/dm-xapian"
|
data/lib/dm-xapian.rb
CHANGED
@@ -19,6 +19,7 @@ rescue LoadError
|
|
19
19
|
STDERR.puts "acts_as_xapian: No Ruby bindings for Xapian installed"
|
20
20
|
$acts_as_xapian_bindings_available = false
|
21
21
|
end
|
22
|
+
require 'remove_accents'
|
22
23
|
|
23
24
|
module ActsAsXapian
|
24
25
|
######################################################################
|
@@ -362,7 +363,7 @@ module ActsAsXapian
|
|
362
363
|
self.initialize_db
|
363
364
|
|
364
365
|
# Case of a string, searching for a Google-like syntax query
|
365
|
-
self.query_string = query_string
|
366
|
+
self.query_string = query_string.remove_accents
|
366
367
|
|
367
368
|
# Construct query which only finds things from specified models
|
368
369
|
model_query = Xapian::Query.new(Xapian::Query::OP_OR, model_classes.map{|mc| "M" + mc.to_s})
|
@@ -621,7 +622,7 @@ module DataMapper
|
|
621
622
|
elsif type == :boolean
|
622
623
|
value ? true : false
|
623
624
|
else
|
624
|
-
value.to_s
|
625
|
+
value.to_s.remove_accents
|
625
626
|
end
|
626
627
|
end
|
627
628
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
# based on http://codesnippets.joyent.com/posts/show/451
|
4
|
+
# and http://snippets.dzone.com/posts/show/2384
|
5
|
+
# although should be using http://trac.wordpress.org/browser/trunk/wp-includes/formatting.php#L437
|
6
|
+
|
7
|
+
|
8
|
+
def remove_accents
|
9
|
+
str = String.new(self)
|
10
|
+
accents = {
|
11
|
+
['á','à','â','ä','ã'] => 'a',
|
12
|
+
['Ã','Ä','Â','À','Á'] => 'A',
|
13
|
+
['æ'] => 'oe',
|
14
|
+
['Æ'] => 'AE',
|
15
|
+
['é','è','ê','ë'] => 'e',
|
16
|
+
['Ë','É','È','Ê'] => 'E',
|
17
|
+
['í','ì','î','ï'] => 'i',
|
18
|
+
['Ï','Î','Ì','Í'] => 'I',
|
19
|
+
['ó','ò','ô','ö','õ'] => 'o',
|
20
|
+
['Õ','Ö','Ô','Ò','Ó'] => 'O',
|
21
|
+
['ú','ù','û','ü'] => 'u',
|
22
|
+
['Ú','Û','Ù','Ü'] => 'U',
|
23
|
+
['ç'] => 'c',
|
24
|
+
['Ç'] => 'C',
|
25
|
+
['ñ'] => 'n',
|
26
|
+
['Ñ'] => 'N',
|
27
|
+
['ß'] => 'ss'
|
28
|
+
}
|
29
|
+
accents.each do |ac,rep|
|
30
|
+
ac.each do |s|
|
31
|
+
str = str.gsub(s, rep)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
str
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psq-dm-xapian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshaven Potter, Pascal Belloncle
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- TODO
|
50
50
|
- lib/dm-xapian.rb
|
51
51
|
- lib/dm-xapian/merbtasks.rb
|
52
|
+
- lib/remove_accents.rb
|
52
53
|
- SETUP.txt
|
53
54
|
- CHANGES.txt
|
54
55
|
- bin/dm-xapian-updater
|