forkforge 0.0.3
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/.gitignore +19 -0
- data/.travis.yml +4 -0
- data/.yardopts +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +67 -0
- data/Rakefile +22 -0
- data/config/cucumber.yml +5 -0
- data/features/step_definitions/unicode_org_steps.rb +226 -0
- data/features/support/env.rb +24 -0
- data/features/unicode_org.feature +500 -0
- data/forkforge.gemspec +33 -0
- data/lib/forkforge/category.rb +165 -0
- data/lib/forkforge/dsl/handler.rb +28 -0
- data/lib/forkforge/internal/canonical_combining_classes.rb +66 -0
- data/lib/forkforge/internal/character_decomposition_mapping.rb +65 -0
- data/lib/forkforge/internal/code_point.rb +109 -0
- data/lib/forkforge/internal/monkeypatches.rb +45 -0
- data/lib/forkforge/internal/special_casing.rb +69 -0
- data/lib/forkforge/internal/unicode_data.rb +91 -0
- data/lib/forkforge/internal/unicode_org_file.rb +65 -0
- data/lib/forkforge/knife/string.rb +35 -0
- data/lib/forkforge/selector.rb +49 -0
- data/lib/forkforge/unicode.rb +84 -0
- data/lib/forkforge/version.rb +3 -0
- data/lib/forkforge.rb +9 -0
- data/media/ff-128.png +0 -0
- data/media/ff-16.png +0 -0
- data/media/ff-300.png +0 -0
- data/media/ff-32.png +0 -0
- data/media/ff-48.png +0 -0
- data/media/ff-64.png +0 -0
- data/media/ff.png +0 -0
- metadata +209 -0
@@ -0,0 +1,500 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Feature: UnicodeData.txt file is to be used locally until it’s absent
|
4
|
+
Scenario: Get all composed symbols
|
5
|
+
When we call all_character_decomposition_mapping on Forkforge::UnicodeData
|
6
|
+
Then the result count equals to 5721
|
7
|
+
|
8
|
+
###############################################################################
|
9
|
+
@camel
|
10
|
+
Scenario: Camel to underscore function works
|
11
|
+
Given we have a string "CamelCasedString"
|
12
|
+
When we call "camel_to_underscore" method on Forkforge::Unicode
|
13
|
+
Then the result is "camel_cased_string"
|
14
|
+
|
15
|
+
@camel
|
16
|
+
Scenario: Underscore to camel function works
|
17
|
+
Given we have a string "underscore_old_school_string"
|
18
|
+
When we call "underscore_to_camel" method on Forkforge::Unicode
|
19
|
+
Then the result is "UnderscoreOldSchoolString"
|
20
|
+
|
21
|
+
###############################################################################
|
22
|
+
|
23
|
+
@letter
|
24
|
+
Scenario: Get all specific letter: uppercase
|
25
|
+
When we call "uppercase" method on Forkforge::Letter
|
26
|
+
Then the result count equals to 1490
|
27
|
+
And the first item equals to "A"
|
28
|
+
|
29
|
+
@letter
|
30
|
+
Scenario: Get all specific letter: lowercase
|
31
|
+
When we call "lowercase" method on Forkforge::Letter
|
32
|
+
Then the result count equals to 1841
|
33
|
+
And the first item equals to "a"
|
34
|
+
|
35
|
+
@letter
|
36
|
+
Scenario: Get all specific letter: titlecase
|
37
|
+
When we call "titlecase" method on Forkforge::Letter
|
38
|
+
Then the result count equals to 31
|
39
|
+
And the first item equals to "Dž"
|
40
|
+
|
41
|
+
@letter
|
42
|
+
Scenario: Get all specific letter: modifier
|
43
|
+
When we call "modifier" method on Forkforge::Letter
|
44
|
+
Then the result count equals to 248
|
45
|
+
And the first item equals to "ʰ"
|
46
|
+
|
47
|
+
@letter
|
48
|
+
Scenario: Get all specific letter: others
|
49
|
+
When we call "other" method on Forkforge::Letter
|
50
|
+
Then the result count equals to 13350
|
51
|
+
And the first item equals to "ª"
|
52
|
+
|
53
|
+
@letter
|
54
|
+
Scenario: Get all codepoints for uppercased letters
|
55
|
+
When we call uppercase_code_point on Forkforge::Letter
|
56
|
+
Then we print first 10 results
|
57
|
+
|
58
|
+
###############################################################################
|
59
|
+
|
60
|
+
@mark
|
61
|
+
Scenario: Get all specific marks: non-spacing
|
62
|
+
When we call "non_spacing" method on Forkforge::Mark
|
63
|
+
Then the result count equals to 1418
|
64
|
+
And the first item equals to "̀"
|
65
|
+
|
66
|
+
@mark
|
67
|
+
Scenario: Get all specific marks: spacing combining
|
68
|
+
When we call "spacing_combining" method on Forkforge::Mark
|
69
|
+
Then the result count equals to 399
|
70
|
+
And the first item equals to "ः"
|
71
|
+
|
72
|
+
@mark
|
73
|
+
Scenario: Get all specific marks: enclosing
|
74
|
+
When we call "enclosing" method on Forkforge::Mark
|
75
|
+
Then the result count equals to 13
|
76
|
+
And the first item equals to "҈"
|
77
|
+
|
78
|
+
###############################################################################
|
79
|
+
|
80
|
+
@number
|
81
|
+
Scenario: Get all specific numbers: decimal digit
|
82
|
+
When we call "decimal_digit" method on Forkforge::Number
|
83
|
+
Then the result count equals to 540
|
84
|
+
And the first item equals to "0"
|
85
|
+
|
86
|
+
@number
|
87
|
+
Scenario: Get all specific numbers: letter
|
88
|
+
When we call "letter" method on Forkforge::Number
|
89
|
+
Then the result count equals to 236
|
90
|
+
And the first item equals to "ᛮ"
|
91
|
+
|
92
|
+
@number
|
93
|
+
Scenario: Get all specific numbers: other
|
94
|
+
When we call "other" method on Forkforge::Number
|
95
|
+
Then the result count equals to 570
|
96
|
+
And the first item equals to "²"
|
97
|
+
|
98
|
+
###############################################################################
|
99
|
+
|
100
|
+
@punctuation
|
101
|
+
Scenario: Get all specific punctuation: connectors
|
102
|
+
When we call "connector" method on Forkforge::Punctuation
|
103
|
+
Then the result count equals to 10
|
104
|
+
And the first item equals to "_"
|
105
|
+
|
106
|
+
@punctuation
|
107
|
+
Scenario: Get all specific punctuation: dashes
|
108
|
+
When we call "dash" method on Forkforge::Punctuation
|
109
|
+
Then the result count equals to 24
|
110
|
+
And the first item equals to "-"
|
111
|
+
|
112
|
+
@punctuation
|
113
|
+
Scenario: Get all specific punctuation: opens
|
114
|
+
When we call "open" method on Forkforge::Punctuation
|
115
|
+
Then the result count equals to 75
|
116
|
+
And the first item equals to "("
|
117
|
+
|
118
|
+
@punctuation
|
119
|
+
Scenario: Get all specific punctuation: closes
|
120
|
+
When we call "close" method on Forkforge::Punctuation
|
121
|
+
Then the result count equals to 73
|
122
|
+
And the first item equals to ")"
|
123
|
+
|
124
|
+
@punctuation
|
125
|
+
Scenario: Get all specific punctuation: initial_quotes
|
126
|
+
When we call "initial_quote" method on Forkforge::Punctuation
|
127
|
+
Then the result count equals to 12
|
128
|
+
And the first item equals to "«"
|
129
|
+
|
130
|
+
@punctuation
|
131
|
+
Scenario: Get all specific punctuation: final_quotes
|
132
|
+
When we call "final_quote" method on Forkforge::Punctuation
|
133
|
+
Then the result count equals to 10
|
134
|
+
And the first item equals to "»"
|
135
|
+
|
136
|
+
@punctuation
|
137
|
+
Scenario: Get all specific punctuation: others
|
138
|
+
When we call "other" method on Forkforge::Punctuation
|
139
|
+
Then the result count equals to 484
|
140
|
+
And the first item equals to "!"
|
141
|
+
|
142
|
+
###############################################################################
|
143
|
+
|
144
|
+
@symbol
|
145
|
+
Scenario: Get all specific symbols: math
|
146
|
+
When we call "math" method on Forkforge::Symbol
|
147
|
+
Then the result count equals to 948
|
148
|
+
And the first item equals to "+"
|
149
|
+
|
150
|
+
@symbol
|
151
|
+
Scenario: Get all specific symbols: currency
|
152
|
+
When we call "currency" method on Forkforge::Symbol
|
153
|
+
Then the result count equals to 52
|
154
|
+
And the first item equals to "$"
|
155
|
+
|
156
|
+
@symbol
|
157
|
+
Scenario: Get all specific symbols: modifier
|
158
|
+
When we call "modifier" method on Forkforge::Symbol
|
159
|
+
Then the result count equals to 116
|
160
|
+
And the first item equals to "^"
|
161
|
+
|
162
|
+
@symbol
|
163
|
+
Scenario: Get all specific symbols: other
|
164
|
+
When we call "other" method on Forkforge::Symbol
|
165
|
+
Then the result count equals to 5082
|
166
|
+
And the first item equals to "¦"
|
167
|
+
|
168
|
+
###############################################################################
|
169
|
+
|
170
|
+
@separator
|
171
|
+
Scenario: Get all specific separators: space
|
172
|
+
When we call "space" method on Forkforge::Separator
|
173
|
+
Then the result count equals to 17
|
174
|
+
And the first item equals to " "
|
175
|
+
|
176
|
+
@separator
|
177
|
+
Scenario: Get all specific separators: line
|
178
|
+
When we call "line" method on Forkforge::Separator
|
179
|
+
Then the result count equals to 1
|
180
|
+
And we print results
|
181
|
+
|
182
|
+
@separator
|
183
|
+
Scenario: Get all specific separators: paragraph
|
184
|
+
When we call "paragraph" method on Forkforge::Separator
|
185
|
+
Then the result count equals to 1
|
186
|
+
And we print results
|
187
|
+
|
188
|
+
###############################################################################
|
189
|
+
|
190
|
+
@other
|
191
|
+
Scenario: Get all specific others: control
|
192
|
+
When we call "control" method on Forkforge::Other
|
193
|
+
Then the result count equals to 65
|
194
|
+
|
195
|
+
@other
|
196
|
+
Scenario: Get all specific others: format
|
197
|
+
When we call "format" method on Forkforge::Other
|
198
|
+
Then the result count equals to 150
|
199
|
+
And the first item equals to ""
|
200
|
+
|
201
|
+
@other
|
202
|
+
Scenario: Get all specific others: surrogate
|
203
|
+
When we call "surrogate" method on Forkforge::Other
|
204
|
+
Then the result count equals to 6
|
205
|
+
And we print results
|
206
|
+
|
207
|
+
@other
|
208
|
+
Scenario: Get all specific others: private use
|
209
|
+
When we call "private_use" method on Forkforge::Other
|
210
|
+
Then the result count equals to 6
|
211
|
+
And we print results
|
212
|
+
|
213
|
+
@other
|
214
|
+
Scenario: Get all specific others: not assigned
|
215
|
+
When we call "not_assigned" method on Forkforge::Other
|
216
|
+
Then the result count equals to 0
|
217
|
+
|
218
|
+
###############################################################################
|
219
|
+
|
220
|
+
@punctuation @connector
|
221
|
+
Scenario: Get all connectors with their names
|
222
|
+
When we call "connector_character_name" method on Forkforge::Punctuation
|
223
|
+
Then the result count equals to 10
|
224
|
+
And the first item’s value equals to "LOW LINE"
|
225
|
+
|
226
|
+
@punctuation @connector
|
227
|
+
Scenario: Get all dashes with their names
|
228
|
+
When we call "dash_character_name" method on Forkforge::Punctuation
|
229
|
+
Then the result count equals to 24
|
230
|
+
And the first item’s value equals to "HYPHEN-MINUS"
|
231
|
+
|
232
|
+
###############################################################################
|
233
|
+
|
234
|
+
@languages
|
235
|
+
Scenario: Upcase function works properly on cyrillics
|
236
|
+
Given we have a cyrillic string "МАМА мыла РАМУ"
|
237
|
+
When the string is upcased
|
238
|
+
Then the result is "МАМА МЫЛА РАМУ"
|
239
|
+
|
240
|
+
# titlecase titleize every funcking letter!!
|
241
|
+
@languages
|
242
|
+
Scenario: Titlecase function works properly on cyrillics
|
243
|
+
Given we have a cyrillic string "МАМА мыла РАМУ"
|
244
|
+
When the string is titlecased
|
245
|
+
Then the result is "МАМА МЫЛА РАМУ"
|
246
|
+
|
247
|
+
@languages
|
248
|
+
Scenario: Downcase function works properly on cyrillics
|
249
|
+
Given we have a cyrillic string "МАМА мыла РАМУ"
|
250
|
+
When the string is downcased
|
251
|
+
Then the result is "мама мыла раму"
|
252
|
+
|
253
|
+
@languages
|
254
|
+
Scenario: Upcase function works properly on combined
|
255
|
+
Given we have a cyrillic string "naïve Álto Pàlo"
|
256
|
+
When the string is upcased
|
257
|
+
Then the result is "NAÏVE ÁLTO PÀLO"
|
258
|
+
|
259
|
+
@languages
|
260
|
+
Scenario: Upcase function works properly with Turkic (CAPITAL I WITH DOT)
|
261
|
+
Given we have a string "naïve istanbul"
|
262
|
+
When the string is upcased with language set to "tr"
|
263
|
+
Then the result is "NAİ̈VE İSTANBUL"
|
264
|
+
|
265
|
+
@languages
|
266
|
+
Scenario: Upcase function works properly with generic (CAPITAL I WITHOUT DOT)
|
267
|
+
Given we have a string "naïve istanbul"
|
268
|
+
When the string is upcased with language set to ""
|
269
|
+
Then the result is "NAÏVE ISTANBUL"
|
270
|
+
|
271
|
+
@languages
|
272
|
+
Scenario: Downcase function works properly with generic (SMALL I WITH DOT)
|
273
|
+
Given we have a string "NAÏVE ISTANBUL"
|
274
|
+
When the string is downcased with language set to ""
|
275
|
+
Then the result is "naïve istanbul"
|
276
|
+
|
277
|
+
@languages
|
278
|
+
Scenario: Print out known conditions
|
279
|
+
When we ask to print known conditions
|
280
|
+
Then we print results
|
281
|
+
|
282
|
+
###############################################################################
|
283
|
+
|
284
|
+
@lookup
|
285
|
+
Scenario: Lookup symbols by name
|
286
|
+
Given we have a pattern "RiNg AbOvE"
|
287
|
+
When lookup is done with this pattern
|
288
|
+
Then we print results
|
289
|
+
|
290
|
+
@lookup
|
291
|
+
Scenario: Lookup symbols by name
|
292
|
+
Given we have a pattern "RING ABOVE"
|
293
|
+
When lookup using all_character_name is done with this pattern
|
294
|
+
Then we print first 2 results
|
295
|
+
|
296
|
+
@lookup
|
297
|
+
Scenario: Lookup symbols with tagged character_name
|
298
|
+
Given we have a pattern looking like a tag
|
299
|
+
When lookup using all_character_name is done with this pattern
|
300
|
+
Then we print first 1 results
|
301
|
+
|
302
|
+
@lookup
|
303
|
+
Scenario: Lookup tag names using character_name
|
304
|
+
Given we have a pattern looking like a tag
|
305
|
+
When result is filtered to show tags
|
306
|
+
Then the result count equals to 25
|
307
|
+
And we print first 21 results
|
308
|
+
|
309
|
+
@lookup
|
310
|
+
Scenario: Lookup tags using character_name
|
311
|
+
Given we have a pattern looking like a tag
|
312
|
+
When result is filtered to show tagged characters
|
313
|
+
Then the result count equals to 25
|
314
|
+
And the result’s first element nested count is "65"
|
315
|
+
|
316
|
+
@lookup
|
317
|
+
Scenario: Lookup tags using meta method
|
318
|
+
Given we have a pattern looking like a tag
|
319
|
+
When result is set to response from "control" function call
|
320
|
+
Then the result count equals to 65
|
321
|
+
And we print first 1 results
|
322
|
+
|
323
|
+
@lookup
|
324
|
+
Scenario: Print info on symbol
|
325
|
+
Given we have a symbol "〷"
|
326
|
+
When we retrieve it’s info
|
327
|
+
Then we print results
|
328
|
+
And the result is "IDEOGRAPHIC TELEGRAPH LINE FEED SEPARATOR SYMBOL"
|
329
|
+
|
330
|
+
@lookup
|
331
|
+
Scenario: Print info on symbol on it’s codebase
|
332
|
+
Given we have a symbol with codebase "0x3037"
|
333
|
+
When we retrieve it’s info
|
334
|
+
Then we print results
|
335
|
+
And the result is "IDEOGRAPHIC TELEGRAPH LINE FEED SEPARATOR SYMBOL"
|
336
|
+
|
337
|
+
###############################################################################
|
338
|
+
|
339
|
+
@tag
|
340
|
+
Scenario: Tag class accepts strings with tag delimiters properly
|
341
|
+
Given we have a string "<font>"
|
342
|
+
When we construct Tag object against it
|
343
|
+
Then both sym and tag have correct values
|
344
|
+
|
345
|
+
@tag
|
346
|
+
Scenario: Tag class accepts strings without tag delimiters properly
|
347
|
+
Given we have a string "font"
|
348
|
+
When we construct Tag object against it
|
349
|
+
Then both sym and tag have correct values
|
350
|
+
|
351
|
+
@tag
|
352
|
+
Scenario: Tag class rejects strings with improper tags
|
353
|
+
Given we have a string "ghgh"
|
354
|
+
When we construct Tag object against it
|
355
|
+
Then both sym and tag have nil values
|
356
|
+
|
357
|
+
@tag
|
358
|
+
Scenario: Decompose symbols
|
359
|
+
Given we have a string "Barçelona Niños"
|
360
|
+
When we decompose it
|
361
|
+
Then we print results
|
362
|
+
And the result is "Barçelona Niños"
|
363
|
+
|
364
|
+
@tag
|
365
|
+
Scenario: Decompose symbols with <font>
|
366
|
+
Given we have a string "ℂool"
|
367
|
+
When we decompose it
|
368
|
+
Then we print results
|
369
|
+
And the result is "Cool"
|
370
|
+
|
371
|
+
@tag
|
372
|
+
Scenario: Decompose symbols with <font>
|
373
|
+
Given we have a string "ℂool"
|
374
|
+
When we decompose it with circle tag only
|
375
|
+
Then we print results
|
376
|
+
And the result is "ℂool"
|
377
|
+
|
378
|
+
@tag
|
379
|
+
Scenario: Add custom decomposition symbols
|
380
|
+
Given we have a string "Мáма"
|
381
|
+
When we add custom decomposition rule
|
382
|
+
And we decompose it
|
383
|
+
Then we print results
|
384
|
+
|
385
|
+
###############################################################################
|
386
|
+
|
387
|
+
@compose
|
388
|
+
Scenario: Composing digit with circle
|
389
|
+
Given we have a string "1"
|
390
|
+
When we compose input to "circle"
|
391
|
+
Then the result is "①"
|
392
|
+
And we print results
|
393
|
+
|
394
|
+
@compose
|
395
|
+
Scenario: Composing letter with font
|
396
|
+
Given we have a string "a"
|
397
|
+
When we compose input to "font"
|
398
|
+
Then the result is "𝐚,𝑎,𝒂,𝒶,𝓪,𝔞,𝕒,𝖆,𝖺,𝗮,𝘢,𝙖,𝚊"
|
399
|
+
And we print results
|
400
|
+
|
401
|
+
@compose
|
402
|
+
Scenario: Composing letter with wide
|
403
|
+
Given we have a string "a"
|
404
|
+
When we compose input to "wide"
|
405
|
+
Then the result is "a"
|
406
|
+
And we print results
|
407
|
+
|
408
|
+
@compose
|
409
|
+
Scenario: Composing letter with super
|
410
|
+
Given we have a string "a"
|
411
|
+
When we compose input to "super"
|
412
|
+
Then we print results
|
413
|
+
And the result is "ª,ᵃ"
|
414
|
+
|
415
|
+
@compose
|
416
|
+
Scenario: Composing letter with sub
|
417
|
+
Given we have a string "a"
|
418
|
+
When we compose input to "sub"
|
419
|
+
Then we print results
|
420
|
+
And the result is "ₐ"
|
421
|
+
|
422
|
+
@compose
|
423
|
+
Scenario: Composing letter with vertical
|
424
|
+
Given we have a string "?"
|
425
|
+
When we compose input to "vertical"
|
426
|
+
Then we print results
|
427
|
+
And the result is "︖"
|
428
|
+
|
429
|
+
@compose
|
430
|
+
Scenario: Composing letter with small
|
431
|
+
Given we have a string "?"
|
432
|
+
When we compose input to "small"
|
433
|
+
Then we print results
|
434
|
+
And the result is "﹖"
|
435
|
+
|
436
|
+
@compose
|
437
|
+
Scenario: Composing letter with compat
|
438
|
+
Given we have a string "µ"
|
439
|
+
When we compose input to "compat"
|
440
|
+
Then we print results
|
441
|
+
And the result is "µ"
|
442
|
+
|
443
|
+
###############################################################################
|
444
|
+
|
445
|
+
@compose @complex
|
446
|
+
Scenario: Composing text with wide
|
447
|
+
Given we have a string "Hola, Barçelona!"
|
448
|
+
When we compose input to "wide"
|
449
|
+
Then we print results
|
450
|
+
And the result is "H,o,l,a,,, ,B,a,r,ç,e,l,o,n,a,!"
|
451
|
+
|
452
|
+
@compose @complex
|
453
|
+
Scenario: Composing text with wide (direct call)
|
454
|
+
Given we have a string "Hola, Barçelona!"
|
455
|
+
When we widify input
|
456
|
+
Then we print results
|
457
|
+
And the result is "Hola, Barçelona!"
|
458
|
+
|
459
|
+
@compose @complex
|
460
|
+
Scenario: Composing text with circle (direct call)
|
461
|
+
Given we have a string "Hola, Barçelona!"
|
462
|
+
When we circlefy input
|
463
|
+
Then we print results
|
464
|
+
And the result is "Ⓗⓞⓛⓐ, Ⓑⓐⓡⓒ̧ⓔⓛⓞⓝⓐ!"
|
465
|
+
|
466
|
+
###############################################################################
|
467
|
+
|
468
|
+
@lookup @complex
|
469
|
+
Scenario: Code points method missing works on latin letters
|
470
|
+
When we call "math" method on Forkforge::CodePoints for "b"
|
471
|
+
Then we print results
|
472
|
+
And the result to string is "𝐛𝑏𝒃𝒷𝓫𝔟𝕓𝖇𝖻𝗯𝘣𝙗𝚋"
|
473
|
+
|
474
|
+
@lookup @complex
|
475
|
+
Scenario: Code points method missing works on strings
|
476
|
+
When we call "math" method on Forkforge::CodePoints for "abc"
|
477
|
+
Then we print results
|
478
|
+
And the result to string is "𝐚𝐛𝐜𝑎𝑏𝑐𝒂𝒃𝒄𝒶𝒷𝒸𝓪𝓫𝓬𝔞𝔟𝔠𝕒𝕓𝕔𝖆𝖇𝖈𝖺𝖻𝖼𝗮𝗯𝗰𝘢𝘣𝘤𝙖𝙗𝙘𝚊𝚋𝚌"
|
479
|
+
|
480
|
+
@lookup @complex
|
481
|
+
Scenario: Code points method missing chained works on strings
|
482
|
+
When we call "math_fraktur_bold" method on Forkforge::CodePoints for "abc"
|
483
|
+
Then we print results
|
484
|
+
And the result to string is "𝖆𝖇𝖈"
|
485
|
+
|
486
|
+
###############################################################################
|
487
|
+
|
488
|
+
@monkey
|
489
|
+
Scenario: String monkeypatches (wide)
|
490
|
+
Given we have a string "CamelCasedString"
|
491
|
+
When the string is directly widefied
|
492
|
+
Then the result is "CamelCasedString"
|
493
|
+
|
494
|
+
@monkey
|
495
|
+
Scenario: String monkeypatches (upcase on cyrillics)
|
496
|
+
Given we have a string "МАМА мыла РАМУ"
|
497
|
+
When the string is directly upcased
|
498
|
+
Then the result is "МАМА МЫЛА РАМУ"
|
499
|
+
|
500
|
+
###############################################################################
|
data/forkforge.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'forkforge/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "forkforge"
|
8
|
+
spec.version = Forkforge::VERSION
|
9
|
+
spec.authors = ["Alexei Matyushkin"]
|
10
|
+
spec.email = ["am@mudasobwa.ru"]
|
11
|
+
spec.summary = %q{Unicode handling library}
|
12
|
+
spec.description = %Q{
|
13
|
+
Pure ruby implementation of Unicode manipulations as by Consortium.
|
14
|
+
Includes: languages-specific uppercase/lowercase, composition, decomposition and more.
|
15
|
+
}
|
16
|
+
spec.homepage = "http://forkforge.com"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0")
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake", '~> 0'
|
26
|
+
spec.add_development_dependency "pry", '~> 0'
|
27
|
+
spec.add_development_dependency "pry-rescue", '~> 0'
|
28
|
+
spec.add_development_dependency "awesome_print", '~> 0'
|
29
|
+
spec.add_development_dependency "rspec", '~> 0'
|
30
|
+
spec.add_development_dependency 'yard', '~> 0'
|
31
|
+
spec.add_development_dependency 'cucumber', '~> 0'
|
32
|
+
spec.add_development_dependency 'yard-cucumber', '~> 0'
|
33
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'forkforge/internal/code_point'
|
4
|
+
require 'forkforge/internal/unicode_data'
|
5
|
+
|
6
|
+
module Forkforge
|
7
|
+
module Category
|
8
|
+
# Letter::all_raw | Letter::uppercase_raw | Letter::uppercase 'Alexei' # ⇒ 'A'
|
9
|
+
# Letter::uppercase_code_point | Mark::non_spacing_bidirectional_category
|
10
|
+
def self.included base
|
11
|
+
base.const_get(:TYPES).each { |type|
|
12
|
+
base.class_eval %Q{
|
13
|
+
def #{type.last}_raw
|
14
|
+
@@#{type.last} ||= Forkforge::UnicodeData::all_general_category /#{type.first}/
|
15
|
+
end
|
16
|
+
def is_#{type.last} s
|
17
|
+
UnicodeData::infos(s).inject(true) { |memo, kv|
|
18
|
+
memo &&= kv[:general_category] == "#{type.first}"
|
19
|
+
}
|
20
|
+
end
|
21
|
+
def #{type.last} s = nil
|
22
|
+
@@#{type.last}_array ||= #{type.last}_raw.map { |k, v| Forkforge::UnicodeData::to_char k }
|
23
|
+
s.respond_to?(:scan) ? s.scan(Regexp.new(@@#{type.last}_array.join '|')) : @@#{type.last}_array
|
24
|
+
end
|
25
|
+
}
|
26
|
+
CodePoint::UNICODE_FIELDS.each { |method|
|
27
|
+
base.class_eval %Q{
|
28
|
+
def #{type.last}_#{method}
|
29
|
+
@@#{type.last}_#{method} ||= #{type.last}_raw.map { |k, v|
|
30
|
+
[ Forkforge::UnicodeData::to_char(k), Forkforge::UnicodeData::get_#{method}(k) ]
|
31
|
+
}.to_h
|
32
|
+
end
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
base.extend base
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
=begin
|
41
|
+
Lu Letter, Uppercase
|
42
|
+
Ll Letter, Lowercase
|
43
|
+
Lt Letter, Titlecase
|
44
|
+
Lm Letter, Modifier
|
45
|
+
Lo Letter, Other
|
46
|
+
LC Letter, Cased (combining)
|
47
|
+
=end
|
48
|
+
module Letter
|
49
|
+
TYPES = [
|
50
|
+
['L.?', :all],
|
51
|
+
['Lu', :uppercase],
|
52
|
+
['Ll', :lowercase],
|
53
|
+
['Lt', :titlecase],
|
54
|
+
['Lm', :modifier],
|
55
|
+
['Lo', :other],
|
56
|
+
['L[Cult]', :cased]
|
57
|
+
]
|
58
|
+
include Forkforge::Category
|
59
|
+
end
|
60
|
+
|
61
|
+
=begin
|
62
|
+
Mn Mark, Non-Spacing
|
63
|
+
Mc Mark, Spacing Combining
|
64
|
+
Me Mark, Enclosing
|
65
|
+
=end
|
66
|
+
module Mark
|
67
|
+
TYPES = [
|
68
|
+
['M.?', :all],
|
69
|
+
['Mn', :non_spacing],
|
70
|
+
['Mc', :spacing_combining],
|
71
|
+
['Me', :enclosing]
|
72
|
+
]
|
73
|
+
include Forkforge::Category
|
74
|
+
end
|
75
|
+
|
76
|
+
=begin
|
77
|
+
Nd Number, Decimal Digit
|
78
|
+
Nl Number, Letter
|
79
|
+
No Number, Other
|
80
|
+
=end
|
81
|
+
module Number
|
82
|
+
TYPES = [
|
83
|
+
['N.?', :all],
|
84
|
+
['Nd', :decimal_digit],
|
85
|
+
['Nl', :letter],
|
86
|
+
['No', :other]
|
87
|
+
]
|
88
|
+
include Forkforge::Category
|
89
|
+
end
|
90
|
+
|
91
|
+
=begin
|
92
|
+
Pc Punctuation, Connector
|
93
|
+
Pd Punctuation, Dash
|
94
|
+
Ps Punctuation, Open
|
95
|
+
Pe Punctuation, Close
|
96
|
+
Pi Punctuation, Initial quote (may behave like Ps or Pe depending on usage)
|
97
|
+
Pf Punctuation, Final quote (may behave like Ps or Pe depending on usage)
|
98
|
+
Po Punctuation, Other
|
99
|
+
=end
|
100
|
+
module Punctuation
|
101
|
+
TYPES = [
|
102
|
+
['P.?', :all],
|
103
|
+
['Pc', :connector],
|
104
|
+
['Pd', :dash],
|
105
|
+
['Ps', :open],
|
106
|
+
['Pe', :close],
|
107
|
+
['Pi', :initial_quote], # (may behave like Ps or Pe depending on usage)
|
108
|
+
['Pf', :final_quote], # (may behave like Ps or Pe depending on usage)
|
109
|
+
['Po', :other]
|
110
|
+
]
|
111
|
+
include Forkforge::Category
|
112
|
+
end
|
113
|
+
|
114
|
+
=begin
|
115
|
+
Sm Symbol, Math
|
116
|
+
Sc Symbol, Currency
|
117
|
+
Sk Symbol, Modifier
|
118
|
+
So Symbol, Other
|
119
|
+
=end
|
120
|
+
module Symbol
|
121
|
+
TYPES = [
|
122
|
+
['S.?', :all],
|
123
|
+
['Sm', :math],
|
124
|
+
['Sc', :currency],
|
125
|
+
['Sk', :modifier],
|
126
|
+
['So', :other]
|
127
|
+
]
|
128
|
+
include Forkforge::Category
|
129
|
+
end
|
130
|
+
|
131
|
+
=begin
|
132
|
+
Zs Separator, Space
|
133
|
+
Zl Separator, Line
|
134
|
+
Zp Separator, Paragraph
|
135
|
+
=end
|
136
|
+
module Separator
|
137
|
+
TYPES = [
|
138
|
+
['Z.?', :all],
|
139
|
+
['Zs', :space],
|
140
|
+
['Zl', :line],
|
141
|
+
['Zp', :paragraph]
|
142
|
+
]
|
143
|
+
include Forkforge::Category
|
144
|
+
end
|
145
|
+
|
146
|
+
=begin
|
147
|
+
Cc Other, Control
|
148
|
+
Cf Other, Format
|
149
|
+
Cs Other, Surrogate
|
150
|
+
Co Other, Private Use
|
151
|
+
Cn Other, Not Assigned (no characters in the file have this property)
|
152
|
+
=end
|
153
|
+
module Other
|
154
|
+
TYPES = [
|
155
|
+
['C.?', :all],
|
156
|
+
['Cc', :control],
|
157
|
+
['Cf', :format],
|
158
|
+
['Cs', :surrogate],
|
159
|
+
['Co', :private_use],
|
160
|
+
['Cn', :not_assigned] # no characters in the file have this property
|
161
|
+
]
|
162
|
+
include Forkforge::Category
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|