slugity 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,139 @@
1
+ # encoding: utf-8
2
+ module Slugity
3
+ module Matchers
4
+
5
+ @@matchers = {
6
+ # define the default matchers
7
+ default: {
8
+
9
+ # symbols
10
+ /\s|\// => '-',
11
+ /\~|\~/ => '-',
12
+ /\_/ => '_',
13
+ /\&/ => 'and',
14
+ /\+/ => 'plus',
15
+ /\=/ => 'equals',
16
+ /℡/ => 'tel',
17
+ /™/ => 'tm',
18
+ /℠/ => 'sm',
19
+ /²/ => '2',
20
+ /³/ => '3',
21
+
22
+ # a
23
+ /[ÀÁÂÃÄÅàáâãäåĀāĂ㥹ᴀ⒜ⒶaǍǎǞǟǠǡǺǻȃȀȁȂȦȧȺḀḁẚẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặÅɑₐⓐA]/ => 'a',
24
+ /[Ꜳꜳ]/ => 'aa',
25
+ /℀/ => 'ac',
26
+ /[ÆæǢǣǼǽᴁᴂ]/ => 'ae',
27
+ /[ꜺꜻꜼꜽ]/ => 'af',
28
+ /[Ꜷꜷ]/ => 'aj',
29
+ /℁/ => 'as',
30
+ /[Ꜵꜵ]/ => 'ao',
31
+ /[Ꜹꜹ]/ => 'av',
32
+
33
+ # b
34
+ /[ƀƁƄƅɃᴃḂḃḄḅḆḇℬ⒝ⒷⓑBbẞ]/ => 'b',
35
+
36
+ # c
37
+ /[ÇçĆćĈĉĊċČčƇƈȻȼᴄḈḉℂ℃℄⒞ⒸⓒCc]/ => 'c',
38
+ /℅/ => 'co',
39
+ /℆/ => 'cu',
40
+
41
+ # d
42
+ /[ÐĎďĐđƉƊɗᴅᴆḊḋḌḍḎḏḐḑḒḓ⒟ⒹⓓDd]/ => 'd',
43
+ /ȸ/ => 'db',
44
+ /[DŽDždžDZDzdz]/ => 'dz',
45
+
46
+ # e
47
+ /[ÈÉÊËèéêëĒēĔĕĖėĘęĚěƐǝȄȅȆȇȨȩɆɇᴇḔḕḖḗḘḙḚḛḜḝẸẹẺẻẼẽẾếỀềỂểỄễỆệₑ℮ℯ⒠ⒺⓔEe]/ => 'e',
48
+
49
+ # f
50
+ /[ƑƒḞḟ℉⒡ⒻⓕꜰFf]/ => 'f',
51
+
52
+ # g
53
+ /[ĜĝĞğĠġĢģƓǤǥǦǧǴǵɠɡɢḠḡℊ⒢ⒼⓖGg]/ => 'g',
54
+
55
+ # h
56
+ /[ĤĥĦħȞȟḢḣḤḥḦḧḨḩḪḫẖℋℌℍℎℏ⒣ⒽⓗHh]/ => 'h',
57
+
58
+ # i
59
+ /[ÌÍÎÏìíîïĨĩĪīĬĭĮįƖƗǏǐȈȉȊȋḬḭḮḯ⒤ⒾⓘIi]/ => 'i',
60
+ /[IJij]/ => 'ij',
61
+
62
+ # j
63
+ /[ĴĵǰȷɈɉᴊ⒥ⒿⓙJj]/ => 'j',
64
+
65
+ # k
66
+ /[ĶķĸƘƙǨǩᴋḰḱḲḳḴḵK⒦ⓀⓚKk]/ => 'k',
67
+
68
+ # l
69
+ /[İıĹĺĻļĽľĿŀŁłȽȾᴌḶḷḸḹḺḻḼḽ⒧ⓁⓛLl]/ => 'l',
70
+ /[LJLjlj]/ => 'lj',
71
+
72
+ # m
73
+ /[ɱᴍḾḿṀṁṂṃ⒨ⓂⓜMm]/ => 'm',
74
+
75
+ # n
76
+ /[ÑñŃńŅņŇňʼnŊŋƝƞǸǹȠᴎṄṅṆṇṈṉṊṋℕ⒩ⓃⓝNn]/ => 'n',
77
+ /[Ƌƌ]/ => 'nd',
78
+ /[NJNjnj]/ => 'nj',
79
+
80
+ # o
81
+ /[ÒÓÔÕÖØðòóôõöøŌōŎŏŐőƟƠơǑǒǪǫǬǭǾǿȌȍȎȏȪȫȬȭȮȯȰȱɵᴏṌṍṎṏṐṑṒṓỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợₒ⒪ⓄⓞOo]/ => 'o',
82
+ /[Œœɶ]/ => 'oe',
83
+
84
+ # p
85
+ /[ƤƥṔṕṖṗ℗ℙ⒫ⓅⓟPp]/ => 'p',
86
+ /℞/ => 'px',
87
+
88
+ # q
89
+ /[ƼƽɊɋℚ⒬ⓆⓠQq]/ => 'q',
90
+ /ȹ/ => 'qp',
91
+
92
+ # r
93
+ /[ŔŕŖŗŘřƦȐȑȒȓɌɍṘṙṚṛṜṝṞṟℛℜℝ℟⒭ⓇⓡRr]/ => 'r',
94
+
95
+ # s
96
+ /[ŚśŜŝŞşŠšſƧƨƩȘșȿṠṡṢṣṤṥṦṧṨṩ⒮ⓈⓢꜱSs]/ => 's',
97
+ /[ß]/ => 'ss',
98
+
99
+ # t
100
+ /[ŢţŤťŦŧƪƫƬƭƮȚțṪṫṬṭṮṯṰṱẗ⒯ⓉⓣTt]/ => 't',
101
+ /[Þþ]/ => 'th',
102
+
103
+ # u
104
+ /[µÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưƱƲǓǔǕǖǗǘǙǚǛǜȕȖȗɄṲṳṴṵṶṷṸṹṺṻỤụỦủỨứỪừỬửỮữỰự⒰ⓊⓤUuȔ]/ => 'u',
105
+
106
+ # v
107
+ /[ɅṼṽṾṿ⒱ⓋⓥVv]/ => 'v',
108
+
109
+ # w
110
+ /[ŴŵƜɯẀẁẂẃẄẅẆẇẈẉẘ⒲ⓌⓦWw]/ => 'w',
111
+
112
+ # x
113
+ /[×ẊẋẌẍₓ⒳ⓍⓧXx]/ => 'x',
114
+
115
+ # y
116
+ /[ÝýÿŶŷŸȲȳɏẎẏẙỲỳỴỵỶỷỸỹ⒴ⓎⓨYyɎ]/ => 'y',
117
+
118
+ # z
119
+ /[ŹźŻżŽžƵƶƷȤȥɀẐẑẒẓẔẕℤ⒵ⓏⓩZz]/ => 'z',
120
+
121
+ # numbers
122
+ /⓪/ => '0',
123
+ /⒐/ => '9',
124
+ /⒑/ => '10',
125
+ /⒒/ => '11',
126
+ /⒓/ => '12',
127
+ /⒔/ => '13',
128
+ /⒕/ => '14',
129
+ /⒖/ => '15',
130
+ /⒗/ => '16',
131
+ /⒘/ => '17',
132
+ /⒙/ => '18',
133
+ /⒚/ => '19',
134
+ /⒛/ => '20',
135
+ }
136
+ }
137
+
138
+ end
139
+ end
@@ -1,16 +1,9 @@
1
+ # encoding: utf-8
2
+ require 'slugity/matchers/default'
3
+
1
4
  module Slugity
2
5
  module Matchers
3
6
 
4
- @@matchers = {
5
- # define the default matchers
6
- default: {
7
- /\s|\// => '-',
8
- /\&/ => 'and',
9
- /\+/ => 'plus',
10
- /\=/ => 'equals'
11
- }
12
- }
13
-
14
7
  # fetch a matcher
15
8
  # @param key [Symbol]
16
9
  # @return [Hash]
@@ -30,4 +23,6 @@ module Slugity
30
23
  end
31
24
 
32
25
  end
33
- end
26
+ end
27
+
28
+
@@ -1,3 +1,3 @@
1
1
  module Slugity
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -0,0 +1,912 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'slugity'
5
+
6
+ test_characters = {
7
+ '²' => '2',
8
+ '³' => '3',
9
+ '&' => 'and',
10
+ '-' => '-',
11
+ '_' => '_',
12
+ '=' => 'equals',
13
+ '+' => 'plus',
14
+ '~' => '-',
15
+ 'µ' => 'u',
16
+ 'A' => 'a',
17
+ 'B' => 'b',
18
+ 'C' => 'c',
19
+ 'D' => 'd',
20
+ 'E' => 'e',
21
+ 'F' => 'f',
22
+ 'G' => 'g',
23
+ 'H' => 'h',
24
+ 'I' => 'i',
25
+ 'J' => 'j',
26
+ 'K' => 'k',
27
+ 'L' => 'l',
28
+ 'M' => 'm',
29
+ 'N' => 'n',
30
+ 'O' => 'o',
31
+ 'P' => 'p',
32
+ 'Q' => 'q',
33
+ 'R' => 'r',
34
+ 'S' => 's',
35
+ 'T' => 't',
36
+ 'U' => 'u',
37
+ 'V' => 'v',
38
+ 'W' => 'w',
39
+ 'X' => 'x',
40
+ 'Y' => 'y',
41
+ 'Z' => 'z',
42
+ 'a' => 'a',
43
+ 'b' => 'b',
44
+ 'c' => 'c',
45
+ 'd' => 'd',
46
+ 'e' => 'e',
47
+ 'f' => 'f',
48
+ 'g' => 'g',
49
+ 'h' => 'h',
50
+ 'i' => 'i',
51
+ 'j' => 'j',
52
+ 'k' => 'k',
53
+ 'l' => 'l',
54
+ 'm' => 'm',
55
+ 'n' => 'n',
56
+ 'o' => 'o',
57
+ 'p' => 'p',
58
+ 'q' => 'q',
59
+ 'r' => 'r',
60
+ 's' => 's',
61
+ 't' => 't',
62
+ 'u' => 'u',
63
+ 'v' => 'v',
64
+ 'w' => 'w',
65
+ 'x' => 'x',
66
+ 'y' => 'y',
67
+ 'z' => 'z',
68
+ 'À' => 'a',
69
+ 'Á' => 'a',
70
+ 'Â' => 'a',
71
+ 'Ã' => 'a',
72
+ 'Ä' => 'a',
73
+ 'Å' => 'a',
74
+ 'Æ' => 'ae',
75
+ 'Ç' => 'c',
76
+ 'È' => 'e',
77
+ 'É' => 'e',
78
+ 'Ê' => 'e',
79
+ 'Ë' => 'e',
80
+ 'Ì' => 'i',
81
+ 'Í' => 'i',
82
+ 'Î' => 'i',
83
+ 'Ï' => 'i',
84
+ 'Ð' => 'd',
85
+ 'Ñ' => 'n',
86
+ 'Ò' => 'o',
87
+ 'Ó' => 'o',
88
+ 'Ô' => 'o',
89
+ 'Õ' => 'o',
90
+ 'Ö' => 'o',
91
+ '×' => 'x',
92
+ 'Ø' => 'o',
93
+ 'Ù' => 'u',
94
+ 'Ú' => 'u',
95
+ 'Û' => 'u',
96
+ 'Ü' => 'u',
97
+ 'Ý' => 'y',
98
+ 'Þ' => 'th',
99
+ 'ß' => 'ss',
100
+ 'à' => 'a',
101
+ 'á' => 'a',
102
+ 'â' => 'a',
103
+ 'ã' => 'a',
104
+ 'ä' => 'a',
105
+ 'å' => 'a',
106
+ 'æ' => 'ae',
107
+ 'ç' => 'c',
108
+ 'è' => 'e',
109
+ 'é' => 'e',
110
+ 'ê' => 'e',
111
+ 'ë' => 'e',
112
+ 'ì' => 'i',
113
+ 'í' => 'i',
114
+ 'î' => 'i',
115
+ 'ï' => 'i',
116
+ 'ð' => 'o',
117
+ 'ñ' => 'n',
118
+ 'ò' => 'o',
119
+ 'ó' => 'o',
120
+ 'ô' => 'o',
121
+ 'õ' => 'o',
122
+ 'ö' => 'o',
123
+ 'ø' => 'o',
124
+ 'ù' => 'u',
125
+ 'ú' => 'u',
126
+ 'û' => 'u',
127
+ 'ü' => 'u',
128
+ 'ý' => 'y',
129
+ 'þ' => 'th',
130
+ 'ÿ' => 'y',
131
+ 'Ā' => 'a',
132
+ 'ā' => 'a',
133
+ 'Ă' => 'a',
134
+ 'ă' => 'a',
135
+ 'Ą' => 'a',
136
+ 'ą' => 'a',
137
+ 'Ć' => 'c',
138
+ 'ć' => 'c',
139
+ 'Ĉ' => 'c',
140
+ 'ĉ' => 'c',
141
+ 'Ċ' => 'c',
142
+ 'ċ' => 'c',
143
+ 'Č' => 'c',
144
+ 'č' => 'c',
145
+ 'Ď' => 'd',
146
+ 'ď' => 'd',
147
+ 'Đ' => 'd',
148
+ 'đ' => 'd',
149
+ 'Ē' => 'e',
150
+ 'ē' => 'e',
151
+ 'Ĕ' => 'e',
152
+ 'ĕ' => 'e',
153
+ 'Ė' => 'e',
154
+ 'ė' => 'e',
155
+ 'Ę' => 'e',
156
+ 'ę' => 'e',
157
+ 'Ě' => 'e',
158
+ 'ě' => 'e',
159
+ 'Ĝ' => 'g',
160
+ 'ĝ' => 'g',
161
+ 'Ğ' => 'g',
162
+ 'ğ' => 'g',
163
+ 'Ġ' => 'g',
164
+ 'ġ' => 'g',
165
+ 'Ģ' => 'g',
166
+ 'ģ' => 'g',
167
+ 'Ĥ' => 'h',
168
+ 'ĥ' => 'h',
169
+ 'Ħ' => 'h',
170
+ 'ħ' => 'h',
171
+ 'Ĩ' => 'i',
172
+ 'ĩ' => 'i',
173
+ 'Ī' => 'i',
174
+ 'ī' => 'i',
175
+ 'Ĭ' => 'i',
176
+ 'ĭ' => 'i',
177
+ 'Į' => 'i',
178
+ 'į' => 'i',
179
+ 'İ' => 'l',
180
+ 'ı' => 'l',
181
+ 'IJ' => 'ij',
182
+ 'ij' => 'ij',
183
+ 'Ĵ' => 'j',
184
+ 'ĵ' => 'j',
185
+ 'Ķ' => 'k',
186
+ 'ķ' => 'k',
187
+ 'ĸ' => 'k',
188
+ 'Ĺ' => 'l',
189
+ 'ĺ' => 'l',
190
+ 'Ļ' => 'l',
191
+ 'ļ' => 'l',
192
+ 'Ľ' => 'l',
193
+ 'ľ' => 'l',
194
+ 'Ŀ' => 'l',
195
+ 'ŀ' => 'l',
196
+ 'Ł' => 'l',
197
+ 'ł' => 'l',
198
+ 'Ń' => 'n',
199
+ 'ń' => 'n',
200
+ 'Ņ' => 'n',
201
+ 'ņ' => 'n',
202
+ 'Ň' => 'n',
203
+ 'ň' => 'n',
204
+ 'ʼn' => 'n',
205
+ 'Ŋ' => 'n',
206
+ 'ŋ' => 'n',
207
+ 'Ō' => 'o',
208
+ 'ō' => 'o',
209
+ 'Ŏ' => 'o',
210
+ 'ŏ' => 'o',
211
+ 'Ő' => 'o',
212
+ 'ő' => 'o',
213
+ 'Œ' => 'oe',
214
+ 'œ' => 'oe',
215
+ 'Ŕ' => 'r',
216
+ 'ŕ' => 'r',
217
+ 'Ŗ' => 'r',
218
+ 'ŗ' => 'r',
219
+ 'Ř' => 'r',
220
+ 'ř' => 'r',
221
+ 'Ś' => 's',
222
+ 'ś' => 's',
223
+ 'Ŝ' => 's',
224
+ 'ŝ' => 's',
225
+ 'Ş' => 's',
226
+ 'ş' => 's',
227
+ 'Š' => 's',
228
+ 'š' => 's',
229
+ 'Ţ' => 't',
230
+ 'ţ' => 't',
231
+ 'Ť' => 't',
232
+ 'ť' => 't',
233
+ 'Ŧ' => 't',
234
+ 'ŧ' => 't',
235
+ 'Ũ' => 'u',
236
+ 'ũ' => 'u',
237
+ 'Ū' => 'u',
238
+ 'ū' => 'u',
239
+ 'Ŭ' => 'u',
240
+ 'ŭ' => 'u',
241
+ 'Ů' => 'u',
242
+ 'ů' => 'u',
243
+ 'Ű' => 'u',
244
+ 'ű' => 'u',
245
+ 'Ų' => 'u',
246
+ 'ų' => 'u',
247
+ 'Ŵ' => 'w',
248
+ 'ŵ' => 'w',
249
+ 'Ŷ' => 'y',
250
+ 'ŷ' => 'y',
251
+ 'Ÿ' => 'y',
252
+ 'Ź' => 'z',
253
+ 'ź' => 'z',
254
+ 'Ż' => 'z',
255
+ 'ż' => 'z',
256
+ 'Ž' => 'z',
257
+ 'ž' => 'z',
258
+ 'ſ' => 's',
259
+ 'ƀ' => 'b',
260
+ 'Ɓ' => 'b',
261
+ 'Ƅ' => 'b',
262
+ 'ƅ' => 'b',
263
+ 'Ƈ' => 'c',
264
+ 'ƈ' => 'c',
265
+ 'Ɖ' => 'd',
266
+ 'Ɗ' => 'd',
267
+ 'Ƌ' => 'nd',
268
+ 'ƌ' => 'nd',
269
+ 'Ɛ' => 'e',
270
+ 'Ƒ' => 'f',
271
+ 'ƒ' => 'f',
272
+ 'Ɠ' => 'g',
273
+ 'Ɩ' => 'i',
274
+ 'Ɨ' => 'i',
275
+ 'Ƙ' => 'k',
276
+ 'ƙ' => 'k',
277
+ 'Ɯ' => 'w',
278
+ 'Ɲ' => 'n',
279
+ 'ƞ' => 'n',
280
+ 'Ɵ' => 'o',
281
+ 'Ơ' => 'o',
282
+ 'ơ' => 'o',
283
+ 'Ƥ' => 'p',
284
+ 'ƥ' => 'p',
285
+ 'Ʀ' => 'r',
286
+ 'Ƨ' => 's',
287
+ 'ƨ' => 's',
288
+ 'Ʃ' => 's',
289
+ 'ƪ' => 't',
290
+ 'ƫ' => 't',
291
+ 'Ƭ' => 't',
292
+ 'ƭ' => 't',
293
+ 'Ʈ' => 't',
294
+ 'Ư' => 'u',
295
+ 'ư' => 'u',
296
+ 'Ʊ' => 'u',
297
+ 'Ʋ' => 'u',
298
+ 'Ƶ' => 'z',
299
+ 'ƶ' => 'z',
300
+ 'Ʒ' => 'z',
301
+ 'Ƽ' => 'q',
302
+ 'ƽ' => 'q',
303
+ 'DŽ' => 'dz',
304
+ 'Dž' => 'dz',
305
+ 'dž' => 'dz',
306
+ 'LJ' => 'lj',
307
+ 'Lj' => 'lj',
308
+ 'lj' => 'lj',
309
+ 'NJ' => 'nj',
310
+ 'Nj' => 'nj',
311
+ 'nj' => 'nj',
312
+ 'Ǎ' => 'a',
313
+ 'ǎ' => 'a',
314
+ 'Ǐ' => 'i',
315
+ 'ǐ' => 'i',
316
+ 'Ǒ' => 'o',
317
+ 'ǒ' => 'o',
318
+ 'Ǔ' => 'u',
319
+ 'ǔ' => 'u',
320
+ 'Ǖ' => 'u',
321
+ 'ǖ' => 'u',
322
+ 'Ǘ' => 'u',
323
+ 'ǘ' => 'u',
324
+ 'Ǚ' => 'u',
325
+ 'ǚ' => 'u',
326
+ 'Ǜ' => 'u',
327
+ 'ǜ' => 'u',
328
+ 'ǝ' => 'e',
329
+ 'Ǟ' => 'a',
330
+ 'ǟ' => 'a',
331
+ 'Ǡ' => 'a',
332
+ 'ǡ' => 'a',
333
+ 'Ǣ' => 'ae',
334
+ 'ǣ' => 'ae',
335
+ 'Ǥ' => 'g',
336
+ 'ǥ' => 'g',
337
+ 'Ǧ' => 'g',
338
+ 'ǧ' => 'g',
339
+ 'Ǩ' => 'k',
340
+ 'ǩ' => 'k',
341
+ 'Ǫ' => 'o',
342
+ 'ǫ' => 'o',
343
+ 'Ǭ' => 'o',
344
+ 'ǭ' => 'o',
345
+ 'ǰ' => 'j',
346
+ 'DZ' => 'dz',
347
+ 'Dz' => 'dz',
348
+ 'dz' => 'dz',
349
+ 'Ǵ' => 'g',
350
+ 'ǵ' => 'g',
351
+ 'Ǹ' => 'n',
352
+ 'ǹ' => 'n',
353
+ 'Ǻ' => 'a',
354
+ 'ǻ' => 'a',
355
+ 'Ǽ' => 'ae',
356
+ 'ǽ' => 'ae',
357
+ 'Ǿ' => 'o',
358
+ 'ǿ' => 'o',
359
+ 'Ȁ' => 'a',
360
+ 'ȁ' => 'a',
361
+ 'Ȃ' => 'a',
362
+ 'ȃ' => 'a',
363
+ 'Ȅ' => 'e',
364
+ 'ȅ' => 'e',
365
+ 'Ȇ' => 'e',
366
+ 'ȇ' => 'e',
367
+ 'Ȉ' => 'i',
368
+ 'ȉ' => 'i',
369
+ 'Ȋ' => 'i',
370
+ 'ȋ' => 'i',
371
+ 'Ȍ' => 'o',
372
+ 'ȍ' => 'o',
373
+ 'Ȏ' => 'o',
374
+ 'ȏ' => 'o',
375
+ 'Ȑ' => 'r',
376
+ 'ȑ' => 'r',
377
+ 'Ȓ' => 'r',
378
+ 'ȓ' => 'r',
379
+ 'Ȕ' => 'u',
380
+ 'ȕ' => 'u',
381
+ 'Ȗ' => 'u',
382
+ 'ȗ' => 'u',
383
+ 'Ș' => 's',
384
+ 'ș' => 's',
385
+ 'Ț' => 't',
386
+ 'ț' => 't',
387
+ 'Ȟ' => 'h',
388
+ 'ȟ' => 'h',
389
+ 'Ƞ' => 'n',
390
+ 'Ȥ' => 'z',
391
+ 'ȥ' => 'z',
392
+ 'Ȧ' => 'a',
393
+ 'ȧ' => 'a',
394
+ 'Ȩ' => 'e',
395
+ 'ȩ' => 'e',
396
+ 'Ȫ' => 'o',
397
+ 'ȫ' => 'o',
398
+ 'Ȭ' => 'o',
399
+ 'ȭ' => 'o',
400
+ 'Ȯ' => 'o',
401
+ 'ȯ' => 'o',
402
+ 'Ȱ' => 'o',
403
+ 'ȱ' => 'o',
404
+ 'Ȳ' => 'y',
405
+ 'ȳ' => 'y',
406
+ 'ȷ' => 'j',
407
+ 'ȸ' => 'db',
408
+ 'ȹ' => 'qp',
409
+ 'Ⱥ' => 'a',
410
+ 'Ȼ' => 'c',
411
+ 'ȼ' => 'c',
412
+ 'Ƚ' => 'l',
413
+ 'Ⱦ' => 'l',
414
+ 'ȿ' => 's',
415
+ 'ɀ' => 'z',
416
+ 'Ƀ' => 'b',
417
+ 'Ʉ' => 'u',
418
+ 'Ʌ' => 'v',
419
+ 'Ɇ' => 'e',
420
+ 'ɇ' => 'e',
421
+ 'Ɉ' => 'j',
422
+ 'ɉ' => 'j',
423
+ 'Ɋ' => 'q',
424
+ 'ɋ' => 'q',
425
+ 'Ɍ' => 'r',
426
+ 'ɍ' => 'r',
427
+ 'Ɏ' => 'y',
428
+ 'ɏ' => 'y',
429
+ 'ɑ' => 'a',
430
+ 'ɗ' => 'd',
431
+ 'ɠ' => 'g',
432
+ 'ɡ' => 'g',
433
+ 'ɢ' => 'g',
434
+ 'ɯ' => 'w',
435
+ 'ɱ' => 'm',
436
+ 'ɵ' => 'o',
437
+ 'ɶ' => 'oe',
438
+ 'ᴀ' => 'a',
439
+ 'ᴁ' => 'ae',
440
+ 'ᴂ' => 'ae',
441
+ 'ᴃ' => 'b',
442
+ 'ᴄ' => 'c',
443
+ 'ᴅ' => 'd',
444
+ 'ᴆ' => 'd',
445
+ 'ᴇ' => 'e',
446
+ 'ᴊ' => 'j',
447
+ 'ᴋ' => 'k',
448
+ 'ᴌ' => 'l',
449
+ 'ᴍ' => 'm',
450
+ 'ᴎ' => 'n',
451
+ 'ᴏ' => 'o',
452
+ 'Ḁ' => 'a',
453
+ 'ḁ' => 'a',
454
+ 'Ḃ' => 'b',
455
+ 'ḃ' => 'b',
456
+ 'Ḅ' => 'b',
457
+ 'ḅ' => 'b',
458
+ 'Ḇ' => 'b',
459
+ 'ḇ' => 'b',
460
+ 'Ḉ' => 'c',
461
+ 'ḉ' => 'c',
462
+ 'Ḋ' => 'd',
463
+ 'ḋ' => 'd',
464
+ 'Ḍ' => 'd',
465
+ 'ḍ' => 'd',
466
+ 'Ḏ' => 'd',
467
+ 'ḏ' => 'd',
468
+ 'Ḑ' => 'd',
469
+ 'ḑ' => 'd',
470
+ 'Ḓ' => 'd',
471
+ 'ḓ' => 'd',
472
+ 'Ḕ' => 'e',
473
+ 'ḕ' => 'e',
474
+ 'Ḗ' => 'e',
475
+ 'ḗ' => 'e',
476
+ 'Ḙ' => 'e',
477
+ 'ḙ' => 'e',
478
+ 'Ḛ' => 'e',
479
+ 'ḛ' => 'e',
480
+ 'Ḝ' => 'e',
481
+ 'ḝ' => 'e',
482
+ 'Ḟ' => 'f',
483
+ 'ḟ' => 'f',
484
+ 'Ḡ' => 'g',
485
+ 'ḡ' => 'g',
486
+ 'Ḣ' => 'h',
487
+ 'ḣ' => 'h',
488
+ 'Ḥ' => 'h',
489
+ 'ḥ' => 'h',
490
+ 'Ḧ' => 'h',
491
+ 'ḧ' => 'h',
492
+ 'Ḩ' => 'h',
493
+ 'ḩ' => 'h',
494
+ 'Ḫ' => 'h',
495
+ 'ḫ' => 'h',
496
+ 'Ḭ' => 'i',
497
+ 'ḭ' => 'i',
498
+ 'Ḯ' => 'i',
499
+ 'ḯ' => 'i',
500
+ 'Ḱ' => 'k',
501
+ 'ḱ' => 'k',
502
+ 'Ḳ' => 'k',
503
+ 'ḳ' => 'k',
504
+ 'Ḵ' => 'k',
505
+ 'ḵ' => 'k',
506
+ 'Ḷ' => 'l',
507
+ 'ḷ' => 'l',
508
+ 'Ḹ' => 'l',
509
+ 'ḹ' => 'l',
510
+ 'Ḻ' => 'l',
511
+ 'ḻ' => 'l',
512
+ 'Ḽ' => 'l',
513
+ 'ḽ' => 'l',
514
+ 'Ḿ' => 'm',
515
+ 'ḿ' => 'm',
516
+ 'Ṁ' => 'm',
517
+ 'ṁ' => 'm',
518
+ 'Ṃ' => 'm',
519
+ 'ṃ' => 'm',
520
+ 'Ṅ' => 'n',
521
+ 'ṅ' => 'n',
522
+ 'Ṇ' => 'n',
523
+ 'ṇ' => 'n',
524
+ 'Ṉ' => 'n',
525
+ 'ṉ' => 'n',
526
+ 'Ṋ' => 'n',
527
+ 'ṋ' => 'n',
528
+ 'Ṍ' => 'o',
529
+ 'ṍ' => 'o',
530
+ 'Ṏ' => 'o',
531
+ 'ṏ' => 'o',
532
+ 'Ṑ' => 'o',
533
+ 'ṑ' => 'o',
534
+ 'Ṓ' => 'o',
535
+ 'ṓ' => 'o',
536
+ 'Ṕ' => 'p',
537
+ 'ṕ' => 'p',
538
+ 'Ṗ' => 'p',
539
+ 'ṗ' => 'p',
540
+ 'Ṙ' => 'r',
541
+ 'ṙ' => 'r',
542
+ 'Ṛ' => 'r',
543
+ 'ṛ' => 'r',
544
+ 'Ṝ' => 'r',
545
+ 'ṝ' => 'r',
546
+ 'Ṟ' => 'r',
547
+ 'ṟ' => 'r',
548
+ 'Ṡ' => 's',
549
+ 'ṡ' => 's',
550
+ 'Ṣ' => 's',
551
+ 'ṣ' => 's',
552
+ 'Ṥ' => 's',
553
+ 'ṥ' => 's',
554
+ 'Ṧ' => 's',
555
+ 'ṧ' => 's',
556
+ 'Ṩ' => 's',
557
+ 'ṩ' => 's',
558
+ 'Ṫ' => 't',
559
+ 'ṫ' => 't',
560
+ 'Ṭ' => 't',
561
+ 'ṭ' => 't',
562
+ 'Ṯ' => 't',
563
+ 'ṯ' => 't',
564
+ 'Ṱ' => 't',
565
+ 'ṱ' => 't',
566
+ 'Ṳ' => 'u',
567
+ 'ṳ' => 'u',
568
+ 'Ṵ' => 'u',
569
+ 'ṵ' => 'u',
570
+ 'Ṷ' => 'u',
571
+ 'ṷ' => 'u',
572
+ 'Ṹ' => 'u',
573
+ 'ṹ' => 'u',
574
+ 'Ṻ' => 'u',
575
+ 'ṻ' => 'u',
576
+ 'Ṽ' => 'v',
577
+ 'ṽ' => 'v',
578
+ 'Ṿ' => 'v',
579
+ 'ṿ' => 'v',
580
+ 'Ẁ' => 'w',
581
+ 'ẁ' => 'w',
582
+ 'Ẃ' => 'w',
583
+ 'ẃ' => 'w',
584
+ 'Ẅ' => 'w',
585
+ 'ẅ' => 'w',
586
+ 'Ẇ' => 'w',
587
+ 'ẇ' => 'w',
588
+ 'Ẉ' => 'w',
589
+ 'ẉ' => 'w',
590
+ 'Ẋ' => 'x',
591
+ 'ẋ' => 'x',
592
+ 'Ẍ' => 'x',
593
+ 'ẍ' => 'x',
594
+ 'Ẏ' => 'y',
595
+ 'ẏ' => 'y',
596
+ 'Ẑ' => 'z',
597
+ 'ẑ' => 'z',
598
+ 'Ẓ' => 'z',
599
+ 'ẓ' => 'z',
600
+ 'Ẕ' => 'z',
601
+ 'ẕ' => 'z',
602
+ 'ẖ' => 'h',
603
+ 'ẗ' => 't',
604
+ 'ẘ' => 'w',
605
+ 'ẙ' => 'y',
606
+ 'ẚ' => 'a',
607
+ 'Ạ' => 'a',
608
+ 'ạ' => 'a',
609
+ 'Ả' => 'a',
610
+ 'ả' => 'a',
611
+ 'Ấ' => 'a',
612
+ 'ấ' => 'a',
613
+ 'Ầ' => 'a',
614
+ 'ầ' => 'a',
615
+ 'Ẩ' => 'a',
616
+ 'ẩ' => 'a',
617
+ 'Ẫ' => 'a',
618
+ 'ẫ' => 'a',
619
+ 'Ậ' => 'a',
620
+ 'ậ' => 'a',
621
+ 'Ắ' => 'a',
622
+ 'ắ' => 'a',
623
+ 'Ằ' => 'a',
624
+ 'ằ' => 'a',
625
+ 'Ẳ' => 'a',
626
+ 'ẳ' => 'a',
627
+ 'Ẵ' => 'a',
628
+ 'ẵ' => 'a',
629
+ 'Ặ' => 'a',
630
+ 'ặ' => 'a',
631
+ 'Ẹ' => 'e',
632
+ 'ẹ' => 'e',
633
+ 'Ẻ' => 'e',
634
+ 'ẻ' => 'e',
635
+ 'Ẽ' => 'e',
636
+ 'ẽ' => 'e',
637
+ 'Ế' => 'e',
638
+ 'ế' => 'e',
639
+ 'Ề' => 'e',
640
+ 'ề' => 'e',
641
+ 'Ể' => 'e',
642
+ 'ể' => 'e',
643
+ 'Ễ' => 'e',
644
+ 'ễ' => 'e',
645
+ 'Ệ' => 'e',
646
+ 'ệ' => 'e',
647
+ 'Ọ' => 'o',
648
+ 'ọ' => 'o',
649
+ 'Ỏ' => 'o',
650
+ 'ỏ' => 'o',
651
+ 'Ố' => 'o',
652
+ 'ố' => 'o',
653
+ 'Ồ' => 'o',
654
+ 'ồ' => 'o',
655
+ 'Ổ' => 'o',
656
+ 'ổ' => 'o',
657
+ 'Ỗ' => 'o',
658
+ 'ỗ' => 'o',
659
+ 'Ộ' => 'o',
660
+ 'ộ' => 'o',
661
+ 'Ớ' => 'o',
662
+ 'ớ' => 'o',
663
+ 'Ờ' => 'o',
664
+ 'ờ' => 'o',
665
+ 'Ở' => 'o',
666
+ 'ở' => 'o',
667
+ 'Ỡ' => 'o',
668
+ 'ỡ' => 'o',
669
+ 'Ợ' => 'o',
670
+ 'ợ' => 'o',
671
+ 'Ụ' => 'u',
672
+ 'ụ' => 'u',
673
+ 'Ủ' => 'u',
674
+ 'ủ' => 'u',
675
+ 'Ứ' => 'u',
676
+ 'ứ' => 'u',
677
+ 'Ừ' => 'u',
678
+ 'ừ' => 'u',
679
+ 'Ử' => 'u',
680
+ 'ử' => 'u',
681
+ 'Ữ' => 'u',
682
+ 'ữ' => 'u',
683
+ 'Ự' => 'u',
684
+ 'ự' => 'u',
685
+ 'Ỳ' => 'y',
686
+ 'ỳ' => 'y',
687
+ 'Ỵ' => 'y',
688
+ 'ỵ' => 'y',
689
+ 'Ỷ' => 'y',
690
+ 'ỷ' => 'y',
691
+ 'Ỹ' => 'y',
692
+ 'ỹ' => 'y',
693
+ 'ₐ' => 'a',
694
+ 'ₑ' => 'e',
695
+ 'ₒ' => 'o',
696
+ 'ₓ' => 'x',
697
+ '℀' => 'ac',
698
+ '℁' => 'as',
699
+ 'ℂ' => 'c',
700
+ '℃' => 'c',
701
+ '℄' => 'c',
702
+ '℅' => 'co',
703
+ '℆' => 'cu',
704
+ '℉' => 'f',
705
+ 'ℊ' => 'g',
706
+ 'ℋ' => 'h',
707
+ 'ℌ' => 'h',
708
+ 'ℍ' => 'h',
709
+ 'ℎ' => 'h',
710
+ 'ℏ' => 'h',
711
+ 'ℕ' => 'n',
712
+ '℗' => 'p',
713
+ 'ℙ' => 'p',
714
+ 'ℚ' => 'q',
715
+ 'ℛ' => 'r',
716
+ 'ℜ' => 'r',
717
+ 'ℝ' => 'r',
718
+ '℞' => 'px',
719
+ '℟' => 'r',
720
+ '℠' => 'sm',
721
+ '℡' => 'tel',
722
+ '™' => 'tm',
723
+ 'ℤ' => 'z',
724
+ 'K' => 'k',
725
+ 'Å' => 'a',
726
+ 'ℬ' => 'b',
727
+ '℮' => 'e',
728
+ 'ℯ' => 'e',
729
+ '⒐' => '9',
730
+ '⒑' => '10',
731
+ '⒒' => '11',
732
+ '⒓' => '12',
733
+ '⒔' => '13',
734
+ '⒕' => '14',
735
+ '⒖' => '15',
736
+ '⒗' => '16',
737
+ '⒘' => '17',
738
+ '⒙' => '18',
739
+ '⒚' => '19',
740
+ '⒛' => '20',
741
+ '⒜' => 'a',
742
+ '⒝' => 'b',
743
+ '⒞' => 'c',
744
+ '⒟' => 'd',
745
+ '⒠' => 'e',
746
+ '⒡' => 'f',
747
+ '⒢' => 'g',
748
+ '⒣' => 'h',
749
+ '⒤' => 'i',
750
+ '⒥' => 'j',
751
+ '⒦' => 'k',
752
+ '⒧' => 'l',
753
+ '⒨' => 'm',
754
+ '⒩' => 'n',
755
+ '⒪' => 'o',
756
+ '⒫' => 'p',
757
+ '⒬' => 'q',
758
+ '⒭' => 'r',
759
+ '⒮' => 's',
760
+ '⒯' => 't',
761
+ '⒰' => 'u',
762
+ '⒱' => 'v',
763
+ '⒲' => 'w',
764
+ '⒳' => 'x',
765
+ '⒴' => 'y',
766
+ '⒵' => 'z',
767
+ 'Ⓐ' => 'a',
768
+ 'Ⓑ' => 'b',
769
+ 'Ⓒ' => 'c',
770
+ 'Ⓓ' => 'd',
771
+ 'Ⓔ' => 'e',
772
+ 'Ⓕ' => 'f',
773
+ 'Ⓖ' => 'g',
774
+ 'Ⓗ' => 'h',
775
+ 'Ⓘ' => 'i',
776
+ 'Ⓙ' => 'j',
777
+ 'Ⓚ' => 'k',
778
+ 'Ⓛ' => 'l',
779
+ 'Ⓜ' => 'm',
780
+ 'Ⓝ' => 'n',
781
+ 'Ⓞ' => 'o',
782
+ 'Ⓟ' => 'p',
783
+ 'Ⓠ' => 'q',
784
+ 'Ⓡ' => 'r',
785
+ 'Ⓢ' => 's',
786
+ 'Ⓣ' => 't',
787
+ 'Ⓤ' => 'u',
788
+ 'Ⓥ' => 'v',
789
+ 'Ⓦ' => 'w',
790
+ 'Ⓧ' => 'x',
791
+ 'Ⓨ' => 'y',
792
+ 'Ⓩ' => 'z',
793
+ 'ⓐ' => 'a',
794
+ 'ⓑ' => 'b',
795
+ 'ⓒ' => 'c',
796
+ 'ⓓ' => 'd',
797
+ 'ⓔ' => 'e',
798
+ 'ⓕ' => 'f',
799
+ 'ⓖ' => 'g',
800
+ 'ⓗ' => 'h',
801
+ 'ⓘ' => 'i',
802
+ 'ⓙ' => 'j',
803
+ 'ⓚ' => 'k',
804
+ 'ⓛ' => 'l',
805
+ 'ⓜ' => 'm',
806
+ 'ⓝ' => 'n',
807
+ 'ⓞ' => 'o',
808
+ 'ⓟ' => 'p',
809
+ 'ⓠ' => 'q',
810
+ 'ⓡ' => 'r',
811
+ 'ⓢ' => 's',
812
+ 'ⓣ' => 't',
813
+ 'ⓤ' => 'u',
814
+ 'ⓥ' => 'v',
815
+ 'ⓦ' => 'w',
816
+ 'ⓧ' => 'x',
817
+ 'ⓨ' => 'y',
818
+ 'ⓩ' => 'z',
819
+ '⓪' => '0',
820
+ 'ꜰ' => 'f',
821
+ 'ꜱ' => 's',
822
+ 'Ꜳ' => 'aa',
823
+ 'ꜳ' => 'aa',
824
+ 'Ꜵ' => 'ao',
825
+ 'ꜵ' => 'ao',
826
+ 'Ꜷ' => 'aj',
827
+ 'ꜷ' => 'aj',
828
+ 'Ꜹ' => 'av',
829
+ 'ꜹ' => 'av',
830
+ 'Ꜻ' => 'af',
831
+ 'ꜻ' => 'af',
832
+ 'Ꜽ' => 'af',
833
+ 'ꜽ' => 'af',
834
+ 'A' => 'a',
835
+ 'B' => 'b',
836
+ 'C' => 'c',
837
+ 'D' => 'd',
838
+ 'E' => 'e',
839
+ 'F' => 'f',
840
+ 'G' => 'g',
841
+ 'H' => 'h',
842
+ 'I' => 'i',
843
+ 'J' => 'j',
844
+ 'K' => 'k',
845
+ 'L' => 'l',
846
+ 'M' => 'm',
847
+ 'N' => 'n',
848
+ 'O' => 'o',
849
+ 'P' => 'p',
850
+ 'Q' => 'q',
851
+ 'R' => 'r',
852
+ 'S' => 's',
853
+ 'T' => 't',
854
+ 'U' => 'u',
855
+ 'V' => 'v',
856
+ 'W' => 'w',
857
+ 'X' => 'x',
858
+ 'Y' => 'y',
859
+ 'Z' => 'z',
860
+ '_' => '_',
861
+ 'a' => 'a',
862
+ 'b' => 'b',
863
+ 'c' => 'c',
864
+ 'd' => 'd',
865
+ 'e' => 'e',
866
+ 'f' => 'f',
867
+ 'g' => 'g',
868
+ 'h' => 'h',
869
+ 'i' => 'i',
870
+ 'j' => 'j',
871
+ 'k' => 'k',
872
+ 'l' => 'l',
873
+ 'm' => 'm',
874
+ 'n' => 'n',
875
+ 'o' => 'o',
876
+ 'p' => 'p',
877
+ 'q' => 'q',
878
+ 'r' => 'r',
879
+ 's' => 's',
880
+ 't' => 't',
881
+ 'u' => 'u',
882
+ 'v' => 'v',
883
+ 'w' => 'w',
884
+ 'x' => 'x',
885
+ 'y' => 'y',
886
+ 'z' => 'z',
887
+ '~' => '-',
888
+ 'ẞ' => 'b'
889
+ }
890
+
891
+ test_strings = {
892
+ 'ḡḡḡḡḡx' => 'gggggx'
893
+ }
894
+
895
+ describe Slugity do
896
+ include Slugity
897
+
898
+ describe "#slugity()" do
899
+ it "returns the correctly mapped character" do
900
+ test_characters.each do |input,output|
901
+ p "matching #{input}"
902
+ slugity( input ).should == output
903
+ end
904
+ end
905
+
906
+ it "correctly handles strings of characters" do
907
+ test_strings.each do |input,output|
908
+ slugity( input ).should == output
909
+ end
910
+ end
911
+ end
912
+ end
data/spec/slugity_spec.rb CHANGED
@@ -10,7 +10,9 @@ test_strings = {
10
10
  "Freddie & Bananas" => "freddie-and-bananas",
11
11
  "One + Two = Three" => "one-plus-two-equals-three",
12
12
  " hello world" => "hello-world",
13
- "hello world " => "hello-world"
13
+ "hello world " => "hello-world",
14
+ "post id 1234" => "post-id-1234",
15
+ "124 post id" => "124-post-id"
14
16
  }
15
17
 
16
18
  describe Slugity do
@@ -25,7 +27,7 @@ describe Slugity do
25
27
  end
26
28
 
27
29
  it "strips unrecognized characters" do
28
- slugity( "aëòúi".encode("UTF-8") ).should == "ai"
30
+ slugity( "a…‡†i".encode("UTF-8") ).should == "ai"
29
31
  end
30
32
  end
31
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slugity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,20 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-14 00:00:00.000000000 Z
12
+ date: 2013-03-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: ! ' Yet another slugging gem, this one makes sure you want to extend
15
- the String class instead of assuming. '
14
+ description: ! ' Yet another slugging gem, convert a string to a slug with the option
15
+ for custom mappings. '
16
16
  email: stevenosloan@gmail.com
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - lib/slugity/extend_string.rb
22
+ - lib/slugity/matchers/default.rb
22
23
  - lib/slugity/matchers.rb
23
24
  - lib/slugity/utilities.rb
24
25
  - lib/slugity/version.rb
25
26
  - lib/slugity.rb
27
+ - spec/accented_character_spec.rb
26
28
  - spec/slugity/matchers_spec.rb
27
29
  - spec/slugity/trim_string_spec.rb
28
30
  - spec/slugity_spec.rb
@@ -53,8 +55,10 @@ signing_key:
53
55
  specification_version: 3
54
56
  summary: Yet another slugging gem
55
57
  test_files:
58
+ - spec/accented_character_spec.rb
56
59
  - spec/slugity/matchers_spec.rb
57
60
  - spec/slugity/trim_string_spec.rb
58
61
  - spec/slugity_spec.rb
59
62
  - spec/spec_helper.rb
60
63
  - spec/string_spec.rb
64
+ has_rdoc: