characteristics 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e75050c917591b71a2bec6839ba773ce8db0b0a5
4
- data.tar.gz: 932dbfc7d19c456d58d59403e8e4f79462f56373
3
+ metadata.gz: dc0c2818e9353a8bf2723c6c4bf52fdb4fe108e5
4
+ data.tar.gz: c83c50620d650bb3e41c84cdff744411a3eb31f2
5
5
  SHA512:
6
- metadata.gz: 492d9986683f98be2f0e268445ddecbc976a372d06854b1a2858b9556f9627ea149a2fd39866fe0ec6e0d062c715e20824eee95ba0c8e89f958e1d3964722ba0
7
- data.tar.gz: d7bd3e2ae36cd69be1693d617ba859ceb66c580f8dfb0d7bc719d089e140be749e7249f219c0bc2d3087daf071c3f64cdaaa9f08804868a42dd94be0e1e79cde
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- characteristics (0.4.0)
4
+ characteristics (0.5.1)
5
5
  unicode-categories (~> 1.1, >= 1.1.2)
6
6
 
7
7
  GEM
@@ -69,6 +69,9 @@ class Characteristics
69
69
  def format?
70
70
  end
71
71
 
72
+ def bidi_control?
73
+ end
74
+
72
75
  # private use emojis
73
76
  def kddi?
74
77
  end
@@ -49,4 +49,8 @@ class AsciiCharacteristics < Characteristics
49
49
  def format?
50
50
  false
51
51
  end
52
+
53
+ def bidi_control?
54
+ false
55
+ end
52
56
  end
@@ -50,4 +50,8 @@ class BinaryCharacteristics < Characteristics
50
50
  def format?
51
51
  false
52
52
  end
53
+
54
+ def bidi_control?
55
+ false
56
+ end
53
57
  end
@@ -187,6 +187,10 @@ class ByteCharacteristics < Characteristics
187
187
  FORMATS[@ord] =~ @encoding_name
188
188
  end
189
189
 
190
+ def bidi_control?
191
+ format?
192
+ end
193
+
190
194
  private
191
195
 
192
196
  def encoding_has_c1?
@@ -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
- encoding_has_kddi? && ( @ord >= 0xE468 && @ord <= 0xE5DF ||
119
- @ord >= 0xEA80 && @ord <= 0xEB8E )
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
- encoding_has_softbank? && ( @ord >= 0xE001 && @ord <= 0xE05A ||
124
- @ord >= 0xE101 && @ord <= 0xE15A ||
125
- @ord >= 0xE201 && @ord <= 0xE25A ||
126
- @ord >= 0xE301 && @ord <= 0xE34D ||
127
- @ord >= 0xE401 && @ord <= 0xE44C ||
128
- @ord >= 0xE501 && @ord <= 0xE53E )
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
- encoding_has_docomo? && ( @ord >= 0xE63E && @ord <= 0xE757 )
159
+ @is_valid &&
160
+ encoding_has_docomo? &&
161
+ ( @ord >= 0xE63E && @ord <= 0xE757 )
133
162
  end
134
163
 
135
164
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Characteristics
4
- VERSION = "0.4.0".freeze
4
+ VERSION = "0.5.1".freeze
5
5
  end
@@ -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.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-21 00:00:00.000000000 Z
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode-categories