unibits 1.1.0 → 1.2.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: 3a765c7b1a6edfd62f8fed06b683d0d4ff2cacae
4
- data.tar.gz: c66cb699f9a4425fc169fd6562dd4b758b94c584
3
+ metadata.gz: a0d2c78485e3fa534c3dcd45053880ee335c6903
4
+ data.tar.gz: 32f99ecc52618c3578fc85b99564a124a64cf1f6
5
5
  SHA512:
6
- metadata.gz: a516728fe08185386fc1902fa341784517521d0a85e494e35a7e2700c1c6d7fc3dfc8f86bb20d4268de6d69df591ab431aa3ab5ee02d96f6798fcd97f2426a8e
7
- data.tar.gz: cb2fbfea68be359661ad75cc6e203bd4235ccd81431a37f74f965e90f6116e1a12d8cb04094a213f537e2a032c0c25775edd08378cd7c8ae613503dbe5cc3e0e
6
+ metadata.gz: 41ddb5833f8e6b356ddbc866df640452c3b62b6dc427c4b236533812749997b27f70446732355f6fdace9eb361307d358801bd16ee664f892188cf5524026b33
7
+ data.tar.gz: beb327d7946a08655d7b794a70f9d848227dad43c4d8d6f017bb81449e780ea0796995259cbd54b8535a9c1ea4e96e6bbed1e0695ac6f40c9d9ca1b6f18a774d
@@ -1,5 +1,9 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 1.2.0
4
+
5
+ * Do not display (but highlight) unassigned codepoints
6
+
3
7
  ### 1.1.0
4
8
 
5
9
  * Support (and highlight) invalid encodings \o/
data/README.md CHANGED
@@ -36,7 +36,7 @@ unibits "🌫 Idiosyncrätic ℜսᖯʏ"
36
36
 
37
37
  `unibits` takes some optional options:
38
38
 
39
- - *encoding (e)*: The encoding of the given string (uses your default encoding if none given)
39
+ - *encoding (e)*: The encoding of the given string (uses the string's default encoding if none given)
40
40
  - *convert (c)*: An encoding the string should be converted to before visualizing it
41
41
  - *stats*: Whether to show a short stats header (default: `true`), you can deactivate on the CLI with `--no-stats`
42
42
  - *wide-ambiguous*: Treat characters of ambiguous width as 2 spaces instead of 1 ([more info](https://github.com/janlelis/unicode-display_width))
@@ -33,7 +33,7 @@ if argv[:help]
33
33
 
34
34
  #{Paint["DESCRIPTION", :underline]}
35
35
 
36
- Visualizes ANSI and variouus Unicode encodings in the terminal.
36
+ Visualizes ASCII and variouus Unicode encodings in the terminal.
37
37
 
38
38
  #{Paint["USAGE", :underline]}
39
39
 
@@ -4,6 +4,7 @@ require_relative "unibits/symbolify"
4
4
  require "io/console"
5
5
  require "paint"
6
6
  require "unicode/display_width"
7
+ require "unicode/categories"
7
8
 
8
9
  module Unibits
9
10
  SUPPORTED_ENCODINGS = [
@@ -60,8 +61,12 @@ module Unibits
60
61
  string.each_char{ |char|
61
62
  if char.valid_encoding?
62
63
  char_valid = true
63
- current_color = random_color
64
64
  current_encoding_error = nil
65
+ if Unicode::Categories.category(char) == "Cn"
66
+ current_color = "#FF5500"
67
+ else
68
+ current_color = random_color
69
+ end
65
70
  else
66
71
  char_valid = false
67
72
  current_color = :red
@@ -1,3 +1,5 @@
1
+ require "unicode/categories"
2
+
1
3
  module Unibits
2
4
  module Symbolify
3
5
  ASCII_CONTROL_CODEPOINTS = "\x00-\x1F\x7F".freeze
@@ -74,9 +76,10 @@ module Unibits
74
76
  "\u{FE0F}" => "VS16",
75
77
  }.freeze
76
78
  COULD_BE_WHITESPACE = '[\p{Space}­᠎​‌‍⁠⁡⁢⁣⁤⠀𛲠𛲡𛲢𛲣𝅳𝅴𝅵𝅶𝅷𝅸𝅹𝅺]'.freeze
77
- # UNASSIGNED = '\p{Cn}'.freeze
78
79
 
79
80
  def self.symbolify(char, encoding = char.encoding)
81
+ return "n/a" if Unicode::Categories.category(char) == "Cn"
82
+
80
83
  char.tr!(
81
84
  ASCII_CONTROL_CODEPOINTS.encode(encoding),
82
85
  ASCII_CONTROL_SYMBOLS.encode(encoding)
@@ -85,10 +88,7 @@ module Unibits
85
88
  Regexp.compile(COULD_BE_WHITESPACE.encode(encoding)),
86
89
  ']\0['.encode(encoding)
87
90
  )
88
- # char.gsub!(
89
- # Regexp.compile(UNASSIGNED.encode(encoding)),
90
- # 'n/a'.encode(encoding)
91
- # )
91
+
92
92
  INTERESTING_CODEPOINTS.each{ |cp, desc|
93
93
  char.gsub! Regexp.compile(cp.encode(encoding)), desc.encode(encoding)
94
94
  }
@@ -1,3 +1,3 @@
1
1
  module Unibits
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency 'paint', '>= 0.9', '< 3.0'
21
21
  gem.add_dependency 'unicode-display_width', '~> 1.1'
22
+ gem.add_dependency 'unicode-categories', '~> 1.1', '>= 1.1.1'
22
23
  gem.add_dependency 'rationalist', '~> 2.0'
23
24
 
24
25
  gem.required_ruby_version = "~> 2.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unibits
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Lelis
@@ -44,6 +44,26 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: unicode-categories
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.1'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.1.1
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.1'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.1.1
47
67
  - !ruby/object:Gem::Dependency
48
68
  name: rationalist
49
69
  requirement: !ruby/object:Gem::Requirement