kosi 0.0.1 → 0.0.2
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/.coveralls.yml +1 -1
- data/.rspec +2 -2
- data/.rubocop.yml +11 -11
- data/.travis.yml +8 -8
- data/Gemfile +12 -12
- data/README.md +2 -1
- data/Rakefile +8 -8
- data/kosi.gemspec +28 -28
- data/lib/kosi.rb +13 -13
- data/lib/kosi/align.rb +33 -33
- data/lib/kosi/char_option.rb +17 -17
- data/lib/kosi/connector_char.rb +26 -26
- data/lib/kosi/header.rb +18 -18
- data/lib/kosi/horizontal_border_char.rb +26 -26
- data/lib/kosi/options.rb +15 -15
- data/lib/kosi/separate_each_row.rb +15 -15
- data/lib/kosi/validators.rb +3 -3
- data/lib/kosi/validators/each_array_length_validator.rb +21 -21
- data/lib/kosi/validators/row_type_validator.rb +19 -19
- data/lib/kosi/version.rb +4 -4
- data/lib/kosi/vertical_border_char.rb +26 -26
- data/lib/table.rb +149 -138
- data/spec/kosi/align_spec.rb +77 -77
- data/spec/kosi/connector_char_spec.rb +59 -59
- data/spec/kosi/header_spec.rb +93 -93
- data/spec/kosi/horizontal_border_char_spec.rb +59 -59
- data/spec/kosi/separate_each_row_spec.rb +55 -55
- data/spec/kosi/validators/each_array_length_validator_spec.rb +56 -56
- data/spec/kosi/validators/row_type_validator_spec.rb +51 -51
- data/spec/kosi/vertical_border_char_spec.rb +59 -59
- data/spec/spec_helper.rb +16 -16
- data/spec/table_spec.rb +145 -134
- metadata +2 -3
- data/README.html +0 -273
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'simplecov'
|
3
|
-
require 'coveralls'
|
4
|
-
Coveralls.wear!
|
5
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
-
SimpleCov::Formatter::HTMLFormatter,
|
7
|
-
Coveralls::SimpleCov::Formatter
|
8
|
-
]
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter '/spec/'
|
11
|
-
end
|
12
|
-
RSpec.configure do |config|
|
13
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
-
config.run_all_when_everything_filtered = true
|
15
|
-
config.filter_run :focus
|
16
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
+
SimpleCov::Formatter::HTMLFormatter,
|
7
|
+
Coveralls::SimpleCov::Formatter
|
8
|
+
]
|
9
|
+
SimpleCov.start do
|
10
|
+
add_filter '/spec/'
|
11
|
+
end
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
config.filter_run :focus
|
16
|
+
end
|
data/spec/table_spec.rb
CHANGED
@@ -1,134 +1,145 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'kosi'
|
4
|
-
|
5
|
-
describe Kosi::Table do
|
6
|
-
context :initialize do
|
7
|
-
cases = [
|
8
|
-
{
|
9
|
-
case_no: 1,
|
10
|
-
case_title: 'no options case',
|
11
|
-
options: nil,
|
12
|
-
attr_name: '@align',
|
13
|
-
expected: Kosi::Align::TYPE::LEFT
|
14
|
-
},
|
15
|
-
{
|
16
|
-
case_no: 2,
|
17
|
-
case_title: 'align options left case',
|
18
|
-
options: { Kosi::OptionKeys::ALIGN => Kosi::Align::TYPE::RIGHT },
|
19
|
-
attr_name: '@align',
|
20
|
-
expected: Kosi::Align::TYPE::RIGHT
|
21
|
-
}
|
22
|
-
]
|
23
|
-
|
24
|
-
cases.each do |c|
|
25
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
26
|
-
begin
|
27
|
-
case_before c
|
28
|
-
|
29
|
-
# -- given --
|
30
|
-
kosi_table = \
|
31
|
-
if c[:options]
|
32
|
-
Kosi::Table.new(c[:options])
|
33
|
-
else
|
34
|
-
Kosi::Table.new
|
35
|
-
end
|
36
|
-
|
37
|
-
# -- when --
|
38
|
-
actual = kosi_table.instance_variable_get(c[:attr_name]).value
|
39
|
-
|
40
|
-
# -- then --
|
41
|
-
expect(actual).to eq(c[:expected])
|
42
|
-
ensure
|
43
|
-
case_after c
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def case_before(c)
|
48
|
-
# implement each case before
|
49
|
-
end
|
50
|
-
|
51
|
-
def case_after(c)
|
52
|
-
# implement each case after
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context :render do
|
58
|
-
cases = [
|
59
|
-
{
|
60
|
-
case_no: 1,
|
61
|
-
case_title: 'valid case',
|
62
|
-
options: nil,
|
63
|
-
inputs: [[1, 2, 3], [1111, '222アア', '33イイ']],
|
64
|
-
expected: <<-EOS
|
65
|
-
+----+-------+------+
|
66
|
-
|1 |2 |3 |
|
67
|
-
|1111|222アア|33イイ|
|
68
|
-
+----+-------+------+
|
69
|
-
EOS
|
70
|
-
},
|
71
|
-
{
|
72
|
-
case_no: 2,
|
73
|
-
case_title: 'use header case',
|
74
|
-
options: {header: %w{header1 header2 header3}},
|
75
|
-
inputs: [[1, 2, 3], [1111, '222アア', '33イイ']],
|
76
|
-
expected: <<-EOS
|
77
|
-
+-------+-------+-------+
|
78
|
-
|header1|header2|header3|
|
79
|
-
+-------+-------+-------+
|
80
|
-
|1 |2 |3 |
|
81
|
-
|1111 |222アア|33イイ |
|
82
|
-
+-------+-------+-------+
|
83
|
-
EOS
|
84
|
-
},
|
85
|
-
{
|
86
|
-
case_no: 3,
|
87
|
-
case_title: 'Enable SeparateEachRow case',
|
88
|
-
options: {separate_each_row: true},
|
89
|
-
inputs: [[1, 2, 3], [1111, '222アア', '33イイ'], [1, 2, 3]],
|
90
|
-
expected: <<-EOS
|
91
|
-
+----+-------+------+
|
92
|
-
|1 |2 |3 |
|
93
|
-
+----+-------+------+
|
94
|
-
|1111|222アア|33イイ|
|
95
|
-
+----+-------+------+
|
96
|
-
|1 |2 |3 |
|
97
|
-
+----+-------+------+
|
98
|
-
EOS
|
99
|
-
},
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
# --
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'kosi'
|
4
|
+
|
5
|
+
describe Kosi::Table do
|
6
|
+
context :initialize do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'no options case',
|
11
|
+
options: nil,
|
12
|
+
attr_name: '@align',
|
13
|
+
expected: Kosi::Align::TYPE::LEFT
|
14
|
+
},
|
15
|
+
{
|
16
|
+
case_no: 2,
|
17
|
+
case_title: 'align options left case',
|
18
|
+
options: { Kosi::OptionKeys::ALIGN => Kosi::Align::TYPE::RIGHT },
|
19
|
+
attr_name: '@align',
|
20
|
+
expected: Kosi::Align::TYPE::RIGHT
|
21
|
+
}
|
22
|
+
]
|
23
|
+
|
24
|
+
cases.each do |c|
|
25
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
26
|
+
begin
|
27
|
+
case_before c
|
28
|
+
|
29
|
+
# -- given --
|
30
|
+
kosi_table = \
|
31
|
+
if c[:options]
|
32
|
+
Kosi::Table.new(c[:options])
|
33
|
+
else
|
34
|
+
Kosi::Table.new
|
35
|
+
end
|
36
|
+
|
37
|
+
# -- when --
|
38
|
+
actual = kosi_table.instance_variable_get(c[:attr_name]).value
|
39
|
+
|
40
|
+
# -- then --
|
41
|
+
expect(actual).to eq(c[:expected])
|
42
|
+
ensure
|
43
|
+
case_after c
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def case_before(c)
|
48
|
+
# implement each case before
|
49
|
+
end
|
50
|
+
|
51
|
+
def case_after(c)
|
52
|
+
# implement each case after
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context :render do
|
58
|
+
cases = [
|
59
|
+
{
|
60
|
+
case_no: 1,
|
61
|
+
case_title: 'valid case',
|
62
|
+
options: nil,
|
63
|
+
inputs: [[1, 2, 3], [1111, '222アア', '33イイ']],
|
64
|
+
expected: <<-EOS
|
65
|
+
+----+-------+------+
|
66
|
+
|1 |2 |3 |
|
67
|
+
|1111|222アア|33イイ|
|
68
|
+
+----+-------+------+
|
69
|
+
EOS
|
70
|
+
},
|
71
|
+
{
|
72
|
+
case_no: 2,
|
73
|
+
case_title: 'use header case',
|
74
|
+
options: {header: %w{header1 header2 header3}},
|
75
|
+
inputs: [[1, 2, 3], [1111, '222アア', '33イイ']],
|
76
|
+
expected: <<-EOS
|
77
|
+
+-------+-------+-------+
|
78
|
+
|header1|header2|header3|
|
79
|
+
+-------+-------+-------+
|
80
|
+
|1 |2 |3 |
|
81
|
+
|1111 |222アア|33イイ |
|
82
|
+
+-------+-------+-------+
|
83
|
+
EOS
|
84
|
+
},
|
85
|
+
{
|
86
|
+
case_no: 3,
|
87
|
+
case_title: 'Enable SeparateEachRow case',
|
88
|
+
options: {separate_each_row: true},
|
89
|
+
inputs: [[1, 2, 3], [1111, '222アア', '33イイ'], [1, 2, 3]],
|
90
|
+
expected: <<-EOS
|
91
|
+
+----+-------+------+
|
92
|
+
|1 |2 |3 |
|
93
|
+
+----+-------+------+
|
94
|
+
|1111|222アア|33イイ|
|
95
|
+
+----+-------+------+
|
96
|
+
|1 |2 |3 |
|
97
|
+
+----+-------+------+
|
98
|
+
EOS
|
99
|
+
},
|
100
|
+
{
|
101
|
+
case_no: 4,
|
102
|
+
case_title: 'use ANSI Escape sequence case',
|
103
|
+
options: nil,
|
104
|
+
inputs: [["\e[31mhello\e[0m"]],
|
105
|
+
expected: <<-EOS
|
106
|
+
+-----+
|
107
|
+
|\e[31mhello\e[0m|
|
108
|
+
+-----+
|
109
|
+
EOS
|
110
|
+
},
|
111
|
+
]
|
112
|
+
|
113
|
+
cases.each do |c|
|
114
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
115
|
+
begin
|
116
|
+
case_before c
|
117
|
+
|
118
|
+
# -- given --
|
119
|
+
kosi_table = \
|
120
|
+
if c[:options]
|
121
|
+
Kosi::Table.new(c[:options])
|
122
|
+
else
|
123
|
+
Kosi::Table.new
|
124
|
+
end
|
125
|
+
|
126
|
+
# -- when --
|
127
|
+
actual = kosi_table.render(c[:inputs])
|
128
|
+
|
129
|
+
# -- then --
|
130
|
+
expect(actual).to eq(c[:expected])
|
131
|
+
ensure
|
132
|
+
case_after c
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def case_before(c)
|
137
|
+
# implement each case before
|
138
|
+
end
|
139
|
+
|
140
|
+
def case_after(c)
|
141
|
+
# implement each case after
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kosi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -108,7 +108,6 @@ files:
|
|
108
108
|
- .travis.yml
|
109
109
|
- Gemfile
|
110
110
|
- LICENSE.txt
|
111
|
-
- README.html
|
112
111
|
- README.md
|
113
112
|
- Rakefile
|
114
113
|
- kosi.gemspec
|
data/README.html
DELETED
@@ -1,273 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html lang="ja">
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8">
|
5
|
-
<title>Markdown Preview</title>
|
6
|
-
<link rel="stylesheet" href="C:\Users\tabei\AppData\Roaming\Sublime Text 2\Packages\User\markdown_template\styles\default.css">
|
7
|
-
<link rel="stylesheet" href="C:\Users\tabei\AppData\Roaming\Sublime Text 2\Packages\User\markdown_template\github.css">
|
8
|
-
<script src="C:\Users\tabei\AppData\Roaming\Sublime Text 2\Packages\User\markdown_template\highlight.pack.js"></script>
|
9
|
-
<script>hljs.initHighlightingOnLoad();</script>
|
10
|
-
</head>
|
11
|
-
<body>
|
12
|
-
<h1 id="kosi">Kosi</h1>
|
13
|
-
<p>ターミナル用表フォーマットサポートツール。格子。</p>
|
14
|
-
<h2 id="installation">Installation</h2>
|
15
|
-
<p>Add this line to your application's Gemfile:</p>
|
16
|
-
<pre><code>gem 'kosi'
|
17
|
-
</code></pre>
|
18
|
-
<p>And then execute:</p>
|
19
|
-
<pre><code>$ bundle
|
20
|
-
</code></pre>
|
21
|
-
<p>Or install it yourself as:</p>
|
22
|
-
<pre><code>$ gem install kosi
|
23
|
-
</code></pre>
|
24
|
-
<h2 id="description">Description</h2>
|
25
|
-
<p>2次元配列をテーブルフォーマットにして出力します。<br />
|
26
|
-
terminal-table gemの日本語対応版にあたります。<br />
|
27
|
-
(terminal-tableはASCII対応のみなので全角文字が混ざるとテーブルレイアウトが崩れる) </p>
|
28
|
-
<p>具体的には </p>
|
29
|
-
<ul>
|
30
|
-
<li>Unicode 1-127 => ASCII。1文字分として計算</li>
|
31
|
-
<li>Unicode 65_377(0xff61)..65_439(0xff9f) => 半角カナ。1文字分として計算</li>
|
32
|
-
<li>その他 => 全角として扱う。2文字分として計算</li>
|
33
|
-
</ul>
|
34
|
-
<h2 id="options">Options</h2>
|
35
|
-
<h3 id="align">Align</h3>
|
36
|
-
<p>配置指定。右寄せ、左寄せ、中央を選択可能。 </p>
|
37
|
-
<table>
|
38
|
-
<thead>
|
39
|
-
<tr>
|
40
|
-
<th align="left">設定可能パラメータ</th>
|
41
|
-
<th align="left">説明</th>
|
42
|
-
</tr>
|
43
|
-
</thead>
|
44
|
-
<tbody>
|
45
|
-
<tr>
|
46
|
-
<td align="left">Kosi::Align::TYPE::RIGHT</td>
|
47
|
-
<td align="left">右寄せ</td>
|
48
|
-
</tr>
|
49
|
-
<tr>
|
50
|
-
<td align="left">Kosi::Align::TYPE::LEFT</td>
|
51
|
-
<td align="left">左寄せ。デフォルト</td>
|
52
|
-
</tr>
|
53
|
-
<tr>
|
54
|
-
<td align="left">Kosi::Align::TYPE::CENTER</td>
|
55
|
-
<td align="left">中央</td>
|
56
|
-
</tr>
|
57
|
-
</tbody>
|
58
|
-
</table>
|
59
|
-
<h3 id="connectorchar">ConnectorChar</h3>
|
60
|
-
<p>表の結合部に表示するテキスト。1文字で指定。<br />
|
61
|
-
下記で言うところの 「+」がConnectorChar。 </p>
|
62
|
-
<pre><code>+-----+------+-------+
|
63
|
-
|a |b |c |
|
64
|
-
+-----+------+-------+
|
65
|
-
</code></pre>
|
66
|
-
|
67
|
-
<h3 id="header">Header</h3>
|
68
|
-
<p>表のヘッダー。配列で指定。<br />
|
69
|
-
デフォルトはヘッダーなし。 </p>
|
70
|
-
<h3 id="horizontalborderchar">HorizontalBorderChar</h3>
|
71
|
-
<p>水平線を1文字で設定。<br />
|
72
|
-
デフォルトは「-」 </p>
|
73
|
-
<h3 id="separateeachrow">SeparateEachRow</h3>
|
74
|
-
<p>各行に区切り線を入れるかどうか。<br />
|
75
|
-
デフォルトは「false」 </p>
|
76
|
-
<h3 id="verticalborderchar">VerticalBorderChar</h3>
|
77
|
-
<p>垂直線を1文字で設定。<br />
|
78
|
-
デフォルトは「|」 </p>
|
79
|
-
<h2 id="usage">Usage</h2>
|
80
|
-
<h3 id="オプション指定なし">オプション指定なし</h3>
|
81
|
-
<pre><code class="ruby">require 'kosi'
|
82
|
-
|
83
|
-
kosi = Kosi::Table.new
|
84
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
85
|
-
</code></pre>
|
86
|
-
|
87
|
-
<p>出力<br />
|
88
|
-
※GitHubの表示上ずれているかもしれませんが、等幅フォント利用時にそろいます。</p>
|
89
|
-
<pre><code>+-----+------+-------+
|
90
|
-
|a |b |c |
|
91
|
-
|ほゲ1|ひゲ22|へゲ333|
|
92
|
-
+-----+------+-------+
|
93
|
-
</code></pre>
|
94
|
-
|
95
|
-
<h3 id="align指定">Align指定</h3>
|
96
|
-
<pre><code class="ruby">require 'kosi'
|
97
|
-
|
98
|
-
kosi = Kosi::Table.new({align: Kosi::Align::TYPE::CENTER})
|
99
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
100
|
-
kosi = Kosi::Table.new({align: Kosi::Align::TYPE::RIGHT})
|
101
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
102
|
-
kosi = Kosi::Table.new({align: Kosi::Align::TYPE::LEFT})
|
103
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
104
|
-
</code></pre>
|
105
|
-
|
106
|
-
<p>出力 </p>
|
107
|
-
<pre><code>+-----+------+-------+
|
108
|
-
| a | b | c |
|
109
|
-
|ほゲ1|ひゲ22|へゲ333|
|
110
|
-
+-----+------+-------+
|
111
|
-
+-----+------+-------+
|
112
|
-
| a| b| c|
|
113
|
-
|ほゲ1|ひゲ22|へゲ333|
|
114
|
-
+-----+------+-------+
|
115
|
-
+-----+------+-------+
|
116
|
-
|a |b |c |
|
117
|
-
|ほゲ1|ひゲ22|へゲ333|
|
118
|
-
+-----+------+-------+
|
119
|
-
</code></pre>
|
120
|
-
|
121
|
-
<h3 id="connectorchar指定">ConnectorChar指定</h3>
|
122
|
-
<pre><code class="ruby">require 'kosi'
|
123
|
-
|
124
|
-
kosi = Kosi::Table.new
|
125
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
126
|
-
kosi = Kosi::Table.new({connector_char: 'x'})
|
127
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
128
|
-
kosi = Kosi::Table.new({connector_char: '$'})
|
129
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
130
|
-
</code></pre>
|
131
|
-
|
132
|
-
<p>出力 </p>
|
133
|
-
<pre><code>+-----+------+-------+
|
134
|
-
|a |b |c |
|
135
|
-
|ほゲ1|ひゲ22|へゲ333|
|
136
|
-
+-----+------+-------+
|
137
|
-
x-----x------x-------x
|
138
|
-
|a |b |c |
|
139
|
-
|ほゲ1|ひゲ22|へゲ333|
|
140
|
-
x-----x------x-------x
|
141
|
-
$-----$------$-------$
|
142
|
-
|a |b |c |
|
143
|
-
|ほゲ1|ひゲ22|へゲ333|
|
144
|
-
$-----$------$-------$
|
145
|
-
</code></pre>
|
146
|
-
|
147
|
-
<h3 id="header指定">Header指定</h3>
|
148
|
-
<pre><code class="ruby">require 'kosi'
|
149
|
-
|
150
|
-
kosi = Kosi::Table.new
|
151
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
152
|
-
kosi = Kosi::Table.new({header: %w{column1 column2 column3}})
|
153
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
154
|
-
</code></pre>
|
155
|
-
|
156
|
-
<p>出力 </p>
|
157
|
-
<pre><code>+-----+------+-------+
|
158
|
-
|a |b |c |
|
159
|
-
|ほゲ1|ひゲ22|へゲ333|
|
160
|
-
+-----+------+-------+
|
161
|
-
+-------+-------+-------+
|
162
|
-
|column1|column2|column3|
|
163
|
-
+-------+-------+-------+
|
164
|
-
|a |b |c |
|
165
|
-
|ほゲ1 |ひゲ22 |へゲ333|
|
166
|
-
+-------+-------+-------+
|
167
|
-
</code></pre>
|
168
|
-
|
169
|
-
<h3 id="horizontalborderchar指定">HorizontalBorderChar指定</h3>
|
170
|
-
<pre><code class="ruby">require 'kosi'
|
171
|
-
|
172
|
-
kosi = Kosi::Table.new
|
173
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
174
|
-
kosi = Kosi::Table.new({horizontal_border_char: '*'})
|
175
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
176
|
-
</code></pre>
|
177
|
-
|
178
|
-
<p>出力 </p>
|
179
|
-
<pre><code>+-----+------+-------+
|
180
|
-
|a |b |c |
|
181
|
-
|ほゲ1|ひゲ22|へゲ333|
|
182
|
-
+-----+------+-------+
|
183
|
-
+*****+******+*******+
|
184
|
-
|a |b |c |
|
185
|
-
|ほゲ1|ひゲ22|へゲ333|
|
186
|
-
+*****+******+*******+
|
187
|
-
</code></pre>
|
188
|
-
|
189
|
-
<h3 id="separateeachrow指定">SeparateEachRow指定</h3>
|
190
|
-
<pre><code class="ruby">require 'kosi'
|
191
|
-
|
192
|
-
kosi = Kosi::Table.new
|
193
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333'], [*'a'..'c']])
|
194
|
-
kosi = Kosi::Table.new({separate_each_row: true})
|
195
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333'], [*'a'..'c']])
|
196
|
-
</code></pre>
|
197
|
-
|
198
|
-
<p>出力 </p>
|
199
|
-
<pre><code>+-----+------+-------+
|
200
|
-
|a |b |c |
|
201
|
-
|ほゲ1|ひゲ22|へゲ333|
|
202
|
-
|a |b |c |
|
203
|
-
+-----+------+-------+
|
204
|
-
+-----+------+-------+
|
205
|
-
|a |b |c |
|
206
|
-
+-----+------+-------+
|
207
|
-
|ほゲ1|ひゲ22|へゲ333|
|
208
|
-
+-----+------+-------+
|
209
|
-
|a |b |c |
|
210
|
-
+-----+------+-------+
|
211
|
-
</code></pre>
|
212
|
-
|
213
|
-
<h3 id="verticalborderchar指定">VerticalBorderChar指定</h3>
|
214
|
-
<pre><code class="ruby">require 'kosi'
|
215
|
-
|
216
|
-
kosi = Kosi::Table.new
|
217
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
218
|
-
kosi = Kosi::Table.new({vertical_border_char: '#'})
|
219
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
|
220
|
-
</code></pre>
|
221
|
-
|
222
|
-
<p>出力 </p>
|
223
|
-
<pre><code>+-----+------+-------+
|
224
|
-
|a |b |c |
|
225
|
-
|ほゲ1|ひゲ22|へゲ333|
|
226
|
-
+-----+------+-------+
|
227
|
-
+-----+------+-------+
|
228
|
-
#a #b #c #
|
229
|
-
#ほゲ1#ひゲ22#へゲ333#
|
230
|
-
+-----+------+-------+
|
231
|
-
</code></pre>
|
232
|
-
|
233
|
-
<h3 id="複合オプション">複合オプション</h3>
|
234
|
-
<p>様々なオプションを一気に指定してみます</p>
|
235
|
-
<pre><code class="ruby">require 'kosi'
|
236
|
-
|
237
|
-
kosi = Kosi::Table.new(
|
238
|
-
{
|
239
|
-
align: Kosi::Align::TYPE::CENTER,
|
240
|
-
connector_char: 'x',
|
241
|
-
header: %w{column1 column2 column3},
|
242
|
-
horizontal_border_char: '*',
|
243
|
-
vertical_border_char: '#',
|
244
|
-
separate_each_row: true
|
245
|
-
}
|
246
|
-
)
|
247
|
-
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333'], [*'a'..'c']])
|
248
|
-
</code></pre>
|
249
|
-
|
250
|
-
<p>出力 </p>
|
251
|
-
<pre><code>x*******x*******x*******x
|
252
|
-
#column1#column2#column3#
|
253
|
-
x*******x*******x*******x
|
254
|
-
# a # b # c #
|
255
|
-
x*******x*******x*******x
|
256
|
-
# ほゲ1 #ひゲ22 #へゲ333#
|
257
|
-
x*******x*******x*******x
|
258
|
-
# a # b # c #
|
259
|
-
x*******x*******x*******x
|
260
|
-
</code></pre>
|
261
|
-
|
262
|
-
<h2 id="history">History</h2>
|
263
|
-
<p>version 0.0.1 : first release</p>
|
264
|
-
<h2 id="contributing">Contributing</h2>
|
265
|
-
<ol>
|
266
|
-
<li>Fork it ( https://github.com/[my-github-username]/kosi/fork )</li>
|
267
|
-
<li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
|
268
|
-
<li>Commit your changes (<code>git commit -am 'Add some feature'</code>)</li>
|
269
|
-
<li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
|
270
|
-
<li>Create a new Pull Request</li>
|
271
|
-
</ol>
|
272
|
-
</body>
|
273
|
-
</html>
|