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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/bin/unibits +1 -1
- data/lib/unibits.rb +6 -1
- data/lib/unibits/symbolify.rb +5 -5
- data/lib/unibits/version.rb +1 -1
- data/unibits.gemspec +1 -0
- metadata +21 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0d2c78485e3fa534c3dcd45053880ee335c6903
|
4
|
+
data.tar.gz: 32f99ecc52618c3578fc85b99564a124a64cf1f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41ddb5833f8e6b356ddbc866df640452c3b62b6dc427c4b236533812749997b27f70446732355f6fdace9eb361307d358801bd16ee664f892188cf5524026b33
|
7
|
+
data.tar.gz: beb327d7946a08655d7b794a70f9d848227dad43c4d8d6f017bb81449e780ea0796995259cbd54b8535a9c1ea4e96e6bbed1e0695ac6f40c9d9ca1b6f18a774d
|
data/CHANGELOG.md
CHANGED
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
|
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))
|
data/bin/unibits
CHANGED
data/lib/unibits.rb
CHANGED
@@ -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
|
data/lib/unibits/symbolify.rb
CHANGED
@@ -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
|
-
|
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
|
}
|
data/lib/unibits/version.rb
CHANGED
data/unibits.gemspec
CHANGED
@@ -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.
|
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
|