table_print 1.2.0 → 1.3.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.
- data/.travis.yml +1 -0
- data/Rakefile +10 -1
- data/features/multibyte.feature +17 -0
- data/lib/table_print/column.rb +4 -1
- data/lib/table_print/formatter.rb +2 -1
- data/lib/table_print/version.rb +1 -1
- metadata +4 -2
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -12,7 +12,11 @@ require 'rake'
|
|
12
12
|
require 'rspec/core/rake_task'
|
13
13
|
|
14
14
|
desc 'Default: run specs and cucumber features.'
|
15
|
-
|
15
|
+
if RUBY_VERSION < '1.9'
|
16
|
+
task :default => [:spec, :cucumber_187]
|
17
|
+
else
|
18
|
+
task :default => [:spec, :cucumber]
|
19
|
+
end
|
16
20
|
|
17
21
|
desc "Run specs"
|
18
22
|
RSpec::Core::RakeTask.new do |t|
|
@@ -24,6 +28,11 @@ Cucumber::Rake::Task.new(:cucumber) do |task|
|
|
24
28
|
task.cucumber_opts = ["features"]
|
25
29
|
end
|
26
30
|
|
31
|
+
desc 'Run cucumber features for ruby 1.8.7'
|
32
|
+
Cucumber::Rake::Task.new(:cucumber_187) do |task|
|
33
|
+
task.cucumber_opts = ["-t", "~@ruby19", "features"]
|
34
|
+
end
|
35
|
+
|
27
36
|
begin
|
28
37
|
require 'rdoc/task'
|
29
38
|
rescue LoadError
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
@ruby19
|
4
|
+
Feature: Fix the column width for multibyte character
|
5
|
+
Scenario: A simple array of hashes
|
6
|
+
Given a variable named data with
|
7
|
+
|title | author |
|
8
|
+
|これは日本語です。| 山田太郎 |
|
9
|
+
|English | Bob |
|
10
|
+
When I table_print data
|
11
|
+
Then the output should contain
|
12
|
+
"""
|
13
|
+
TITLE | AUTHOR
|
14
|
+
-------------------|---------
|
15
|
+
これは日本語です。 | 山田太郎
|
16
|
+
English | Bob
|
17
|
+
"""
|
data/lib/table_print/column.rb
CHANGED
@@ -34,7 +34,10 @@ module TablePrint
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def data_width
|
37
|
-
[
|
37
|
+
[
|
38
|
+
name.each_char.collect{|c| c.bytesize == 1 ? 1 : 2}.inject(0, &:+),
|
39
|
+
Array(data).compact.collect(&:to_s).collect{|m| m.each_char.collect{|n| n.bytesize == 1 ? 1 : 2}.inject(0, &:+)}.max
|
40
|
+
].max
|
38
41
|
end
|
39
42
|
|
40
43
|
def width
|
data/lib/table_print/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cat
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- features/adding_columns.feature
|
95
95
|
- features/configuring_output.feature
|
96
96
|
- features/excluding_columns.feature
|
97
|
+
- features/multibyte.feature
|
97
98
|
- features/printing_hash.feature
|
98
99
|
- features/sensible_defaults.feature
|
99
100
|
- features/support/step_definitions/before.rb
|
@@ -151,6 +152,7 @@ test_files:
|
|
151
152
|
- features/adding_columns.feature
|
152
153
|
- features/configuring_output.feature
|
153
154
|
- features/excluding_columns.feature
|
155
|
+
- features/multibyte.feature
|
154
156
|
- features/printing_hash.feature
|
155
157
|
- features/sensible_defaults.feature
|
156
158
|
- features/support/step_definitions/before.rb
|