symbolify 1.0.0 → 1.1.0

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: 9e0fa391ee606b11f9c99f4f33e9656f08692534
4
- data.tar.gz: df940cb466c10f7894ca7a582c1dd87c6998a8a7
3
+ metadata.gz: 86f1b09386497498d42a5bc13c1bd0eada8558e1
4
+ data.tar.gz: 40d18cd726a05c7b8374478dfef7fe1f0269b171
5
5
  SHA512:
6
- metadata.gz: f970bd71fb817eb2205f45f46b65cfdb6dbead36e302eccc2e15f6f138da921192744ba0800c77fcb379d3e9b3972b3727b3dcb49f9a9930f733ae944f46c1fb
7
- data.tar.gz: 73ca12130eafeab368588ea617a45c6cf4c1fc27a2d1a7f4439ab99bc8d1792f08175ae403a76c5304759cfd20e48a586eaf8ca506fe233266da9fa560ee99fa
6
+ metadata.gz: 5ad1e514f138cc49b80c4efb55d5fdfb1181d13a5f1c082f0b65eacdb980014f62c209d4cba852ee948cb75586638ed09e69664aad7f04f94090005c4783b825
7
+ data.tar.gz: 32296309c2cc61c305997c61cfc038a26f25c8d8480057ea6c9589adcb861bcefefe85e1685118c3d13f3509274c2767c99c6870f2479488025fdb631193e158
@@ -1,5 +1,11 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 1.1.0
4
+
5
+ * Add special characters (U+FFF9 - U+FFFC)
6
+ * Non-control separators return ⏎
7
+ * Ensure that only first character/codepoint will be returned
8
+
3
9
  ### 1.0.0
4
10
 
5
11
  * Import from unibits gem
data/README.md CHANGED
@@ -25,6 +25,8 @@ puts Symbolify.symbolify "\u{200F}" # RLM
25
25
  puts Symbolify.symbolify "\u{2067}" # RLI
26
26
  puts Symbolify.symbolify "\u{0300}" # ◌̀
27
27
  puts Symbolify.symbolify " " # ] [
28
+ puts Symbolify.symbolify "\u{FFF9}" # IAA
29
+ puts Symbolify.symbolify "\u{FFFC}" # OBJ
28
30
  puts Symbolify.symbolify "\u{E0020}" # TAG ␠
29
31
  puts Symbolify.symbolify "\u{E01D7}" # VS232
30
32
  puts Symbolify.symbolify "\u{E0000}" # n/a
@@ -96,6 +96,14 @@ module Symbolify
96
96
  0x2069 => "PDI",
97
97
  }.freeze
98
98
 
99
+ # no official aliases at the time of adding
100
+ SPECIALS = {
101
+ 0xFFF9 => "IAA",
102
+ 0xFFFA => "IAS",
103
+ 0xFFFB => "IAT",
104
+ 0xFFFC => "OBJ",
105
+ }.freeze
106
+
99
107
  TAG_NAMES = {
100
108
  0xE0001 => "LANG TAG",
101
109
  0xE0020 => "TAG ␠",
@@ -530,6 +538,7 @@ module Symbolify
530
538
 
531
539
  char = char.dup.encode("UTF-8")
532
540
  ord = char.ord
541
+ char = char[0]
533
542
 
534
543
  if char_info.delete?
535
544
  char = CONTROL_DELETE_SYMBOL
@@ -545,10 +554,14 @@ module Symbolify
545
554
  char = "◌" + char
546
555
  elsif char_info.category == "Me"
547
556
  char = " " + char
557
+ elsif char_info.separator?
558
+ char = "⏎"
548
559
  elsif char_info.blank?
549
560
  char = "]" + char + "["
550
561
  elsif TAG_NAMES.key?(ord)
551
562
  char = TAG_NAMES[ord]
563
+ elsif SPECIALS.key?(ord)
564
+ char = SPECIALS[ord]
552
565
  end
553
566
 
554
567
  char
@@ -559,6 +572,7 @@ module Symbolify
559
572
 
560
573
  ord = char.ord
561
574
  encoding = char_info.encoding
575
+ char = char[0]
562
576
  no_converter = !!(NO_UTF8_CONVERTER =~ encoding.name)
563
577
  treat_char_unconverted = false
564
578
 
@@ -588,6 +602,8 @@ module Symbolify
588
602
  end
589
603
 
590
604
  def self.ascii(char, char_info = AsciiCharacteristics.new(char))
605
+ char = char[0]
606
+
591
607
  if char_info.delete?
592
608
  char = CONTROL_DELETE_SYMBOL
593
609
  elsif char_info.c0?
@@ -600,10 +616,10 @@ module Symbolify
600
616
  end
601
617
 
602
618
  def self.binary(char, _ = nil)
603
- dump(char)
619
+ dump(char[0])
604
620
  end
605
621
 
606
622
  def self.dump(char)
607
- char.dump
623
+ char[0].dump
608
624
  end
609
625
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Symbolify
4
- VERSION = "1.0.0".freeze
4
+ VERSION = "1.1.0".freeze
5
5
  UNICODE_VERSION = "9.0.0".freeze
6
6
  end
7
7
 
@@ -6,6 +6,10 @@ describe Symbolify do
6
6
  it "will show replacement character for invalid characters" do
7
7
  assert_equal "�", Symbolify.symbolify("\x80")
8
8
  end
9
+
10
+ it "will only return first character" do
11
+ assert_equal "a", Symbolify.symbolify("ab")
12
+ end
9
13
  end
10
14
 
11
15
  describe ".unicode" do
@@ -37,10 +41,24 @@ describe Symbolify do
37
41
  assert_equal " \u{20E3}", Symbolify.symbolify("\u{20E3}")
38
42
  end
39
43
 
44
+ it "replaces uncommon newline characters" do
45
+ assert_equal "⏎", Symbolify.symbolify("\u{2028}")
46
+ assert_equal "⏎", Symbolify.symbolify("\u{2029}")
47
+ end
48
+
40
49
  it "wraps blanks" do
41
50
  assert_equal "] [", Symbolify.symbolify(" ")
42
51
  end
43
52
 
53
+ it "replaces annotation characters" do
54
+ assert_equal "IAA", Symbolify.symbolify("\u{FFF9}")
55
+ assert_equal "IAS", Symbolify.symbolify("\u{FFFA}")
56
+ end
57
+
58
+ it "replaces object replacement character" do
59
+ assert_equal "OBJ", Symbolify.symbolify("\u{FFFC}")
60
+ end
61
+
44
62
  it "replaces tags" do
45
63
  assert_equal "TAG ␠", Symbolify.symbolify("\u{E0020}")
46
64
  end
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.required_ruby_version = "~> 2.0"
21
- gem.add_dependency "characteristics", "~> 0.5"
21
+ gem.add_dependency "characteristics", "~> 0.6"
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symbolify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
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-25 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: characteristics
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.5'
26
+ version: '0.6'
27
27
  description: Safely print all codepoints from Unicode and single-byte encodings.
28
28
  email:
29
29
  - mail@janlelis.de