unicode-display_width 1.4.0 → 1.4.1
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/lib/unicode/display_width/constants.rb +1 -1
- metadata +4 -7
- data/Rakefile +0 -64
- data/spec/display_width_spec.rb +0 -156
- data/unicode-display_width.gemspec +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68348f39116ee4b33d3c1e4f58a52649b14d35f3e4d6354dbe7e6116751bae00
|
4
|
+
data.tar.gz: 6a2fac12e942244ac2602f06e2e7088de561e6d230302ca1a875a14690085d4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a85fce734fb9aa0642ee232d2242cc9172c8da2af8c10f4a09b9fd101bd876d7185321d8cfcfffa5f4ca903f07e5075c570806e73c31bef4a625ac6c584824a6
|
7
|
+
data.tar.gz: 86104acc4f9ee32b98b243a373bdad9c6b82da9b363125b819281861ae1fac73ce9b4a4baaef2c53c2ad2859e5cd56085bdf46b5b5601635a85da568e874c362
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Unicode
|
2
2
|
module DisplayWidth
|
3
|
-
VERSION = '1.4.
|
3
|
+
VERSION = '1.4.1'
|
4
4
|
UNICODE_VERSION = "11.0.0".freeze
|
5
5
|
DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + '/../../../data/').freeze
|
6
6
|
INDEX_FILENAME = (DATA_DIRECTORY + '/display_width.marshal.gz').freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicode-display_width
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -51,16 +51,13 @@ files:
|
|
51
51
|
- CHANGELOG.md
|
52
52
|
- MIT-LICENSE.txt
|
53
53
|
- README.md
|
54
|
-
- Rakefile
|
55
54
|
- data/display_width.marshal.gz
|
56
55
|
- lib/unicode/display_width.rb
|
57
56
|
- lib/unicode/display_width/constants.rb
|
58
57
|
- lib/unicode/display_width/index.rb
|
59
58
|
- lib/unicode/display_width/no_string_ext.rb
|
60
59
|
- lib/unicode/display_width/string_ext.rb
|
61
|
-
|
62
|
-
- unicode-display_width.gemspec
|
63
|
-
homepage: http://github.com/janlelis/unicode-display_width
|
60
|
+
homepage: https://github.com/janlelis/unicode-display_width
|
64
61
|
licenses:
|
65
62
|
- MIT
|
66
63
|
metadata: {}
|
@@ -80,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
77
|
version: '0'
|
81
78
|
requirements: []
|
82
79
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.7.
|
80
|
+
rubygems_version: 2.7.7
|
84
81
|
signing_key:
|
85
82
|
specification_version: 4
|
86
83
|
summary: Determines the monospace display width of a string in Ruby.
|
data/Rakefile
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# # #
|
2
|
-
# Get gemspec info
|
3
|
-
|
4
|
-
gemspec_file = Dir['*.gemspec'].first
|
5
|
-
gemspec = eval File.read(gemspec_file), binding, gemspec_file
|
6
|
-
info = "#{gemspec.name} | #{gemspec.version} | " \
|
7
|
-
"#{gemspec.runtime_dependencies.size} dependencies | " \
|
8
|
-
"#{gemspec.files.size} files"
|
9
|
-
|
10
|
-
|
11
|
-
# # #
|
12
|
-
# Gem build and install task
|
13
|
-
|
14
|
-
desc info
|
15
|
-
task :gem do
|
16
|
-
puts info + "\n\n"
|
17
|
-
print " "; sh "gem build #{gemspec_file}"
|
18
|
-
FileUtils.mkdir_p 'pkg'
|
19
|
-
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
20
|
-
puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
# # #
|
25
|
-
# Start an IRB session with the gem loaded
|
26
|
-
|
27
|
-
desc "#{gemspec.name} | IRB"
|
28
|
-
task :irb do
|
29
|
-
sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
|
30
|
-
end
|
31
|
-
|
32
|
-
# # #
|
33
|
-
# Run all specs
|
34
|
-
|
35
|
-
|
36
|
-
desc "#{gemspec.name} | Test"
|
37
|
-
task :test do
|
38
|
-
sh "rspec spec"
|
39
|
-
end
|
40
|
-
task :spec => :test
|
41
|
-
task :default => :test
|
42
|
-
|
43
|
-
# # #
|
44
|
-
# Update index table
|
45
|
-
|
46
|
-
namespace :update do
|
47
|
-
desc "#{gemspec.name} | Update index"
|
48
|
-
task :index do
|
49
|
-
require File.dirname(__FILE__) + '/lib/unicode/display_width/index_builder'
|
50
|
-
Unicode::DisplayWidth::IndexBuilder.build!
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# # #
|
55
|
-
# Update data file
|
56
|
-
|
57
|
-
namespace :update do
|
58
|
-
desc "#{gemspec.name} | Update unicode data"
|
59
|
-
task :data do
|
60
|
-
require File.dirname(__FILE__) + '/lib/unicode/display_width/index_builder'
|
61
|
-
Unicode::DisplayWidth::IndexBuilder.fetch!
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
data/spec/display_width_spec.rb
DELETED
@@ -1,156 +0,0 @@
|
|
1
|
-
require_relative '../lib/unicode/display_width'
|
2
|
-
|
3
|
-
describe 'Unicode::DisplayWidth.of' do
|
4
|
-
describe '[east asian width]' do
|
5
|
-
it 'returns 2 for F' do
|
6
|
-
expect( '!'.display_width ).to eq 2
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'returns 2 for W' do
|
10
|
-
expect( '一'.display_width ).to eq 2
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'returns 2 for W (which are currently unassigned)' do
|
14
|
-
expect( "\u{3FFFD}".display_width ).to eq 2
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns 1 for N' do
|
18
|
-
expect( 'À'.display_width ).to eq 1
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'returns 1 for Na' do
|
22
|
-
expect( 'A'.display_width ).to eq 1
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'returns 1 for H' do
|
26
|
-
expect( '。'.display_width ).to eq 1
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'returns first argument of display_width for A' do
|
30
|
-
expect( '·'.display_width(1) ).to eq 1
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'returns first argument of display_width for A' do
|
34
|
-
expect( '·'.display_width(2) ).to eq 2
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'returns 1 for A if no argument given' do
|
38
|
-
expect( '·'.display_width ).to eq 1
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '[zero width]' do
|
43
|
-
it 'returns 0 for Mn chars' do
|
44
|
-
expect( 'ֿ'.display_width ).to eq 0
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'returns 0 for Me chars' do
|
48
|
-
expect( '҈'.display_width ).to eq 0
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'returns 0 for Cf chars' do
|
52
|
-
expect( ''.display_width ).to eq 0
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'returns 0 for HANGUL JUNGSEONG chars' do
|
56
|
-
expect( 'ᅠ'.display_width ).to eq 0
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'returns 0 for U+2060..U+206F' do
|
60
|
-
expect( "\u{2060}".display_width ).to eq 0
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'returns 0 for U+FFF0..U+FFF8' do
|
64
|
-
expect( "\u{FFF0}".display_width ).to eq 0
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'returns 0 for U+E0000..U+E0FFF' do
|
68
|
-
expect( "\u{E0000}".display_width ).to eq 0
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '[special characters]' do
|
73
|
-
it 'returns 0 for ␀' do
|
74
|
-
expect( "\0".display_width ).to eq 0
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'returns 0 for ␅' do
|
78
|
-
expect( "\x05".display_width ).to eq 0
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'returns 0 for ␇' do
|
82
|
-
expect( "\a".display_width ).to eq 0
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'returns -1 for ␈' do
|
86
|
-
expect( "aaaa\b".display_width ).to eq 3
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'returns -1 for ␈, but at least 0' do
|
90
|
-
expect( "\b".display_width ).to eq 0
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'returns 0 for ␊' do
|
94
|
-
expect( "\n".display_width ).to eq 0
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'returns 0 for ␋' do
|
98
|
-
expect( "\v".display_width ).to eq 0
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'returns 0 for ␌' do
|
102
|
-
expect( "\f".display_width ).to eq 0
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'returns 0 for ␍' do
|
106
|
-
expect( "\r".display_width ).to eq 0
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'returns 0 for ␎' do
|
110
|
-
expect( "\x0E".display_width ).to eq 0
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'returns 0 for ␏' do
|
114
|
-
expect( "\x0F".display_width ).to eq 0
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'returns 1 for other C0 characters' do
|
118
|
-
expect( "\x10".display_width ).to eq 1
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'returns 1 for SOFT HYPHEN' do
|
122
|
-
expect( "".display_width ).to eq 1
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'returns 2 for THREE-EM DASH' do
|
126
|
-
expect( "⸺".display_width ).to eq 2
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'returns 3 for THREE-EM DASH' do
|
130
|
-
expect( "⸻".display_width ).to eq 3
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
|
-
describe '[overwrite]' do
|
136
|
-
it 'can be passed a 3rd parameter with overwrites' do
|
137
|
-
expect( "\t".display_width(1, 0x09 => 12) ).to eq 12
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe '[encoding]' do
|
142
|
-
it 'works with non-utf8 Unicode encodings' do
|
143
|
-
expect( 'À'.encode("UTF-16LE").display_width ).to eq 1
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe '[emoji]' do
|
148
|
-
it 'does not count modifiers and zjw sequences for valid emoji' do
|
149
|
-
expect( "🤾🏽♀️".display_width(1, {}, emoji: true) ).to eq 2
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'works with flags' do
|
153
|
-
expect( "🇵🇹".display_width(1, {}, emoji: true) ).to eq 2
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.dirname(__FILE__) + "/lib/unicode/display_width"
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = "unicode-display_width"
|
6
|
-
s.version = Unicode::DisplayWidth::VERSION
|
7
|
-
s.authors = ["Jan Lelis"]
|
8
|
-
s.email = "mail@janlelis.de"
|
9
|
-
s.homepage = "http://github.com/janlelis/unicode-display_width"
|
10
|
-
s.summary = "Determines the monospace display width of a string in Ruby."
|
11
|
-
s.description = "[Unicode #{Unicode::DisplayWidth::UNICODE_VERSION}] Determines the monospace display width of a string using EastAsianWidth.txt, Unicode general category, and other data."
|
12
|
-
s.files = Dir.glob(%w[{lib,spec}/**/*.rb [A-Z]*.{txt,rdoc} data/display_width.marshal.gz]) + %w{Rakefile unicode-display_width.gemspec}
|
13
|
-
s.extra_rdoc_files = ["README.md", "MIT-LICENSE.txt", "CHANGELOG.md"]
|
14
|
-
s.license = 'MIT'
|
15
|
-
s.required_ruby_version = '>= 1.9.3'
|
16
|
-
s.add_development_dependency 'rspec', '~> 3.4'
|
17
|
-
s.add_development_dependency 'rake', '~> 10.4'
|
18
|
-
end
|