symbolify 1.0.0 → 1.4.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
- SHA1:
3
- metadata.gz: 9e0fa391ee606b11f9c99f4f33e9656f08692534
4
- data.tar.gz: df940cb466c10f7894ca7a582c1dd87c6998a8a7
2
+ SHA256:
3
+ metadata.gz: 87aefbff8db0ef735451e2b96377deccf20dd51e0b68194b1f8e2ccd697c1eb8
4
+ data.tar.gz: a3241b2b275b3cf7e38fdc5dc1631559b570713b87002348aa7675caa36d25c8
5
5
  SHA512:
6
- metadata.gz: f970bd71fb817eb2205f45f46b65cfdb6dbead36e302eccc2e15f6f138da921192744ba0800c77fcb379d3e9b3972b3727b3dcb49f9a9930f733ae944f46c1fb
7
- data.tar.gz: 73ca12130eafeab368588ea617a45c6cf4c1fc27a2d1a7f4439ab99bc8d1792f08175ae403a76c5304759cfd20e48a586eaf8ca506fe233266da9fa560ee99fa
6
+ metadata.gz: 95e7ad65bd12f59006d87d64bfe7ba0fb13e9cf3083375b796b670c174f68db4ac63e73d88ca5ecaa6780b52f0a53ff0663f1454423deaeff95f40053530c23f
7
+ data.tar.gz: 2ba80318dd0623e4cf78a35c84d6991873834b4d7e62013c24f468392870d5bf6f24e9edfa7cc282d6be0c5106204e606ca5c2690e2bbdbc8b6f05b6b6342192
@@ -1,5 +1,30 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 1.4.0
4
+
5
+ * Relax Ruby version requirement to allow Ruby 3.0
6
+ * Remove UNICODE_VERSION constant since it only mirrors the one
7
+ of the unicode-categories gem
8
+
9
+ ### 1.3.1
10
+
11
+ * Allow version of characteristics dependency to 1.x
12
+
13
+ ### 1.3.0
14
+
15
+ * Unicode 10 general categories
16
+
17
+ ### 1.2.0
18
+
19
+ * Return "n/a*" for unassigned codepoints which are ignorable
20
+ * Change "TAG ␡" to "TAG ✦"
21
+
22
+ ### 1.1.0
23
+
24
+ * Add special characters (U+FFF9 - U+FFFC)
25
+ * Non-control separators return ⏎
26
+ * Ensure that only first character/codepoint will be returned
27
+
3
28
  ### 1.0.0
4
29
 
5
30
  * Import from unibits gem
data/Gemfile CHANGED
@@ -3,3 +3,4 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'minitest'
6
+ gem 'rake'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017 Jan Lelis, mail@janlelis.de
1
+ Copyright (c) 2017-2020 Jan Lelis, https://janlelis.com
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Symbolify [![[version]](https://badge.fury.io/rb/symbolify.svg)](http://badge.fury.io/rb/symbolify) [![[travis]](https://travis-ci.org/janlelis/symbolify.svg)](https://travis-ci.org/janlelis/symbolify)
1
+ # Symbolify [![[version]](https://badge.fury.io/rb/symbolify.svg)](https://badge.fury.io/rb/symbolify) [![[ci]](https://github.com/janlelis/symbolify/workflows/Test/badge.svg)](https://github.com/janlelis/symbolify/actions?query=workflow%3ATest)
2
2
 
3
3
  Safely print all codepoints from Unicode and single-byte encodings in UTF-8. It replaces control and non-printable characters with readable equivalents and wraps most blank characters in `]` and `[`.
4
4
 
@@ -25,13 +25,16 @@ 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
- puts Symbolify.symbolify "\u{E0000}" # n/a
32
+ puts Symbolify.symbolify "\u{D0000}" # n/a
33
+ puts Symbolify.symbolify "\u{E0000}" # n/a*
31
34
  puts Symbolify.symbolify "\u{10FFFF}" # n/c
32
35
  puts Symbolify.symbolify "\x80" # �
33
36
  ```
34
37
 
35
38
  ## MIT License
36
39
 
37
- Copyright (C) 2017 Jan Lelis <http://janlelis.com>. Released under the MIT license.
40
+ Copyright (C) 2017-2020 Jan Lelis <https://janlelis.com>. Released under the MIT license.
data/Rakefile CHANGED
@@ -32,7 +32,11 @@ end
32
32
 
33
33
  desc "#{gemspec.name} | Spec"
34
34
  task :spec do
35
- sh "for file in spec/*_spec.rb; do ruby $file; done"
35
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
36
+ sh "for %f in (spec/\*.rb) do ruby spec/%f"
37
+ else
38
+ sh "for file in spec/*.rb; do ruby $file; done"
39
+ end
36
40
  end
37
41
  task default: :spec
38
42
 
@@ -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 ␠",
@@ -193,7 +201,7 @@ module Symbolify
193
201
  0xE007C => "TAG |",
194
202
  0xE007D => "TAG }",
195
203
  0xE007E => "TAG ~",
196
- 0xE007F => "TAG ",
204
+ 0xE007F => "TAG ",
197
205
  }.freeze
198
206
 
199
207
  VARIATION_SELECTOR_NAMES = {
@@ -460,27 +468,6 @@ module Symbolify
460
468
  0xE01EF => "VS256",
461
469
  }.freeze
462
470
 
463
- NONCHARACTERS = [
464
- *0xFDD0..0xFDEF,
465
- 0xFFFE, 0xFFFF,
466
- 0x1FFFE, 0x1FFFF,
467
- 0x2FFFE, 0x2FFFF,
468
- 0x3FFFE, 0x3FFFF,
469
- 0x4FFFE, 0x4FFFF,
470
- 0x5FFFE, 0x5FFFF,
471
- 0x6FFFE, 0x6FFFF,
472
- 0x7FFFE, 0x7FFFF,
473
- 0x8FFFE, 0x8FFFF,
474
- 0x9FFFE, 0x9FFFF,
475
- 0xAFFFE, 0xAFFFF,
476
- 0xBFFFE, 0xBFFFF,
477
- 0xCFFFE, 0xCFFFF,
478
- 0xDFFFE, 0xDFFFF,
479
- 0xEFFFE, 0xEFFFF,
480
- 0xFFFFE, 0xFFFFF,
481
- 0x10FFFE, 0x10FFFF,
482
- ].freeze
483
-
484
471
  INTERESTING_BYTES_ENCODINGS = {
485
472
  0xD8 => /^macCroatian/,
486
473
  0xF0 => /^mac(Iceland|Roman|Turkish)/,
@@ -521,8 +508,10 @@ module Symbolify
521
508
 
522
509
  def self.unicode(char, char_info = UnicodeCharacteristics.new(char))
523
510
  if !char_info.assigned?
524
- if NONCHARACTERS.include?(char.ord)
511
+ if char_info.noncharacter?
525
512
  return "n/c"
513
+ elsif char_info.ignorable?
514
+ return "n/a*"
526
515
  else
527
516
  return "n/a"
528
517
  end
@@ -530,6 +519,7 @@ module Symbolify
530
519
 
531
520
  char = char.dup.encode("UTF-8")
532
521
  ord = char.ord
522
+ char = char[0]
533
523
 
534
524
  if char_info.delete?
535
525
  char = CONTROL_DELETE_SYMBOL
@@ -539,16 +529,20 @@ module Symbolify
539
529
  char = CONTROL_C1_NAMES[ord]
540
530
  elsif char_info.bidi_control?
541
531
  char = BIDI_CONTROL_NAMES[ord]
542
- elsif VARIATION_SELECTOR_NAMES.key?(ord)
532
+ elsif char_info.variation_selector?
543
533
  char = VARIATION_SELECTOR_NAMES[ord]
534
+ elsif char_info.tag?
535
+ char = TAG_NAMES[ord]
544
536
  elsif char_info.category == "Mn"
545
537
  char = "◌" + char
546
538
  elsif char_info.category == "Me"
547
539
  char = " " + char
540
+ elsif char_info.separator?
541
+ char = "⏎"
548
542
  elsif char_info.blank?
549
543
  char = "]" + char + "["
550
- elsif TAG_NAMES.key?(ord)
551
- char = TAG_NAMES[ord]
544
+ elsif SPECIALS.key?(ord)
545
+ char = SPECIALS[ord]
552
546
  end
553
547
 
554
548
  char
@@ -559,6 +553,7 @@ module Symbolify
559
553
 
560
554
  ord = char.ord
561
555
  encoding = char_info.encoding
556
+ char = char[0]
562
557
  no_converter = !!(NO_UTF8_CONVERTER =~ encoding.name)
563
558
  treat_char_unconverted = false
564
559
 
@@ -588,6 +583,8 @@ module Symbolify
588
583
  end
589
584
 
590
585
  def self.ascii(char, char_info = AsciiCharacteristics.new(char))
586
+ char = char[0]
587
+
591
588
  if char_info.delete?
592
589
  char = CONTROL_DELETE_SYMBOL
593
590
  elsif char_info.c0?
@@ -600,10 +597,10 @@ module Symbolify
600
597
  end
601
598
 
602
599
  def self.binary(char, _ = nil)
603
- dump(char)
600
+ dump(char[0])
604
601
  end
605
602
 
606
603
  def self.dump(char)
607
- char.dump
604
+ char[0].dump
608
605
  end
609
606
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Symbolify
4
- VERSION = "1.0.0".freeze
5
- UNICODE_VERSION = "9.0.0".freeze
4
+ VERSION = "1.4.0"
6
5
  end
7
6
 
@@ -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
@@ -54,7 +72,11 @@ describe Symbolify do
54
72
  end
55
73
 
56
74
  it "works with unassigned characters" do
57
- assert_equal "n/a", Symbolify.symbolify("\u{E0000}")
75
+ assert_equal "n/a", Symbolify.symbolify("\u{D0000}")
76
+ end
77
+
78
+ it "adds a * to unassigned characters which are ignorable" do
79
+ assert_equal "n/a*", Symbolify.symbolify("\u{E0000}")
58
80
  end
59
81
  end
60
82
 
@@ -5,10 +5,10 @@ require File.dirname(__FILE__) + "/lib/symbolify/version"
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "symbolify"
7
7
  gem.version = Symbolify::VERSION
8
- gem.summary = "Represent arbitrary codepoints in the terminal."
9
- gem.description = "Safely print all codepoints from Unicode and single-byte encodings."
8
+ gem.summary = "Represent arbitrary code points in the terminal"
9
+ gem.description = "Safely print all code points from Unicode or single-byte encodings"
10
10
  gem.authors = ["Jan Lelis"]
11
- gem.email = ["mail@janlelis.de"]
11
+ gem.email = ["hi@ruby.consulting"]
12
12
  gem.homepage = "https://github.com/janlelis/symbolify"
13
13
  gem.license = "MIT"
14
14
 
@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.required_ruby_version = "~> 2.0"
21
- gem.add_dependency "characteristics", "~> 0.5"
20
+ gem.required_ruby_version = ">= 2.0"
21
+ gem.add_dependency "characteristics", ">= 0.8", "< 2.0"
22
22
  end
metadata CHANGED
@@ -1,41 +1,47 @@
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.4.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: 2020-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: characteristics
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0.8'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.8'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '0.5'
27
- description: Safely print all codepoints from Unicode and single-byte encodings.
32
+ version: '2.0'
33
+ description: Safely print all code points from Unicode or single-byte encodings
28
34
  email:
29
- - mail@janlelis.de
35
+ - hi@ruby.consulting
30
36
  executables: []
31
37
  extensions: []
32
38
  extra_rdoc_files: []
33
39
  files:
34
40
  - ".gitignore"
35
- - ".travis.yml"
36
41
  - CHANGELOG.md
37
42
  - CODE_OF_CONDUCT.md
38
43
  - Gemfile
44
+ - Gemfile.lock
39
45
  - MIT-LICENSE.txt
40
46
  - README.md
41
47
  - Rakefile
@@ -53,7 +59,7 @@ require_paths:
53
59
  - lib
54
60
  required_ruby_version: !ruby/object:Gem::Requirement
55
61
  requirements:
56
- - - "~>"
62
+ - - ">="
57
63
  - !ruby/object:Gem::Version
58
64
  version: '2.0'
59
65
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -62,10 +68,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
68
  - !ruby/object:Gem::Version
63
69
  version: '0'
64
70
  requirements: []
65
- rubyforge_project:
66
- rubygems_version: 2.6.8
71
+ rubygems_version: 3.2.3
67
72
  signing_key:
68
73
  specification_version: 4
69
- summary: Represent arbitrary codepoints in the terminal.
74
+ summary: Represent arbitrary code points in the terminal
70
75
  test_files:
71
76
  - spec/symbolify_spec.rb
@@ -1,22 +0,0 @@
1
- sudo: false
2
- language: ruby
3
-
4
- rvm:
5
- - ruby-head
6
- - 2.4.1
7
- - 2.3.3
8
- - 2.2
9
- - 2.1
10
- - 2.0
11
- - jruby-head
12
- - jruby-9.1.8.0
13
-
14
- cache:
15
- - bundler
16
-
17
- matrix:
18
- allow_failures:
19
- - rvm: jruby-head
20
- - rvm: ruby-head
21
- - rvm: 2.0
22
- # fast_finish: true