unicode-display_width 0.3.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b600c9e8b63a894f3949dbc550fcc36f9954d9e
4
- data.tar.gz: 7a91242b996b77192f59da5ca4bcce96f3d15d7e
3
+ metadata.gz: 7d30235f9e772a7cb8bd87db9e46ccfda2486562
4
+ data.tar.gz: ee3e35d0979b120a900b5d02c115db8541ff2786
5
5
  SHA512:
6
- metadata.gz: dee920064581a08e71a0bf4867096191f8f9c6811b6e3616836c19715d899748c4c7f180df1ae09a699fa537b440f30f32d294d44621e9628706bc06c9ad6fcc
7
- data.tar.gz: 5160acd691a9bd65f05915f3f4a051baa2d1457d8d2b3f1d1ce2cedfa41cf3eeddddf3ee85e80abe93ddaeba0e86c519ecc4279a614cce2e788b69021d4645c4
6
+ metadata.gz: 31322009d863f9b2d83997d0c27ea60fd43a6522beee58a08d719bd2d51f7fb0186c140e5b17b0fb313be59a16fee2e679b704498311456dc1a60a6c230a7d9f
7
+ data.tar.gz: 7c49daaf067fdf97869e3dac8e143dd116e34ecb5d9f88e358a26f1d58b206e9add60262864b7875971dfe74cf3636b70d47ae541d91f38f0ecf436fbcd1a428
@@ -1,4 +1,11 @@
1
+ ## 0.3.1
2
+
3
+ * Faster than 0.3.0
4
+ * Deprecate usage of aliases: String#display_size and String#display_width
5
+ * Eliminate Ruby warnings (@amatsuda)
6
+
1
7
  ## 0.3.0
8
+
2
9
  * Update EastAsianWidth from 7.0 to 8.0
3
10
  * Add rake task to update EastAsianWidth.txt
4
11
  * Move code to generate index from library to Rakefile
data/Rakefile CHANGED
@@ -56,7 +56,7 @@ namespace :update do
56
56
  if $1 && $2
57
57
  cps, width = $1, $2
58
58
  if cps['..']
59
- range = Range.new *cps.split('..').map{ |cp| cp.to_i(16) }
59
+ range = Range.new(*cps.split('..').map{ |cp| cp.to_i(16) })
60
60
  range.each{ |cp| table[ cp ] = width.to_sym }
61
61
  else
62
62
  table[ cps.to_i(16) ] = width.to_sym
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Unicode
4
4
  module DisplayWidth
5
- VERSION = '0.3.0'.freeze
5
+ VERSION = '0.3.1'.freeze
6
6
  DATA_DIR = File.join(File.dirname(__FILE__), '../../data/').freeze
7
7
  TABLE_FILE = (DATA_DIR + 'EastAsianWidth.index').freeze
8
8
  DATA_FILE = (DATA_DIR + 'EastAsianWidth.txt').freeze
9
9
 
10
10
  class << self
11
11
  def table
12
- if @table
12
+ if defined?(@table) && @table
13
13
  @table
14
14
  else
15
15
  @table = Marshal.load File.respond_to?(:binread) ? File.binread(TABLE_FILE) : File.read(TABLE_FILE)
@@ -28,22 +28,29 @@ end
28
28
 
29
29
  class String
30
30
  def display_width(ambiguous = 1)
31
- unpack('U*').inject(0){ |a,c|
32
- width = case Unicode::DisplayWidth.codepoint(c).to_s
33
- when *%w[F W]
34
- 2
35
- when *%w[N Na H]
36
- 1
37
- when *%w[A]
38
- ambiguous
39
- else
40
- 1
41
- end
42
- a + width
31
+ unpack('U*').inject(0){ |total_width, char|
32
+ total_width + case Unicode::DisplayWidth.codepoint(char).to_s
33
+ when 'F', 'W'
34
+ 2
35
+ when 'N', 'Na', 'H'
36
+ 1
37
+ when 'A'
38
+ ambiguous
39
+ else
40
+ 1
41
+ end
43
42
  }
44
43
  end
45
- alias display_size display_width
46
- alias display_length display_width
44
+
45
+ def display_size(*args)
46
+ warn "Deprecation warning: Please use `String#display_width` instead of `String#display_size`"
47
+ display_width(*args)
48
+ end
49
+
50
+ def display_length(*args)
51
+ warn "Deprecation warning: Please use `String#display_width` instead of `String#display_length`"
52
+ display_width(*args)
53
+ end
47
54
  end
48
55
 
49
56
  # J-_-L
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = "mail@janlelis.de"
10
10
  s.homepage = "http://github.com/janlelis/unicode-display_width"
11
11
  s.summary = "Support for east_asian_width string widths."
12
- s.description = "This gem adds String#display_size to get the display size of a string using EastAsianWidth.txt."
12
+ s.description = "This gem adds String#display_width to get the display size of a string using EastAsianWidth.txt."
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
14
  s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} data/EastAsianWidth.index ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile unicode-display_width.gemspec}
15
15
  s.extra_rdoc_files = ["README.rdoc", "MIT-LICENSE.txt", "CHANGELOG.txt"]
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: 0.3.0
4
+ version: 0.3.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: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.4'
41
- description: This gem adds String#display_size to get the display size of a string
41
+ description: This gem adds String#display_width to get the display size of a string
42
42
  using EastAsianWidth.txt.
43
43
  email: mail@janlelis.de
44
44
  executables: []
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: 1.3.6
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.4.6
79
+ rubygems_version: 2.5.1
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Support for east_asian_width string widths.