kyanite 0.7.8 → 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kyanite/string/cast.rb +1 -21
- data/lib/kyanite/string/chars.rb +20 -18
- data/test/string/test_chars.rb +11 -11
- data/version.rb +1 -1
- metadata +1 -1
data/lib/kyanite/string/cast.rb
CHANGED
@@ -114,27 +114,7 @@ class String
|
|
114
114
|
str
|
115
115
|
end
|
116
116
|
|
117
|
-
|
118
|
-
unless defined? MYSQL_REPLACES
|
119
|
-
MYSQL_REPLACES = [
|
120
|
-
[/ä/, 'a'],
|
121
|
-
[/ö/, 'o'],
|
122
|
-
[/ü/, 'u'],
|
123
|
-
[/Ä/, 'a'],
|
124
|
-
[/Ö/, 'o'],
|
125
|
-
[/Ü/, 'u'],
|
126
|
-
[/ss/, 'ß'],
|
127
|
-
[/SS/, 'ß']
|
128
|
-
]
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
# Converts a string so that you can recognize with utf8_general_ci compared strings
|
133
|
-
#
|
134
|
-
def mysqlize
|
135
|
-
self.tidy_bytes.mgsub(MYSQL_REPLACES).downcase.to_s
|
136
|
-
end
|
137
|
-
|
117
|
+
|
138
118
|
|
139
119
|
end
|
140
120
|
|
data/lib/kyanite/string/chars.rb
CHANGED
@@ -7,24 +7,14 @@ end
|
|
7
7
|
|
8
8
|
|
9
9
|
require 'kyanite/string/chars_const'
|
10
|
+
require 'kyanite/string/misc'
|
10
11
|
|
11
12
|
|
12
13
|
|
13
14
|
|
14
15
|
class String
|
15
16
|
|
16
|
-
|
17
|
-
MYSQL_REPLACES = [
|
18
|
-
[/ä/, 'a'],
|
19
|
-
[/ö/, 'o'],
|
20
|
-
[/ü/, 'u'],
|
21
|
-
[/Ä/, 'a'],
|
22
|
-
[/Ö/, 'o'],
|
23
|
-
[/Ü/, 'u'],
|
24
|
-
[/ss/, 'ß'],
|
25
|
-
[/SS/, 'ß']
|
26
|
-
]
|
27
|
-
end
|
17
|
+
|
28
18
|
|
29
19
|
# ---------------------------------------------------------------------------------------------------------------------------------
|
30
20
|
# @!group Clear / Format Text
|
@@ -102,13 +92,25 @@ class String
|
|
102
92
|
|
103
93
|
|
104
94
|
|
105
|
-
|
106
|
-
|
107
|
-
|
95
|
+
unless defined? MYSQL_REPLACES
|
96
|
+
MYSQL_REPLACES = [
|
97
|
+
[/ä/, 'a'],
|
98
|
+
[/ö/, 'o'],
|
99
|
+
[/ü/, 'u'],
|
100
|
+
[/Ä/, 'a'],
|
101
|
+
[/Ö/, 'o'],
|
102
|
+
[/Ü/, 'u'],
|
103
|
+
[/ss/, 'ß'],
|
104
|
+
[/SS/, 'ß']
|
105
|
+
]
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
# Converts a string so that you can recognize with utf8_general_ci compared strings
|
108
110
|
#
|
109
|
-
|
110
|
-
|
111
|
-
|
111
|
+
def mysqlize
|
112
|
+
self.mgsub(MYSQL_REPLACES).downcase.to_s
|
113
|
+
end
|
112
114
|
|
113
115
|
|
114
116
|
|
data/test/string/test_chars.rb
CHANGED
@@ -138,17 +138,17 @@ ENDOFSTRING
|
|
138
138
|
|
139
139
|
|
140
140
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
141
|
+
def test_mysqlize
|
142
|
+
test0 = 'aaoouuß'
|
143
|
+
test1 = 'aäoöuüss'
|
144
|
+
test2 = 'AÄOÖUÜSS'
|
145
|
+
test3 = 'AAOOUUß'
|
146
|
+
|
147
|
+
assert_equal test0, test0.mysqlize
|
148
|
+
assert_equal test0, test1.mysqlize
|
149
|
+
assert_equal test0, test2.mysqlize
|
150
|
+
assert_equal test0, test3.mysqlize
|
151
|
+
end
|
152
152
|
|
153
153
|
|
154
154
|
|
data/version.rb
CHANGED