kosi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.rubocop.yml +12 -0
- data/.travis.yml +8 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.html +273 -0
- data/README.md +290 -0
- data/Rakefile +8 -0
- data/kosi.gemspec +28 -0
- data/lib/kosi.rb +13 -0
- data/lib/kosi/align.rb +33 -0
- data/lib/kosi/char_option.rb +17 -0
- data/lib/kosi/connector_char.rb +26 -0
- data/lib/kosi/header.rb +18 -0
- data/lib/kosi/horizontal_border_char.rb +26 -0
- data/lib/kosi/options.rb +15 -0
- data/lib/kosi/separate_each_row.rb +15 -0
- data/lib/kosi/validators.rb +3 -0
- data/lib/kosi/validators/each_array_length_validator.rb +21 -0
- data/lib/kosi/validators/row_type_validator.rb +19 -0
- data/lib/kosi/version.rb +4 -0
- data/lib/kosi/vertical_border_char.rb +26 -0
- data/lib/table.rb +138 -0
- data/spec/kosi/align_spec.rb +77 -0
- data/spec/kosi/connector_char_spec.rb +59 -0
- data/spec/kosi/header_spec.rb +93 -0
- data/spec/kosi/horizontal_border_char_spec.rb +59 -0
- data/spec/kosi/separate_each_row_spec.rb +55 -0
- data/spec/kosi/validators/each_array_length_validator_spec.rb +56 -0
- data/spec/kosi/validators/row_type_validator_spec.rb +51 -0
- data/spec/kosi/vertical_border_char_spec.rb +59 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/table_spec.rb +134 -0
- metadata +173 -0
data/spec/table_spec.rb
ADDED
@@ -0,0 +1,134 @@
|
|
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
|
+
cases.each do |c|
|
103
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
104
|
+
begin
|
105
|
+
case_before c
|
106
|
+
|
107
|
+
# -- given --
|
108
|
+
kosi_table = \
|
109
|
+
if c[:options]
|
110
|
+
Kosi::Table.new(c[:options])
|
111
|
+
else
|
112
|
+
Kosi::Table.new
|
113
|
+
end
|
114
|
+
|
115
|
+
# -- when --
|
116
|
+
actual = kosi_table.render(c[:inputs])
|
117
|
+
|
118
|
+
# -- then --
|
119
|
+
expect(actual).to eq(c[:expected])
|
120
|
+
ensure
|
121
|
+
case_after c
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def case_before(c)
|
126
|
+
# implement each case before
|
127
|
+
end
|
128
|
+
|
129
|
+
def case_after(c)
|
130
|
+
# implement each case after
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kosi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tbpgr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemodel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.0.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.0.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.14.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.14.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.8.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.8.2
|
97
|
+
description: terminal table format for japanese
|
98
|
+
email:
|
99
|
+
- tbpgr@tbpgr.jp
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .coveralls.yml
|
105
|
+
- .gitignore
|
106
|
+
- .rspec
|
107
|
+
- .rubocop.yml
|
108
|
+
- .travis.yml
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.html
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- kosi.gemspec
|
115
|
+
- lib/kosi.rb
|
116
|
+
- lib/kosi/align.rb
|
117
|
+
- lib/kosi/char_option.rb
|
118
|
+
- lib/kosi/connector_char.rb
|
119
|
+
- lib/kosi/header.rb
|
120
|
+
- lib/kosi/horizontal_border_char.rb
|
121
|
+
- lib/kosi/options.rb
|
122
|
+
- lib/kosi/separate_each_row.rb
|
123
|
+
- lib/kosi/validators.rb
|
124
|
+
- lib/kosi/validators/each_array_length_validator.rb
|
125
|
+
- lib/kosi/validators/row_type_validator.rb
|
126
|
+
- lib/kosi/version.rb
|
127
|
+
- lib/kosi/vertical_border_char.rb
|
128
|
+
- lib/table.rb
|
129
|
+
- spec/kosi/align_spec.rb
|
130
|
+
- spec/kosi/connector_char_spec.rb
|
131
|
+
- spec/kosi/header_spec.rb
|
132
|
+
- spec/kosi/horizontal_border_char_spec.rb
|
133
|
+
- spec/kosi/separate_each_row_spec.rb
|
134
|
+
- spec/kosi/validators/each_array_length_validator_spec.rb
|
135
|
+
- spec/kosi/validators/row_type_validator_spec.rb
|
136
|
+
- spec/kosi/vertical_border_char_spec.rb
|
137
|
+
- spec/spec_helper.rb
|
138
|
+
- spec/table_spec.rb
|
139
|
+
homepage: https://github.com/tbpgr/kosi
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.0.14
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: terminal table format for japanese
|
163
|
+
test_files:
|
164
|
+
- spec/kosi/align_spec.rb
|
165
|
+
- spec/kosi/connector_char_spec.rb
|
166
|
+
- spec/kosi/header_spec.rb
|
167
|
+
- spec/kosi/horizontal_border_char_spec.rb
|
168
|
+
- spec/kosi/separate_each_row_spec.rb
|
169
|
+
- spec/kosi/validators/each_array_length_validator_spec.rb
|
170
|
+
- spec/kosi/validators/row_type_validator_spec.rb
|
171
|
+
- spec/kosi/vertical_border_char_spec.rb
|
172
|
+
- spec/spec_helper.rb
|
173
|
+
- spec/table_spec.rb
|