ananke 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ananke/serialize.rb +9 -3
- data/lib/ananke/utf8.rb +90 -0
- data/lib/version.rb +1 -1
- metadata +4 -3
data/lib/ananke/serialize.rb
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
require 'json'
|
|
2
|
+
require 'ananke/utf8'
|
|
2
3
|
module Serialize
|
|
3
4
|
|
|
4
5
|
def self.can_serialize?(obj)
|
|
5
6
|
obj.class != Array and obj.instance_variables.empty?#!obj.to_json.start_with?('"#<')
|
|
6
7
|
end
|
|
7
8
|
|
|
9
|
+
def self.unaccent(obj)
|
|
10
|
+
"IõÓnãÕißÍizëÕiøî"
|
|
11
|
+
obj.class == String ? obj.utf8_trans_unaccent : obj
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
def self.to_h(obj)
|
|
9
15
|
ret = {}
|
|
10
16
|
|
|
11
17
|
if obj.class == Hash
|
|
12
18
|
obj.each do |k, v|
|
|
13
|
-
ret[k.to_sym] = (can_serialize?(v) ? v : Serialize.to_h(v))
|
|
19
|
+
ret[k.to_sym] = (can_serialize?(v) ? unaccent(v) : Serialize.to_h(v))
|
|
14
20
|
end
|
|
15
21
|
elsif obj.class == Array
|
|
16
22
|
ret = []
|
|
@@ -19,11 +25,11 @@ module Serialize
|
|
|
19
25
|
ret << Serialize.to_h(i)
|
|
20
26
|
end
|
|
21
27
|
elsif obj.instance_variables.empty?
|
|
22
|
-
ret = obj
|
|
28
|
+
ret = unaccent(obj)
|
|
23
29
|
else
|
|
24
30
|
obj.instance_variables.each do |e|
|
|
25
31
|
value = obj.instance_variable_get e.to_sym
|
|
26
|
-
ret[e[1..-1]] = (can_serialize?(value) ? value : Serialize.to_h(value))
|
|
32
|
+
ret[e[1..-1]] = (can_serialize?(value) ? unaccent(value) : Serialize.to_h(value))
|
|
27
33
|
end
|
|
28
34
|
end
|
|
29
35
|
if ret.class == Hash and Ananke.settings[:remove_empty]
|
data/lib/ananke/utf8.rb
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
class String
|
|
2
|
+
# Translate accented utf8 characters over to non-accented
|
|
3
|
+
def utf8_trans_unaccent
|
|
4
|
+
tranmap = {
|
|
5
|
+
"\xC3\x80" => "A", "\xC3\x81" => "A", "\xC3\x82" => "A", "\xC3\x83" => "A",
|
|
6
|
+
"\xC3\x84" => "A", "\xC3\x85" => "A", "\xC3\x86" => "AE","\xC3\x87" => "C",
|
|
7
|
+
"\xC3\x88" => "E", "\xC3\x89" => "E", "\xC3\x8A" => "E", "\xC3\x8B" => "E",
|
|
8
|
+
"\xC3\x8C" => "I", "\xC3\x8D" => "I", "\xC3\x8E" => "I", "\xC3\x8F" => "I",
|
|
9
|
+
"\xC3\x90" => "D", "\xC3\x91" => "N", "\xC3\x92" => "O", "\xC3\x93" => "O",
|
|
10
|
+
"\xC3\x94" => "O", "\xC3\x95" => "O", "\xC3\x96" => "O", "\xC3\x98" => "O",
|
|
11
|
+
"\xC3\x99" => "U", "\xC3\x9A" => "U", "\xC3\x9B" => "U", "\xC3\x9C" => "U",
|
|
12
|
+
"\xC3\x9D" => "Y", "\xC3\x9E" => "P", "\xC3\x9F" => "ss",
|
|
13
|
+
"\xC3\xA0" => "a", "\xC3\xA1" => "a", "\xC3\xA2" => "a", "\xC3\xA3" => "a",
|
|
14
|
+
"\xC3\xA4" => "a", "\xC3\xA5" => "a", "\xC3\xA6" => "ae","\xC3\xA7" => "c",
|
|
15
|
+
"\xC3\xA8" => "e", "\xC3\xA9" => "e", "\xC3\xAA" => "e", "\xC3\xAB" => "e",
|
|
16
|
+
"\xC3\xAC" => "i", "\xC3\xAD" => "i", "\xC3\xAE" => "i", "\xC3\xAF" => "i",
|
|
17
|
+
"\xC3\xB0" => "o", "\xC3\xB1" => "n", "\xC3\xB2" => "o", "\xC3\xB3" => "o",
|
|
18
|
+
"\xC3\xB4" => "o", "\xC3\xB5" => "o", "\xC3\xB6" => "o", "\xC3\xB8" => "o",
|
|
19
|
+
"\xC3\xB9" => "u", "\xC3\xBA" => "u", "\xC3\xBB" => "u", "\xC3\xBC" => "u",
|
|
20
|
+
"\xC3\xBD" => "y", "\xC3\xBE" => "p", "\xC3\xBF" => "y",
|
|
21
|
+
"\xC4\x80" => "A", "\xC4\x81" => "a", "\xC4\x82" => "A", "\xC4\x83" => "a",
|
|
22
|
+
"\xC4\x84" => "A", "\xC4\x85" => "a", "\xC4\x86" => "C", "\xC4\x87" => "c",
|
|
23
|
+
"\xC4\x88" => "C", "\xC4\x89" => "c", "\xC4\x8A" => "C", "\xC4\x8B" => "c",
|
|
24
|
+
"\xC4\x8C" => "C", "\xC4\x8D" => "c", "\xC4\x8E" => "D", "\xC4\x8F" => "d",
|
|
25
|
+
"\xC4\x90" => "D", "\xC4\x91" => "d", "\xC4\x92" => "E", "\xC4\x93" => "e",
|
|
26
|
+
"\xC4\x94" => "E", "\xC4\x95" => "e", "\xC4\x96" => "E", "\xC4\x97" => "e",
|
|
27
|
+
"\xC4\x98" => "E", "\xC4\x99" => "e", "\xC4\x9A" => "E", "\xC4\x9B" => "e",
|
|
28
|
+
"\xC4\x9C" => "G", "\xC4\x9D" => "g", "\xC4\x9E" => "G", "\xC4\x9F" => "g",
|
|
29
|
+
"\xC4\xA0" => "G", "\xC4\xA1" => "g", "\xC4\xA2" => "G", "\xC4\xA3" => "g",
|
|
30
|
+
"\xC4\xA4" => "H", "\xC4\xA5" => "h", "\xC4\xA6" => "H", "\xC4\xA7" => "h",
|
|
31
|
+
"\xC4\xA8" => "I", "\xC4\xA9" => "i", "\xC4\xAA" => "I", "\xC4\xAB" => "i",
|
|
32
|
+
"\xC4\xAC" => "I", "\xC4\xAD" => "i", "\xC4\xAE" => "I", "\xC4\xAF" => "i",
|
|
33
|
+
"\xC4\xB0" => "I", "\xC4\xB1" => "i", "\xC4\xB2" => "IJ","\xC4\xB3" => "ij",
|
|
34
|
+
"\xC4\xB4" => "J", "\xC4\xB5" => "j", "\xC4\xB6" => "K", "\xC4\xB7" => "k",
|
|
35
|
+
"\xC4\xB8" => "k", "\xC4\xB9" => "L", "\xC4\xBA" => "l", "\xC4\xBB" => "L",
|
|
36
|
+
"\xC4\xBC" => "l", "\xC4\xBD" => "L", "\xC4\xBE" => "l", "\xC4\xBF" => "L",
|
|
37
|
+
"\xC5\x80" => "l", "\xC5\x81" => "L", "\xC5\x82" => "l", "\xC5\x83" => "N",
|
|
38
|
+
"\xC5\x84" => "n", "\xC5\x85" => "N", "\xC5\x86" => "n", "\xC5\x87" => "N",
|
|
39
|
+
"\xC5\x88" => "n", "\xC5\x89" => "n", "\xC5\x8A" => "N", "\xC5\x8B" => "n",
|
|
40
|
+
"\xC5\x8C" => "O", "\xC5\x8D" => "o", "\xC5\x8E" => "O", "\xC5\x8F" => "o",
|
|
41
|
+
"\xC5\x90" => "O", "\xC5\x91" => "o", "\xC5\x92" => "CE","\xC5\x93" => "ce",
|
|
42
|
+
"\xC5\x94" => "R", "\xC5\x95" => "r", "\xC5\x96" => "R", "\xC5\x97" => "r",
|
|
43
|
+
"\xC5\x98" => "R", "\xC5\x99" => "r", "\xC5\x9A" => "S", "\xC5\x9B" => "s",
|
|
44
|
+
"\xC5\x9C" => "S", "\xC5\x9D" => "s", "\xC5\x9E" => "S", "\xC5\x9F" => "s",
|
|
45
|
+
"\xC5\xA0" => "S", "\xC5\xA1" => "s", "\xC5\xA2" => "T", "\xC5\xA3" => "t",
|
|
46
|
+
"\xC5\xA4" => "T", "\xC5\xA5" => "t", "\xC5\xA6" => "T", "\xC5\xA7" => "t",
|
|
47
|
+
"\xC5\xA8" => "U", "\xC5\xA9" => "u", "\xC5\xAA" => "U", "\xC5\xAB" => "u",
|
|
48
|
+
"\xC5\xAC" => "U", "\xC5\xAD" => "u", "\xC5\xAE" => "U", "\xC5\xAF" => "u",
|
|
49
|
+
"\xC5\xB0" => "U", "\xC5\xB1" => "u", "\xC5\xB2" => "U", "\xC5\xB3" => "u",
|
|
50
|
+
"\xC5\xB4" => "W", "\xC5\xB5" => "w", "\xC5\xB6" => "Y", "\xC5\xB7" => "y",
|
|
51
|
+
"\xC5\xB8" => "Y", "\xC5\xB9" => "Z", "\xC5\xBA" => "z", "\xC5\xBB" => "Z",
|
|
52
|
+
"\xC5\xBC" => "z", "\xC5\xBD" => "Z", "\xC5\xBE" => "z", "\xC6\x8F" => "E",
|
|
53
|
+
"\xC6\xA0" => "O", "\xC6\xA1" => "o", "\xC6\xAF" => "U", "\xC6\xB0" => "u",
|
|
54
|
+
"\xC7\x8D" => "A", "\xC7\x8E" => "a", "\xC7\x8F" => "I",
|
|
55
|
+
"\xC7\x90" => "i", "\xC7\x91" => "O", "\xC7\x92" => "o", "\xC7\x93" => "U",
|
|
56
|
+
"\xC7\x94" => "u", "\xC7\x95" => "U", "\xC7\x96" => "u", "\xC7\x97" => "U",
|
|
57
|
+
"\xC7\x98" => "u", "\xC7\x99" => "U", "\xC7\x9A" => "u", "\xC7\x9B" => "U",
|
|
58
|
+
"\xC7\x9C" => "u",
|
|
59
|
+
"\xC7\xBA" => "A", "\xC7\xBB" => "a", "\xC7\xBC" => "AE","\xC7\xBD" => "ae",
|
|
60
|
+
"\xC7\xBE" => "O", "\xC7\xBF" => "o",
|
|
61
|
+
"\xC9\x99" => "e",
|
|
62
|
+
|
|
63
|
+
"\xC2\x82" => ",", # High code comma
|
|
64
|
+
"\xC2\x84" => ",,", # High code double comma
|
|
65
|
+
"\xC2\x85" => "...", # Tripple dot
|
|
66
|
+
"\xC2\x88" => "^", # High carat
|
|
67
|
+
"\xC2\x91" => "\x27", # Forward single quote
|
|
68
|
+
"\xC2\x92" => "\x27", # Reverse single quote
|
|
69
|
+
"\xC2\x93" => "\x22", # Forward double quote
|
|
70
|
+
"\xC2\x94" => "\x22", # Reverse double quote
|
|
71
|
+
"\xC2\x96" => "-", # High hyphen
|
|
72
|
+
"\xC2\x97" => "--", # Double hyphen
|
|
73
|
+
"\xC2\xA6" => "|", # Split vertical bar
|
|
74
|
+
"\xC2\xAB" => "<<", # Double less than
|
|
75
|
+
"\xC2\xBB" => ">>", # Double greater than
|
|
76
|
+
"\xC2\xBC" => "1/4", # one quarter
|
|
77
|
+
"\xC2\xBD" => "1/2", # one half
|
|
78
|
+
"\xC2\xBE" => "3/4", # three quarters
|
|
79
|
+
|
|
80
|
+
"\xCA\xBF" => "\x27", # c-single quote
|
|
81
|
+
"\xCC\xA8" => "", # modifier - under curve
|
|
82
|
+
"\xCC\xB1" => "" # modifier - under line
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
tranmap.inject(self) do |str, (utf8, asc)|
|
|
86
|
+
#p [utf8, asc]
|
|
87
|
+
str.gsub(utf8, asc)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: ananke
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 1.1.
|
|
5
|
+
version: 1.1.1
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Andries Coetzee
|
|
@@ -101,6 +101,7 @@ extra_rdoc_files:
|
|
|
101
101
|
files:
|
|
102
102
|
- lib/ananke.rb
|
|
103
103
|
- lib/version.rb
|
|
104
|
+
- lib/ananke/utf8.rb
|
|
104
105
|
- lib/ananke/settings.rb
|
|
105
106
|
- lib/ananke/linking.rb
|
|
106
107
|
- lib/ananke/routing.rb
|
|
@@ -131,7 +132,7 @@ licenses: []
|
|
|
131
132
|
post_install_message: |
|
|
132
133
|
**************************************************
|
|
133
134
|
|
|
134
|
-
Thank you for installing ananke-1.1.
|
|
135
|
+
Thank you for installing ananke-1.1.1
|
|
135
136
|
|
|
136
137
|
Please be sure to look at README.rdoc to see what might have changed
|
|
137
138
|
since the last release and how to use this GEM.
|
|
@@ -160,7 +161,7 @@ rubyforge_project:
|
|
|
160
161
|
rubygems_version: 1.5.0
|
|
161
162
|
signing_key:
|
|
162
163
|
specification_version: 3
|
|
163
|
-
summary: ananke-1.1.
|
|
164
|
+
summary: ananke-1.1.1
|
|
164
165
|
test_files:
|
|
165
166
|
- spec/dumping.rb
|
|
166
167
|
- spec/cov_adapter.rb
|