unibits 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +10 -4
- data/bin/unibits +4 -1
- data/lib/unibits.rb +9 -5
- data/lib/unibits/version.rb +2 -2
- data/unibits.gemspec +3 -3
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cba814f571207d37582bbbdfdbce131842869d2
|
4
|
+
data.tar.gz: '049882afb03bab8eca8ce3693906c02b00f83212'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 331f30661d1f0e7c3de8f85479f326a683711af6e8d1830bab3a4d27dc2b8e7647ef24fff6abdebf507c784bcc5d97d083ba456d9936c8481b22164b29b8af68
|
7
|
+
data.tar.gz: 64d5968cc6e95a33fdedf2772747fee0be2e6e124923e24adf3fb5a57ae953189cf3d8d91199f4329676aab5db34ac153f725e06cf60aa5b3aff5ec6b6082819
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,8 @@ Each byte of the given string is highlighted using the following mechanism (char
|
|
20
20
|
- Lighter orange for unassigned codepoints which are also ignorable
|
21
21
|
- Random color for all other codepoints
|
22
22
|
|
23
|
+
The same colors are used in the higher-level companion tool [uniscribe](https://github.com/janlelis/uniscribe).
|
24
|
+
|
23
25
|
## Setup
|
24
26
|
|
25
27
|
Make sure you have Ruby installed and installing gems works properly. Then do:
|
@@ -111,16 +113,20 @@ Example in Ruby: `unibits "🌫 Idiosyncrätic ℜսᖯʏ", encoding: 'ascii'
|
|
111
113
|
|
112
114
|
## Notes
|
113
115
|
|
114
|
-
|
116
|
+
More info
|
115
117
|
|
116
118
|
- [Ruby's Encoding class](https://ruby-doc.org/core/Encoding.html)
|
117
|
-
- [Symbolify gem](https://github.com/janlelis/symbolify)
|
118
|
-
- [Characteristics gem](https://github.com/janlelis/characteristics)
|
119
119
|
- [UTF-8 (Wikipedia)](https://en.wikipedia.org/wiki/UTF-8#Description)
|
120
120
|
- [UTF-16 (Wikipedia)](https://en.wikipedia.org/wiki/UTF-16#Description)
|
121
121
|
- [UTF-32 (Wikipedia)](https://en.wikipedia.org/wiki/UTF-32)
|
122
122
|
- [Difference between BINARY and ASCII](http://idiosyncratic-ruby.com/56-us-ascii-8bit.html)
|
123
|
-
|
123
|
+
|
124
|
+
Related gems
|
125
|
+
|
126
|
+
- [uniscribe](https://github.com/janlelis/uniscribe)
|
127
|
+
- [unicopy](https://github.com/janlelis/unicopy)
|
128
|
+
- [symbolify](https://github.com/janlelis/symbolify)
|
129
|
+
- [characteristics](https://github.com/janlelis/characteristics)
|
124
130
|
|
125
131
|
Lots of thanks to @damienklinnert for the motivation and inspiration required to build this! 🎆
|
126
132
|
|
data/bin/unibits
CHANGED
@@ -44,8 +44,9 @@ if argv[:help]
|
|
44
44
|
--convert <encoding> | -c | which encoding to convert to (if possible)
|
45
45
|
--width <n> | -w | force a specific number of terminal columns
|
46
46
|
--no-stats | | no stats header with length info
|
47
|
-
--version | | displays version of unibits
|
48
47
|
--wide-ambiguous | | ambiguous characters
|
48
|
+
--help | | this help page
|
49
|
+
--version | | displays version of unibits
|
49
50
|
|
50
51
|
#{Paint["ENCODINGS", :underline]}
|
51
52
|
|
@@ -60,6 +61,8 @@ if argv[:help]
|
|
60
61
|
#{Paint["unassigned", Unibits::COLORS[:unassigned]]}
|
61
62
|
#{Paint["unassigned and ignorable", Unibits::COLORS[:ignorable]]}
|
62
63
|
|
64
|
+
random color for other characters
|
65
|
+
|
63
66
|
#{Paint["STATS", :underline]}
|
64
67
|
|
65
68
|
( bytes / codepoints / glyphs / expected terminal width )
|
data/lib/unibits.rb
CHANGED
@@ -39,17 +39,21 @@ module Unibits
|
|
39
39
|
DEFAULT_TERMINAL_WIDTH = 80
|
40
40
|
|
41
41
|
def self.of(string, encoding: nil, convert: nil, stats: true, wide_ambiguous: false, width: nil)
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
string = convert_to_encoding_or_raise(string, encoding, convert)
|
43
|
+
|
44
|
+
puts stats(string, wide_ambiguous: wide_ambiguous) if stats
|
45
|
+
puts visualize(string, wide_ambiguous: wide_ambiguous, width: width)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.convert_to_encoding_or_raise(string, encoding, convert)
|
49
|
+
raise ArgumentError, "no data given to unibits" if !string || string.empty?
|
45
50
|
|
46
51
|
string = string.dup.force_encoding(encoding) if encoding
|
47
52
|
string = string.encode(convert) if convert
|
48
53
|
|
49
54
|
case string.encoding.name
|
50
55
|
when *SUPPORTED_ENCODINGS
|
51
|
-
|
52
|
-
puts visualize(string, wide_ambiguous: wide_ambiguous, width: width)
|
56
|
+
string
|
53
57
|
when 'UTF-16', 'UTF-32'
|
54
58
|
raise ArgumentError, "unibits only supports #{string.encoding.name} with specified endianess, please use #{string.encoding.name}LE or #{string.encoding.name}BE"
|
55
59
|
else
|
data/lib/unibits/version.rb
CHANGED
data/unibits.gemspec
CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_dependency 'paint', '>= 0.9', '< 3.0'
|
21
|
-
gem.add_dependency 'unicode-display_width', '~> 1.
|
22
|
-
gem.add_dependency 'symbolify', '~> 1.
|
23
|
-
gem.add_dependency 'characteristics', '>= 0.
|
21
|
+
gem.add_dependency 'unicode-display_width', '~> 1.3'
|
22
|
+
gem.add_dependency 'symbolify', '~> 1.3'
|
23
|
+
gem.add_dependency 'characteristics', '>= 0.8'
|
24
24
|
gem.add_dependency 'rationalist', '~> 2.0'
|
25
25
|
|
26
26
|
gem.required_ruby_version = "~> 2.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unibits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.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-
|
11
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paint
|
@@ -36,42 +36,42 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '1.
|
39
|
+
version: '1.3'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
46
|
+
version: '1.3'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: symbolify
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '1.
|
53
|
+
version: '1.3'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '1.
|
60
|
+
version: '1.3'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: characteristics
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0.
|
67
|
+
version: '0.8'
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0.
|
74
|
+
version: '0.8'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rationalist
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.6.
|
134
|
+
rubygems_version: 2.6.11
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Visualizes encodings.
|