table_format 0.0.4 → 0.0.5

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
  SHA256:
3
- metadata.gz: b43cf8ff87491505feda5008ef0f697d8e59a5f1333b2216070e4574c99c0608
4
- data.tar.gz: d3cc57d297912be0e27dd1ce4f37e57d0f7b0cf2061d92c79d7f5a5b5365c8e9
3
+ metadata.gz: cc7a2457aeea59874ff842029a0ddb07612b2ea9d4b933c758ad65ee5e6898cf
4
+ data.tar.gz: 3cd187d8d8b08a9a1be678a1cb0c00f4f1fca434655037cbd4a1c354af790e2c
5
5
  SHA512:
6
- metadata.gz: 0c992fe248e17f712cb9fa39d9867de3249109663f40a6bcd19e6be5d511db130927ff9ff24d28ff83337d7551fe48f3bb5db8f6fa74d98300160f648f6bf2e9
7
- data.tar.gz: ab84ce1367a7f6e01b89950d877747616697faef9dabc8ee65189ec8cb953d02892e5a9e0aae1f9d70764b1f84e1bb7322f55c0d2f557cb4497759cae4a8dee8
6
+ metadata.gz: b73b71faba2c2ab0725d46dcfc7a1a199d4c88d5ed400332334e53bf0dd89f9862426fbbba631703ca3ba29006b76c129ada2352b6f032559af1fdcc640151d1
7
+ data.tar.gz: cdfc9c695aa40bdeadba4fb29674fd3c5f3fc9d3ddc41c22462d738b15eac59b0cd1f3e3c41ec37818df6d3ce453929cd1c13eecbf4d1c17f31037156c450a1b
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH << '../lib'
2
+ require 'table_format'
3
+
4
+ tp "♡"
5
+ # >> |----|
6
+ # >> | ♡ |
7
+ # >> |----|
@@ -154,7 +154,16 @@ module TableFormat
154
154
  end
155
155
 
156
156
  def str_width(str)
157
- str.to_s.kconv(Kconv::EUC, @options[:in_code]).bytesize
157
+ s = str.to_s
158
+ x = nil
159
+ if @options[:in_code] == Kconv::UTF8
160
+ begin
161
+ x = s.encode("EUC-JP", "UTF-8", invalid: :replace, undef: :replace, replace: "xx")
162
+ rescue EncodingError
163
+ end
164
+ end
165
+ x ||= s.kconv(Kconv::EUC, @options[:in_code])
166
+ x.bytesize
158
167
  end
159
168
 
160
169
  def pre_processes
@@ -1,3 +1,3 @@
1
1
  module TableFormat
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -150,4 +150,12 @@ EOT
150
150
  EOT
151
151
  end
152
152
  end
153
+
154
+ it 'emoji' do
155
+ "♡".to_t.should == <<~EOT
156
+ |----|
157
+ | ♡ |
158
+ |----|
159
+ EOT
160
+ end
153
161
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - akicho8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2019-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -112,6 +112,7 @@ files:
112
112
  - examples/0140_markdown_format.rb
113
113
  - examples/0150_line_break.rb
114
114
  - examples/0160_truncate.rb
115
+ - examples/0170_emoji.rb
115
116
  - lib/table_format.rb
116
117
  - lib/table_format/core_ext.rb
117
118
  - lib/table_format/generator.rb