textutils 0.9.1 → 0.9.2
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.
- checksums.yaml +7 -0
- data/Manifest.txt +4 -0
- data/lib/textutils/filter/code_filter.rb +1 -0
- data/lib/textutils/filter/comment_filter.rb +1 -0
- data/lib/textutils/filter/erb_django_filter.rb +1 -0
- data/lib/textutils/filter/erb_filter.rb +1 -0
- data/lib/textutils/filter/string_filter.rb +170 -0
- data/lib/textutils/helper/title_helper.rb +7 -116
- data/lib/textutils/parser/name_parser.rb +12 -0
- data/lib/textutils/utils.rb +2 -0
- data/lib/textutils/version.rb +2 -1
- data/lib/textutils.rb +3 -0
- data/test/test_asciify.rb +43 -0
- data/test/test_slugify.rb +40 -0
- data/test/test_title_helper.rb +0 -6
- metadata +50 -29
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 56b6dcc77d437cdddb1df9336366d74465c9b0e3
|
4
|
+
data.tar.gz: 642a609e8e6c5df8c11e12b9c2c468cb8dd6fa53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d7811b15d502395861cab8ce2ca15d4419d9744c3e58fee44a431804026e489776fdc84b60a33e95ab963abaf778fd6ffd21c54fcd37072498c6ed7caeda144
|
7
|
+
data.tar.gz: 5dd72d6fb3f4977cf9f8d8eb8982b21f5cf4165fcbaed28ff2a8fc396a46c6d9fc37d9df95bb4af5f5b359a70fb10896dcdf3d43ceb36afe57ffea93b338633b
|
data/Manifest.txt
CHANGED
@@ -10,6 +10,7 @@ lib/textutils/filter/code_filter.rb
|
|
10
10
|
lib/textutils/filter/comment_filter.rb
|
11
11
|
lib/textutils/filter/erb_django_filter.rb
|
12
12
|
lib/textutils/filter/erb_filter.rb
|
13
|
+
lib/textutils/filter/string_filter.rb
|
13
14
|
lib/textutils/helper/address_helper.rb
|
14
15
|
lib/textutils/helper/date_helper.rb
|
15
16
|
lib/textutils/helper/hypertext_helper.rb
|
@@ -19,6 +20,7 @@ lib/textutils/helper/unicode_helper.rb
|
|
19
20
|
lib/textutils/helper/value_helper.rb
|
20
21
|
lib/textutils/helper/xml_helper.rb
|
21
22
|
lib/textutils/page.rb
|
23
|
+
lib/textutils/parser/name_parser.rb
|
22
24
|
lib/textutils/patterns.rb
|
23
25
|
lib/textutils/reader/code_reader.rb
|
24
26
|
lib/textutils/reader/fixture_reader.rb
|
@@ -34,7 +36,9 @@ lib/textutils/utils.rb
|
|
34
36
|
lib/textutils/version.rb
|
35
37
|
test/helper.rb
|
36
38
|
test/test_address_helper.rb
|
39
|
+
test/test_asciify.rb
|
37
40
|
test/test_hypertext_helper.rb
|
41
|
+
test/test_slugify.rb
|
38
42
|
test/test_taglist.rb
|
39
43
|
test/test_title_finder.rb
|
40
44
|
test/test_title_helper.rb
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
module TextUtils
|
5
|
+
module StringFilter
|
6
|
+
|
7
|
+
## turn accented char into ascii look alike if possible
|
8
|
+
##
|
9
|
+
## todo: add some more
|
10
|
+
## see http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references for more
|
11
|
+
|
12
|
+
## see http://en.wikipedia.org/wiki/Latin_characters_in_Unicode !!! -- add more chars for conversion
|
13
|
+
## http://en.wikipedia.org/wiki/List_of_Latin_letters
|
14
|
+
|
15
|
+
## todo: add unicode codepoint name ???
|
16
|
+
|
17
|
+
ASCIIFY_MAPPINGS = [
|
18
|
+
['ß', 'ss'], # -- Latin small letter sharp s (ess-zed); see German Eszett // ß
|
19
|
+
|
20
|
+
['æ', 'ae'], # -- Latin small letter ae (Latin small ligature ae) // æ
|
21
|
+
['ä', 'ae'], # -- Latin small letter a with diaeresis // ä
|
22
|
+
['ā', 'a' ], # e.g. Liepājas, Kāṭhmāḍaũ
|
23
|
+
['á', 'a' ], # e.g. Bogotá, Králové
|
24
|
+
['à', 'a' ], # e.g. Thành Phố Hồ Chí Minh [Saigon]
|
25
|
+
['ã', 'a' ], # e.g São Paulo
|
26
|
+
['ă', 'a' ], # e.g. Chișinău
|
27
|
+
['â', 'a' ], # e.g Goiânia
|
28
|
+
['å', 'a' ], # e.g. Vålerenga
|
29
|
+
['ą', 'a' ], # e.g. Śląsk
|
30
|
+
|
31
|
+
['ç', 'c' ], # e.g. São Gonçalo, Iguaçu, Neftçi
|
32
|
+
['ć', 'c' ], # e.g. Budućnost
|
33
|
+
['č', 'c' ], # e.g. Tradiční, Výčepní
|
34
|
+
|
35
|
+
['ḍ', 'd' ], # e.g. Kāṭhmāḍaũ [Kathmandu]
|
36
|
+
|
37
|
+
['é', 'e' ], # e.g. Vélez, Králové
|
38
|
+
['è', 'e' ], # e.g. Rivières
|
39
|
+
['ê', 'e' ], # e.g. Grêmio
|
40
|
+
['ě', 'e' ], # e.g. Budějovice
|
41
|
+
['ĕ', 'e' ], # e.g. Svĕtlý
|
42
|
+
['ė', 'e' ], # e.g. Vėtra
|
43
|
+
['ë', 'e' ], # e.g. Skënderbeu
|
44
|
+
|
45
|
+
['ğ', 'g' ], # e.g. Qarabağ
|
46
|
+
|
47
|
+
['ḥ', 'h' ], # e.g. Ad-Dawḥah [Doha]
|
48
|
+
|
49
|
+
['ì', 'i' ], # e.g. Potosì
|
50
|
+
['í', 'i' ], # e.g. Ústí
|
51
|
+
['ï', 'i' ], # e.g. El Djazaïr
|
52
|
+
['ī', 'i' ], # e.g. Al-Iskandarīyah [Alexandria]
|
53
|
+
|
54
|
+
['ł', 'l' ], # e.g. Wisła, Wrocław
|
55
|
+
['ñ', 'n' ], # e.g. Porteño
|
56
|
+
['ň', 'n' ], # e.g. Plzeň, Třeboň
|
57
|
+
|
58
|
+
['ö', 'oe'],
|
59
|
+
['ő', 'o' ], # e.g. Győri
|
60
|
+
['ó', 'o' ], # e.g. Colón, Łódź, Kraków
|
61
|
+
['õ', 'o' ], # e.g. Nõmme
|
62
|
+
['ô', 'o' ], # e.g. Amazônia (pt)
|
63
|
+
['ō', 'o' ], # e.g. Tōkyō, Pishōr
|
64
|
+
['ŏ', 'o' ], # e.g. P'yŏngyang [Pyongyang]
|
65
|
+
['ø', 'o' ], # e.g. Fuglafjørdur, København
|
66
|
+
['ố', 'o' ], # e.g. Thành Phố Hồ Chí Minh [Saigon]
|
67
|
+
['ồ', 'o' ], # e.g. Thành Phố Hồ Chí Minh [Saigon]
|
68
|
+
['ộ', 'o' ], # e.g. Hà Nội [Hanoi]
|
69
|
+
|
70
|
+
['ř', 'r' ], # e.g. Třeboň
|
71
|
+
|
72
|
+
['ș', 's' ], # e.g. Chișinău, București
|
73
|
+
['ş', 's' ], # e.g. Beşiktaş
|
74
|
+
['š', 's' ], # e.g. Košice
|
75
|
+
['ṣ', 's' ], # e.g. Al-Mawṣil [Mosul]
|
76
|
+
|
77
|
+
['ť', 't' ], # e.g. Měšťan
|
78
|
+
['ṭ', 't' ], # e.g. Al-Kharṭūm [Khartoum], Kāṭhmāḍaũ
|
79
|
+
|
80
|
+
['ü', 'ue'],
|
81
|
+
['ú', 'u' ], # e.g. Fútbol
|
82
|
+
['ù', 'u' ], # e.g. Xyauyù (it)
|
83
|
+
['ū', 'u' ], # e.g. Sūduva
|
84
|
+
['ů', 'u' ], # e.g. Sládkův
|
85
|
+
['ũ', 'u' ], # e.g. Kāṭhmāḍaũ [Kathmandu]
|
86
|
+
|
87
|
+
['ı', 'u' ], # e.g. Bakı # use u?? (Baku) why-why not?
|
88
|
+
|
89
|
+
['x̌', 'x'], # e.g. Pex̌awar [Peshawar]
|
90
|
+
|
91
|
+
['ý', 'y' ], # e.g. Nefitrovaný
|
92
|
+
['ź', 'z' ], # e.g. Łódź
|
93
|
+
['ž', 'z' ], # e.g. Domžale, Petržalka
|
94
|
+
['ż', 'z' ], # e.g. Lomża (polish)
|
95
|
+
|
96
|
+
['Æ', 'Ae' ], # -- Latin capital letter AE
|
97
|
+
['Á', 'A' ], # e.g. Águila (es)
|
98
|
+
['Å', 'A' ], # e.g. Åland Islands -- Latin capital letter A with ring above // Å
|
99
|
+
|
100
|
+
['Ç', 'C' ], # -- Latin capital letter C with cedilla -- Ç
|
101
|
+
['Č', 'C' ], # e.g. České
|
102
|
+
|
103
|
+
['Ḥ', 'H' ], # e.g. Ḥalab [Aleppo]
|
104
|
+
['Ḫ', 'H' ], # e.g. Ḫamīs Mušayṭ
|
105
|
+
['İ', 'I' ], # e.g. İnter
|
106
|
+
['Í', 'I' ], # e.g. ÍBV
|
107
|
+
['Ł', 'L' ], # e.g. Łódź
|
108
|
+
|
109
|
+
['Ö', 'Oe' ], # e.g. Örebro -- Latin capital letter O with diaeresis // Ö
|
110
|
+
['Ō', 'O' ], # e.g. Ōsaka [Osaka] --
|
111
|
+
['Ø', 'O' ], # e.g. Nogne Ø Imperial Stout (no) -- Latin capital letter O with stroke (Latin capital letter O slash) // Ø
|
112
|
+
|
113
|
+
['Ř', 'R' ], # e.g. Řezák
|
114
|
+
|
115
|
+
['Ś', 'S' ], # e.g. Śląsk
|
116
|
+
['Š', 'S' ], # e.g. MŠK -- Latin capital letter S with caron // Š
|
117
|
+
['Ş', 'S' ], # e.g. Şüvälan
|
118
|
+
['Ṣ', 'S' ], # e.g. Ṣan'ā' [Sana'a]
|
119
|
+
|
120
|
+
['Ṭ', 'T' ], # e.g. Ṭarābulus [Tripoli]
|
121
|
+
['Ú', 'U' ], # e.g. Ústí, Újpest
|
122
|
+
['Ž', 'Z' ], # e.g. Žilina
|
123
|
+
['Ż', 'Z' ] # e.g. Żywiec (polish) -- Latin captial letter Z with caron
|
124
|
+
]
|
125
|
+
|
126
|
+
|
127
|
+
def asciify( content, options={} )
|
128
|
+
### fix: use content.each_char and hash_map or similar instead of gsub
|
129
|
+
|
130
|
+
ASCIIFY_MAPPINGS.each do |mapping|
|
131
|
+
content = content.gsub( mapping[0], mapping[1] )
|
132
|
+
end
|
133
|
+
content
|
134
|
+
end
|
135
|
+
|
136
|
+
def slugify( content, options={} )
|
137
|
+
|
138
|
+
## NOTE: for now we do NOT strip non-word characters!!!!
|
139
|
+
## if it is an accented char, add it to asciify first!!!
|
140
|
+
|
141
|
+
## converts to lowercase,
|
142
|
+
## removes non-word characters (alphanumerics and underscores)
|
143
|
+
## and converts spaces to hyphens.
|
144
|
+
## Also strips leading and trailing whitespace.
|
145
|
+
|
146
|
+
# 1) asciify and downcase
|
147
|
+
content = asciify( content ).downcase
|
148
|
+
|
149
|
+
# 2) replace special chars w/space e.g $&%?!§#=*+._/()[]{}
|
150
|
+
## -- check in [] do we need to espcae / () [] {}
|
151
|
+
content = content.gsub( /[$&%?!§#=*+._\/\(\)\[\]\{\}]/, ' ' ) ## -- replace w/ dash (-)
|
152
|
+
content = content.gsub( /["']/, '' ) ## -- remove (use replace too? why? why not? add others???
|
153
|
+
|
154
|
+
# 3) strip leading and trailing spaces; squeeze spaces (e.g. more than one into one space)
|
155
|
+
content = content.strip
|
156
|
+
content = content.gsub( / {2,}/, ' ' )
|
157
|
+
|
158
|
+
# 4) replace remaining (inner) spaces ( ) with dash (-)
|
159
|
+
content = content.gsub( ' ', '-' )
|
160
|
+
content
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
end # module StringFilter
|
165
|
+
|
166
|
+
module Filter
|
167
|
+
include StringFilter
|
168
|
+
end # module Filter
|
169
|
+
|
170
|
+
end # module TextUtils
|
@@ -1,6 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
|
4
|
+
###
|
5
|
+
#
|
6
|
+
# fix: move to filter!!!!
|
7
|
+
# follows fn( content ) pattern!!!
|
8
|
+
|
9
|
+
|
4
10
|
module TextUtils
|
5
11
|
module TitleHelper
|
6
12
|
|
@@ -75,122 +81,7 @@ module TextUtils
|
|
75
81
|
|
76
82
|
key = strip_special_chars( key )
|
77
83
|
|
78
|
-
|
79
|
-
##
|
80
|
-
## todo: add some more
|
81
|
-
## see http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references for more
|
82
|
-
|
83
|
-
## todo: add unicode codepoint name
|
84
|
-
|
85
|
-
|
86
|
-
alternatives = [
|
87
|
-
['ß', 'ss'],
|
88
|
-
|
89
|
-
['æ', 'ae'],
|
90
|
-
['ä', 'ae'],
|
91
|
-
['ā', 'a' ], # e.g. Liepājas, Kāṭhmāḍaũ
|
92
|
-
['á', 'a' ], # e.g. Bogotá, Králové
|
93
|
-
['à', 'a' ], # e.g. Thành Phố Hồ Chí Minh [Saigon]
|
94
|
-
['ã', 'a' ], # e.g São Paulo
|
95
|
-
['ă', 'a' ], # e.g. Chișinău
|
96
|
-
['â', 'a' ], # e.g Goiânia
|
97
|
-
['å', 'a' ], # e.g. Vålerenga
|
98
|
-
['ą', 'a' ], # e.g. Śląsk
|
99
|
-
|
100
|
-
['ç', 'c' ], # e.g. São Gonçalo, Iguaçu, Neftçi
|
101
|
-
['ć', 'c' ], # e.g. Budućnost
|
102
|
-
['č', 'c' ], # e.g. Tradiční, Výčepní
|
103
|
-
|
104
|
-
['ḍ', 'd' ], # e.g. Kāṭhmāḍaũ [Kathmandu]
|
105
|
-
|
106
|
-
['é', 'e' ], # e.g. Vélez, Králové
|
107
|
-
['è', 'e' ], # e.g. Rivières
|
108
|
-
['ê', 'e' ], # e.g. Grêmio
|
109
|
-
['ě', 'e' ], # e.g. Budějovice
|
110
|
-
['ĕ', 'e' ], # e.g. Svĕtlý
|
111
|
-
['ė', 'e' ], # e.g. Vėtra
|
112
|
-
['ë', 'e' ], # e.g. Skënderbeu
|
113
|
-
|
114
|
-
['ğ', 'g' ], # e.g. Qarabağ
|
115
|
-
|
116
|
-
['ḥ', 'h' ], # e.g. Ad-Dawḥah [Doha]
|
117
|
-
|
118
|
-
['ì', 'i' ], # e.g. Potosì
|
119
|
-
['í', 'i' ], # e.g. Ústí
|
120
|
-
['ï', 'i' ], # e.g. El Djazaïr
|
121
|
-
['ī', 'i' ], # e.g. Al-Iskandarīyah [Alexandria]
|
122
|
-
|
123
|
-
['ł', 'l' ], # e.g. Wisła, Wrocław
|
124
|
-
['ñ', 'n' ], # e.g. Porteño
|
125
|
-
['ň', 'n' ], # e.g. Plzeň, Třeboň
|
126
|
-
|
127
|
-
['ö', 'oe'],
|
128
|
-
['ő', 'o' ], # e.g. Győri
|
129
|
-
['ó', 'o' ], # e.g. Colón, Łódź, Kraków
|
130
|
-
['õ', 'o' ], # e.g. Nõmme
|
131
|
-
['ô', 'o' ], # e.g. Amazônia (pt)
|
132
|
-
['ō', 'o' ], # e.g. Tōkyō, Pishōr
|
133
|
-
['ŏ', 'o' ], # e.g. P'yŏngyang [Pyongyang]
|
134
|
-
['ø', 'o' ], # e.g. Fuglafjørdur, København
|
135
|
-
['ố', 'o' ], # e.g. Thành Phố Hồ Chí Minh [Saigon]
|
136
|
-
['ồ', 'o' ], # e.g. Thành Phố Hồ Chí Minh [Saigon]
|
137
|
-
['ộ', 'o' ], # e.g. Hà Nội [Hanoi]
|
138
|
-
|
139
|
-
['ř', 'r' ], # e.g. Třeboň
|
140
|
-
|
141
|
-
['ș', 's' ], # e.g. Chișinău, București
|
142
|
-
['ş', 's' ], # e.g. Beşiktaş
|
143
|
-
['š', 's' ], # e.g. Košice
|
144
|
-
['ṣ', 's' ], # e.g. Al-Mawṣil [Mosul]
|
145
|
-
|
146
|
-
['ť', 't' ], # e.g. Měšťan
|
147
|
-
['ṭ', 't' ], # e.g. Al-Kharṭūm [Khartoum], Kāṭhmāḍaũ
|
148
|
-
|
149
|
-
['ü', 'ue'],
|
150
|
-
['ú', 'u' ], # e.g. Fútbol
|
151
|
-
['ù', 'u' ], # e.g. Xyauyù (it)
|
152
|
-
['ū', 'u' ], # e.g. Sūduva
|
153
|
-
['ů', 'u' ], # e.g. Sládkův
|
154
|
-
['ũ', 'u' ], # e.g. Kāṭhmāḍaũ [Kathmandu]
|
155
|
-
|
156
|
-
['ı', 'u' ], # e.g. Bakı # use u?? (Baku) why-why not?
|
157
|
-
|
158
|
-
['x̌', 'x'], # e.g. Pex̌awar [Peshawar]
|
159
|
-
|
160
|
-
['ý', 'y' ], # e.g. Nefitrovaný
|
161
|
-
['ź', 'z' ], # e.g. Łódź
|
162
|
-
['ž', 'z' ], # e.g. Domžale, Petržalka
|
163
|
-
['ż', 'z' ], # e.g. Lomża (polish)
|
164
|
-
|
165
|
-
['Á', 'a' ], # e.g. Águila (es)
|
166
|
-
['Č', 'c' ], # e.g. České
|
167
|
-
|
168
|
-
['Ḥ', 'h' ], # e.g. Ḥalab [Aleppo]
|
169
|
-
['Ḫ', 'h' ], # e.g. Ḫamīs Mušayṭ
|
170
|
-
['İ', 'i' ], # e.g. İnter
|
171
|
-
['Í', 'i' ], # e.g. ÍBV
|
172
|
-
['Ł', 'l' ], # e.g. Łódź
|
173
|
-
|
174
|
-
['Ö', 'oe' ], # e.g. Örebro
|
175
|
-
['Ō', 'o' ], # e.g. Ōsaka [Osaka]
|
176
|
-
['Ø', 'o' ], # e.g. Nogne Ø Imperial Stout (no)
|
177
|
-
|
178
|
-
['Ř', 'r' ], # e.g. Řezák
|
179
|
-
|
180
|
-
['Ś', 's' ], # e.g. Śląsk
|
181
|
-
['Š', 's' ], # e.g. MŠK
|
182
|
-
['Ş', 's' ], # e.g. Şüvälan
|
183
|
-
['Ṣ', 's' ], # e.g. Ṣan'ā' [Sana'a]
|
184
|
-
|
185
|
-
['Ṭ', 't' ], # e.g. Ṭarābulus [Tripoli]
|
186
|
-
['Ú', 'u' ], # e.g. Ústí, Újpest
|
187
|
-
['Ž', 'z' ], # e.g. Žilina
|
188
|
-
['Ż', 'z' ] # e.g. Żywiec (polish)
|
189
|
-
]
|
190
|
-
|
191
|
-
alternatives.each do |alt|
|
192
|
-
key = key.gsub( alt[0], alt[1] )
|
193
|
-
end
|
84
|
+
key = TextUtils.asciify( key ).downcase ## see filter/string_filter
|
194
85
|
|
195
86
|
key
|
196
87
|
end # method title_to_key
|
data/lib/textutils/utils.rb
CHANGED
data/lib/textutils/version.rb
CHANGED
data/lib/textutils.rb
CHANGED
@@ -30,6 +30,7 @@ require 'textutils/filter/code_filter'
|
|
30
30
|
require 'textutils/filter/comment_filter'
|
31
31
|
require 'textutils/filter/erb_django_filter'
|
32
32
|
require 'textutils/filter/erb_filter'
|
33
|
+
require 'textutils/filter/string_filter'
|
33
34
|
|
34
35
|
require 'textutils/helper/date_helper'
|
35
36
|
require 'textutils/helper/hypertext_helper'
|
@@ -45,6 +46,8 @@ require 'textutils/utils'
|
|
45
46
|
require 'textutils/core_ext/file'
|
46
47
|
require 'textutils/core_ext/time'
|
47
48
|
|
49
|
+
require 'textutils/parser/name_parser'
|
50
|
+
|
48
51
|
require 'textutils/reader/code_reader'
|
49
52
|
require 'textutils/reader/hash_reader'
|
50
53
|
require 'textutils/reader/hash_reader_v2'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
require 'helper'
|
5
|
+
|
6
|
+
|
7
|
+
class TestAsciify < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_asciify
|
10
|
+
|
11
|
+
txt_io = [
|
12
|
+
[ 'São Paulo', 'Sao Paulo' ],
|
13
|
+
[ 'São Gonçalo', 'Sao Goncalo' ],
|
14
|
+
[ 'Výčepní', 'Vycepni' ],
|
15
|
+
[ 'Żubr', 'Zubr' ],
|
16
|
+
[ 'Żywiec', 'Zywiec' ],
|
17
|
+
[ 'Lomża Export', 'Lomza Export' ],
|
18
|
+
[ 'Nogne Ø Imperial Stout', 'Nogne O Imperial Stout' ],
|
19
|
+
[ 'Xyauyù', 'Xyauyu' ],
|
20
|
+
[ 'Águila', 'Aguila' ],
|
21
|
+
[ 'Arena Amazônia', 'Arena Amazonia' ],
|
22
|
+
[ 'Tōkyō', 'Tokyo' ],
|
23
|
+
[ 'Ōsaka', 'Osaka' ],
|
24
|
+
[ 'El Djazaïr', 'El Djazair' ],
|
25
|
+
[ 'Al-Kharṭūm', 'Al-Khartum' ],
|
26
|
+
[ 'Ṭarābulus', 'Tarabulus' ],
|
27
|
+
[ 'Al-Iskandarīyah', 'Al-Iskandariyah' ],
|
28
|
+
[ 'Pex̌awar', 'Pexawar'],
|
29
|
+
[ 'Pishōr', 'Pishor' ],
|
30
|
+
[ 'Pishāwar', 'Pishawar' ],
|
31
|
+
[ 'Islām ābād', 'Islam abad' ],
|
32
|
+
[ 'Thành Phố Hồ Chí Minh', 'Thanh Pho Ho Chi Minh' ],
|
33
|
+
[ 'Åland Islands', 'Aland Islands' ]
|
34
|
+
]
|
35
|
+
|
36
|
+
txt_io.each do |txt|
|
37
|
+
assert_equal txt[1], TextUtils.asciify( txt[0] )
|
38
|
+
end
|
39
|
+
end # method test_asciify
|
40
|
+
|
41
|
+
|
42
|
+
end # class TestAsciify
|
43
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
class TestSlugify < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
def test_slugify
|
8
|
+
|
9
|
+
txt_io = [
|
10
|
+
[ 'São Paulo', 'sao-paulo' ],
|
11
|
+
[ 'São Gonçalo', 'sao-goncalo' ],
|
12
|
+
[ 'Výčepní', 'vycepni' ],
|
13
|
+
[ 'Żubr', 'zubr' ],
|
14
|
+
[ 'Żywiec', 'zywiec' ],
|
15
|
+
[ 'Lomża Export', 'lomza-export' ],
|
16
|
+
[ 'Nogne Ø Imperial Stout', 'nogne-o-imperial-stout' ],
|
17
|
+
[ 'Xyauyù', 'xyauyu' ],
|
18
|
+
[ 'Águila', 'aguila' ],
|
19
|
+
[ 'Arena Amazônia', 'arena-amazonia' ],
|
20
|
+
[ 'Tōkyō', 'tokyo' ],
|
21
|
+
[ 'Ōsaka', 'osaka' ],
|
22
|
+
[ 'El Djazaïr', 'el-djazair' ],
|
23
|
+
[ 'Al-Kharṭūm', 'al-khartum' ],
|
24
|
+
[ 'Ṭarābulus', 'tarabulus' ],
|
25
|
+
[ 'Al-Iskandarīyah', 'al-iskandariyah' ],
|
26
|
+
[ 'Pex̌awar', 'pexawar'],
|
27
|
+
[ 'Pishōr', 'pishor' ],
|
28
|
+
[ 'Pishāwar', 'pishawar' ],
|
29
|
+
[ 'Islām ābād', 'islam-abad' ],
|
30
|
+
[ 'Thành Phố Hồ Chí Minh', 'thanh-pho-ho-chi-minh' ],
|
31
|
+
[ 'Åland Islands', 'aland-islands' ]
|
32
|
+
]
|
33
|
+
|
34
|
+
txt_io.each do |txt|
|
35
|
+
assert_equal txt[1], TextUtils.slugify( txt[0] )
|
36
|
+
end
|
37
|
+
end # method test_slugify
|
38
|
+
|
39
|
+
|
40
|
+
end # class TestSlugify
|
data/test/test_title_helper.rb
CHANGED
metadata
CHANGED
@@ -1,77 +1,93 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
5
|
-
prerelease:
|
4
|
+
version: 0.9.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Gerald Bauer
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: props
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: logutils
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0.5'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.5'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: activesupport
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
45
|
- - ! '>='
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :runtime
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: rdoc
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
61
|
+
version: '4.0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: hoe
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
73
|
- - ~>
|
64
74
|
- !ruby/object:Gem::Version
|
65
|
-
version: '3.
|
75
|
+
version: '3.6'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.6'
|
69
83
|
description: textutils - Text Filters, Helpers, Readers and More
|
70
84
|
email: ruby-talk@ruby-lang.org
|
71
85
|
executables: []
|
72
86
|
extensions: []
|
73
87
|
extra_rdoc_files:
|
88
|
+
- HISTORY.md
|
74
89
|
- Manifest.txt
|
90
|
+
- README.md
|
75
91
|
files:
|
76
92
|
- HISTORY.md
|
77
93
|
- Manifest.txt
|
@@ -85,6 +101,7 @@ files:
|
|
85
101
|
- lib/textutils/filter/comment_filter.rb
|
86
102
|
- lib/textutils/filter/erb_django_filter.rb
|
87
103
|
- lib/textutils/filter/erb_filter.rb
|
104
|
+
- lib/textutils/filter/string_filter.rb
|
88
105
|
- lib/textutils/helper/address_helper.rb
|
89
106
|
- lib/textutils/helper/date_helper.rb
|
90
107
|
- lib/textutils/helper/hypertext_helper.rb
|
@@ -94,6 +111,7 @@ files:
|
|
94
111
|
- lib/textutils/helper/value_helper.rb
|
95
112
|
- lib/textutils/helper/xml_helper.rb
|
96
113
|
- lib/textutils/page.rb
|
114
|
+
- lib/textutils/parser/name_parser.rb
|
97
115
|
- lib/textutils/patterns.rb
|
98
116
|
- lib/textutils/reader/code_reader.rb
|
99
117
|
- lib/textutils/reader/fixture_reader.rb
|
@@ -109,7 +127,9 @@ files:
|
|
109
127
|
- lib/textutils/version.rb
|
110
128
|
- test/helper.rb
|
111
129
|
- test/test_address_helper.rb
|
130
|
+
- test/test_asciify.rb
|
112
131
|
- test/test_hypertext_helper.rb
|
132
|
+
- test/test_slugify.rb
|
113
133
|
- test/test_taglist.rb
|
114
134
|
- test/test_title_finder.rb
|
115
135
|
- test/test_title_helper.rb
|
@@ -120,6 +140,7 @@ files:
|
|
120
140
|
homepage: https://github.com/rubylibs/textutils
|
121
141
|
licenses:
|
122
142
|
- Public Domain
|
143
|
+
metadata: {}
|
123
144
|
post_install_message:
|
124
145
|
rdoc_options:
|
125
146
|
- --main
|
@@ -127,29 +148,29 @@ rdoc_options:
|
|
127
148
|
require_paths:
|
128
149
|
- lib
|
129
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
151
|
requirements:
|
132
152
|
- - ! '>='
|
133
153
|
- !ruby/object:Gem::Version
|
134
154
|
version: 1.9.2
|
135
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
156
|
requirements:
|
138
157
|
- - ! '>='
|
139
158
|
- !ruby/object:Gem::Version
|
140
159
|
version: '0'
|
141
160
|
requirements: []
|
142
161
|
rubyforge_project: textutils
|
143
|
-
rubygems_version: 1.
|
162
|
+
rubygems_version: 2.1.10
|
144
163
|
signing_key:
|
145
|
-
specification_version:
|
164
|
+
specification_version: 4
|
146
165
|
summary: textutils - Text Filters, Helpers, Readers and More
|
147
166
|
test_files:
|
167
|
+
- test/test_address_helper.rb
|
168
|
+
- test/test_asciify.rb
|
169
|
+
- test/test_hypertext_helper.rb
|
170
|
+
- test/test_slugify.rb
|
171
|
+
- test/test_taglist.rb
|
148
172
|
- test/test_title_finder.rb
|
149
|
-
- test/
|
173
|
+
- test/test_title_helper.rb
|
150
174
|
- test/test_title_mapper.rb
|
175
|
+
- test/test_unicode_helper.rb
|
151
176
|
- test/test_values_reader.rb
|
152
|
-
- test/test_taglist.rb
|
153
|
-
- test/test_hypertext_helper.rb
|
154
|
-
- test/test_title_helper.rb
|
155
|
-
- test/test_address_helper.rb
|