characteristics 0.4.0 → 0.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/lib/characteristics.rb +3 -0
- data/lib/characteristics/ascii.rb +4 -0
- data/lib/characteristics/binary.rb +4 -0
- data/lib/characteristics/byte.rb +4 -0
- data/lib/characteristics/unicode.rb +38 -9
- data/lib/characteristics/version.rb +1 -1
- data/spec/characteristics_spec.rb +49 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc0c2818e9353a8bf2723c6c4bf52fdb4fe108e5
|
4
|
+
data.tar.gz: c83c50620d650bb3e41c84cdff744411a3eb31f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ffe39fb8ac396bbaa15cae35e02e087093f0b82b249b5361b37216f9928a7952762086c162c2549875c49792b795e7c7a157cbc9f86b51a0e3b6635ec808c1b
|
7
|
+
data.tar.gz: 828bf1f2542a448b0c8f67b96d9d2f76cbd5a2c70b4ab7f3aad2bada69be658ca743a4139d44db39c1fde7bea6542f2bba3fd02d709e52609105275077321870
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
## CHANGELOG
|
2
2
|
|
3
|
+
### 0.5.1
|
4
|
+
|
5
|
+
* (Proper version of gem on rubygems.org)
|
6
|
+
|
7
|
+
### 0.5.0
|
8
|
+
|
9
|
+
* Add bidi_control? property
|
10
|
+
* Treat NEL (in C1 area) as separator
|
11
|
+
* Treat RLM and LRM as blanks
|
12
|
+
* Treat CGJ as blank
|
13
|
+
|
3
14
|
### 0.4.0
|
4
15
|
|
5
16
|
* Support Japanese Emojis (KDDI / SoftBank / DoCoMo) for Unicode
|
data/Gemfile.lock
CHANGED
data/lib/characteristics.rb
CHANGED
data/lib/characteristics/byte.rb
CHANGED
@@ -7,6 +7,7 @@ class UnicodeCharacteristics < Characteristics
|
|
7
7
|
0x0009,
|
8
8
|
0x0020,
|
9
9
|
0x00AD,
|
10
|
+
0x034F,
|
10
11
|
0x061C,
|
11
12
|
0x070F,
|
12
13
|
0x115F,
|
@@ -29,6 +30,8 @@ class UnicodeCharacteristics < Characteristics
|
|
29
30
|
0x200B,
|
30
31
|
0x200C,
|
31
32
|
0x200D,
|
33
|
+
0x200E,
|
34
|
+
0x200F,
|
32
35
|
0x202F,
|
33
36
|
0x205F,
|
34
37
|
0x2060,
|
@@ -67,10 +70,26 @@ class UnicodeCharacteristics < Characteristics
|
|
67
70
|
0x000B,
|
68
71
|
0x000C,
|
69
72
|
0x000D,
|
73
|
+
0x0085,
|
70
74
|
0x2028,
|
71
75
|
0x2029,
|
72
76
|
].freeze
|
73
77
|
|
78
|
+
BIDI_CONTROL = [
|
79
|
+
0x061C,
|
80
|
+
0x200E,
|
81
|
+
0x200F,
|
82
|
+
0x202A,
|
83
|
+
0x202B,
|
84
|
+
0x202C,
|
85
|
+
0x202D,
|
86
|
+
0x202E,
|
87
|
+
0x2066,
|
88
|
+
0x2067,
|
89
|
+
0x2068,
|
90
|
+
0x2069,
|
91
|
+
].freeze
|
92
|
+
|
74
93
|
attr_reader :category
|
75
94
|
|
76
95
|
def initialize(char)
|
@@ -114,22 +133,32 @@ class UnicodeCharacteristics < Characteristics
|
|
114
133
|
@is_valid && @category == "Cf"
|
115
134
|
end
|
116
135
|
|
136
|
+
def bidi_control?
|
137
|
+
@is_valid && BIDI_CONTROL.include?(@ord)
|
138
|
+
end
|
139
|
+
|
117
140
|
def kddi?
|
118
|
-
|
119
|
-
|
141
|
+
@is_valid &&
|
142
|
+
encoding_has_kddi? &&
|
143
|
+
( @ord >= 0xE468 && @ord <= 0xE5DF ||
|
144
|
+
@ord >= 0xEA80 && @ord <= 0xEB8E )
|
120
145
|
end
|
121
146
|
|
122
147
|
def softbank?
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
148
|
+
@is_valid &&
|
149
|
+
encoding_has_softbank? &&
|
150
|
+
( @ord >= 0xE001 && @ord <= 0xE05A ||
|
151
|
+
@ord >= 0xE101 && @ord <= 0xE15A ||
|
152
|
+
@ord >= 0xE201 && @ord <= 0xE25A ||
|
153
|
+
@ord >= 0xE301 && @ord <= 0xE34D ||
|
154
|
+
@ord >= 0xE401 && @ord <= 0xE44C ||
|
155
|
+
@ord >= 0xE501 && @ord <= 0xE53E )
|
129
156
|
end
|
130
157
|
|
131
158
|
def docomo?
|
132
|
-
|
159
|
+
@is_valid &&
|
160
|
+
encoding_has_docomo? &&
|
161
|
+
( @ord >= 0xE63E && @ord <= 0xE757 )
|
133
162
|
end
|
134
163
|
|
135
164
|
private
|
@@ -22,6 +22,10 @@ describe Characteristics do
|
|
22
22
|
Characteristics.create(char.force_encoding(encoding)).format?
|
23
23
|
end
|
24
24
|
|
25
|
+
def bidi_control?(char)
|
26
|
+
Characteristics.create(char.force_encoding(encoding)).bidi_control?
|
27
|
+
end
|
28
|
+
|
25
29
|
describe UnicodeCharacteristics do
|
26
30
|
describe "UTF*" do
|
27
31
|
let(:encoding) { "UTF-8" }
|
@@ -52,6 +56,11 @@ describe Characteristics do
|
|
52
56
|
assert format? "\uFFF9"
|
53
57
|
refute format? "\x21"
|
54
58
|
end
|
59
|
+
|
60
|
+
it "is bidi_control or not" do
|
61
|
+
assert bidi_control? "\u202D"
|
62
|
+
refute bidi_control? "\x21"
|
63
|
+
end
|
55
64
|
end
|
56
65
|
|
57
66
|
describe "Japanese Emojis" do
|
@@ -101,6 +110,10 @@ describe Characteristics do
|
|
101
110
|
it "is never format" do
|
102
111
|
refute format? "\x21"
|
103
112
|
end
|
113
|
+
|
114
|
+
it "is never bidi_control" do
|
115
|
+
refute bidi_control? "\x21"
|
116
|
+
end
|
104
117
|
end
|
105
118
|
end
|
106
119
|
|
@@ -131,6 +144,10 @@ describe Characteristics do
|
|
131
144
|
it "is never format" do
|
132
145
|
refute format? "\x21"
|
133
146
|
end
|
147
|
+
|
148
|
+
it "is never bidi_control" do
|
149
|
+
refute bidi_control? "\x21"
|
150
|
+
end
|
134
151
|
end
|
135
152
|
end
|
136
153
|
|
@@ -163,6 +180,10 @@ describe Characteristics do
|
|
163
180
|
it "is never format" do
|
164
181
|
refute format? "\x21"
|
165
182
|
end
|
183
|
+
|
184
|
+
it "is never bidi_control" do
|
185
|
+
refute bidi_control? "\x21"
|
186
|
+
end
|
166
187
|
end
|
167
188
|
|
168
189
|
# TODO
|
@@ -209,6 +230,10 @@ describe Characteristics do
|
|
209
230
|
it "is never format" do
|
210
231
|
refute format? "\x21"
|
211
232
|
end
|
233
|
+
|
234
|
+
it "is never bidi_control" do
|
235
|
+
refute bidi_control? "\x21"
|
236
|
+
end
|
212
237
|
end
|
213
238
|
|
214
239
|
# TODO
|
@@ -249,6 +274,10 @@ describe Characteristics do
|
|
249
274
|
it "is never format" do
|
250
275
|
refute format? "\x21"
|
251
276
|
end
|
277
|
+
|
278
|
+
it "is never bidi_control" do
|
279
|
+
refute bidi_control? "\x21"
|
280
|
+
end
|
252
281
|
end
|
253
282
|
|
254
283
|
# describe "IBM437" do
|
@@ -294,6 +323,10 @@ describe Characteristics do
|
|
294
323
|
it "is never format" do
|
295
324
|
refute format? "\x21"
|
296
325
|
end
|
326
|
+
|
327
|
+
it "is never bidi_control" do
|
328
|
+
refute bidi_control? "\x21"
|
329
|
+
end
|
297
330
|
end
|
298
331
|
|
299
332
|
# describe "macCentEuro" do
|
@@ -333,6 +366,10 @@ describe Characteristics do
|
|
333
366
|
it "is never format" do
|
334
367
|
refute format? "\x21"
|
335
368
|
end
|
369
|
+
|
370
|
+
it "is never bidi_control" do
|
371
|
+
refute bidi_control? "\x21"
|
372
|
+
end
|
336
373
|
end
|
337
374
|
|
338
375
|
describe "Windows-874" do
|
@@ -360,6 +397,10 @@ describe Characteristics do
|
|
360
397
|
it "is never format" do
|
361
398
|
refute format? "\x21"
|
362
399
|
end
|
400
|
+
|
401
|
+
it "is never bidi_control" do
|
402
|
+
refute bidi_control? "\x21"
|
403
|
+
end
|
363
404
|
end
|
364
405
|
end
|
365
406
|
|
@@ -388,6 +429,10 @@ describe Characteristics do
|
|
388
429
|
it "is never format" do
|
389
430
|
refute format? "\x21"
|
390
431
|
end
|
432
|
+
|
433
|
+
it "is never bidi_control" do
|
434
|
+
refute bidi_control? "\x21"
|
435
|
+
end
|
391
436
|
end
|
392
437
|
|
393
438
|
describe "KOI8-U" do
|
@@ -414,6 +459,10 @@ describe Characteristics do
|
|
414
459
|
it "is never format" do
|
415
460
|
refute format? "\x21"
|
416
461
|
end
|
462
|
+
|
463
|
+
it "is never bidi_control" do
|
464
|
+
refute bidi_control? "\x21"
|
465
|
+
end
|
417
466
|
end
|
418
467
|
end
|
419
468
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: characteristics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode-categories
|