table_format 0.0.12 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67e3673e951370eecf4c5425e90e1e6c05a1226d832589199a51b5133096c891
4
- data.tar.gz: 8a7a48f7a408564571506dd4373d0f7fbc88220179db20ef0358e9e5dc6382db
3
+ metadata.gz: 951c7faf55e91b0292ccfaa5df26a84694a35daf0d8b5d685e2fefa304de0bfe
4
+ data.tar.gz: 6bf8084836e02defeeb6da944dc0232ebb53e859e2600f28ad1a893817ad5cd2
5
5
  SHA512:
6
- metadata.gz: f3b15c9880d6bce8283278612111113e44df799fff0ad79061d188ca2c13eb51d23892efdedc3eaa22248e4b1dd1ccfb1dbb35b4a465c509d5539bbc7baa649f
7
- data.tar.gz: 1f8601067d240a2afe90df869e1bdb04f340d431874d7686121c8ce886e7cbbbd35a815b747515b260f482518ab4452d302f998a6fe1ec25c64ae77e3312d475
6
+ metadata.gz: 1f795872dbcf42d7acf6258118eaaf5c2dc15023babbd126eaa06b93dde939a413bccc4039242dc3681a115df62ba5ac8fc75bb2b715ea1db273cb0f98ee794d
7
+ data.tar.gz: b881f75d76c2beb947de2af4ea902772da60de79ed11e058d34d4154ba1d7d0bd835edec6e8ed3b040bd20c7810878d951a8a69cf842cc227134a398d356469e
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH << '../lib'
2
+ require 'table_format'
3
+
4
+ require "active_support/logger"
5
+
6
+ AppLogger = ActiveSupport::Logger.new(STDOUT)
7
+
8
+ module TableFormat
9
+ def self.table_print(str)
10
+ AppLogger.debug(str.rstrip)
11
+ end
12
+ end
13
+
14
+ tp "foo"
15
+ # >> |-----|
16
+ # >> | foo |
17
+ # >> |-----|
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH << '../lib'
2
+ require 'table_format'
3
+
4
+ tp "ア"
5
+ # >> |---|
6
+ # >> | ア |
7
+ # >> |---|
@@ -44,7 +44,7 @@ Kernel.module_eval do
44
44
 
45
45
  def tp(object, options = {})
46
46
  object.tap do
47
- table_format(object, options).display
47
+ TableFormat.table_print(table_format(object, options))
48
48
  end
49
49
  end
50
50
 
@@ -27,6 +27,10 @@ module TableFormat
27
27
  }
28
28
  end
29
29
 
30
+ def self.table_print(str)
31
+ print str
32
+ end
33
+
30
34
  def self.generate(rows, options = {})
31
35
  Generator.new(rows, options).generate
32
36
  end
@@ -163,6 +167,9 @@ module TableFormat
163
167
 
164
168
  def str_width(str)
165
169
  s = str.to_s
170
+ if s.encoding == Encoding.find("UTF-8")
171
+ s = s.gsub(/[ヲ-゚]/, "_") # 2byte char (hankaku katakana) -> 1byte
172
+ end
166
173
  x = nil
167
174
  if @options[:in_code] == Kconv::UTF8
168
175
  begin
@@ -1,3 +1,3 @@
1
1
  module TableFormat
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.15'
3
3
  end
@@ -23,6 +23,14 @@ describe TableFormat do
23
23
  |------+------|
24
24
  | i... | 1... |
25
25
  |------+------|
26
+ EOT
27
+ end
28
+
29
+ it 'hankaku katakana' do
30
+ capture(:stdout) { tp("ア") }.should == <<~EOT
31
+ |---|
32
+ | ア |
33
+ |---|
26
34
  EOT
27
35
  end
28
36
  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.12
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - akicho8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-16 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -114,6 +114,8 @@ files:
114
114
  - examples/0160_truncate.rb
115
115
  - examples/0170_emoji.rb
116
116
  - examples/0180_object_spec.rb
117
+ - examples/0190_table_print.rb
118
+ - examples/0200_hankaku_katakana.rb
117
119
  - lib/table_format.rb
118
120
  - lib/table_format/core_ext.rb
119
121
  - lib/table_format/generator.rb