kosi 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,59 +1,59 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'kosi'
|
3
|
-
|
4
|
-
describe Kosi::HorizontalBorderChar do
|
5
|
-
context :value do
|
6
|
-
cases = [
|
7
|
-
{
|
8
|
-
case_no: 1,
|
9
|
-
case_title: 'no options case',
|
10
|
-
options: {},
|
11
|
-
expected: Kosi::HorizontalBorderChar::DEFAULT
|
12
|
-
},
|
13
|
-
{
|
14
|
-
case_no: 2,
|
15
|
-
case_title: 'valid horizontal_border_char options case',
|
16
|
-
options: { Kosi::OptionKeys::HORIZONTAL_BORDER_CHAR => '@' },
|
17
|
-
expected: '@'
|
18
|
-
},
|
19
|
-
{
|
20
|
-
case_no: 3,
|
21
|
-
case_title: 'invalid horizontal_border_char options case',
|
22
|
-
options: { Kosi::OptionKeys::HORIZONTAL_BORDER_CHAR => '--' },
|
23
|
-
expect_error: true
|
24
|
-
}
|
25
|
-
]
|
26
|
-
|
27
|
-
cases.each do |c|
|
28
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
29
|
-
begin
|
30
|
-
case_before c
|
31
|
-
|
32
|
-
# -- given --
|
33
|
-
if c[:expect_error]
|
34
|
-
-> { Kosi::HorizontalBorderChar.new(c[:options]) }
|
35
|
-
.should raise_error(ArgumentError)
|
36
|
-
next
|
37
|
-
end
|
38
|
-
horizontal_border_char = Kosi::HorizontalBorderChar.new(c[:options])
|
39
|
-
|
40
|
-
# -- when --
|
41
|
-
actual = horizontal_border_char.value
|
42
|
-
|
43
|
-
# -- then --
|
44
|
-
expect(actual).to eq(c[:expected])
|
45
|
-
ensure
|
46
|
-
case_after c
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def case_before(c)
|
51
|
-
# implement each case before
|
52
|
-
end
|
53
|
-
|
54
|
-
def case_after(c)
|
55
|
-
# implement each case after
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kosi'
|
3
|
+
|
4
|
+
describe Kosi::HorizontalBorderChar do
|
5
|
+
context :value do
|
6
|
+
cases = [
|
7
|
+
{
|
8
|
+
case_no: 1,
|
9
|
+
case_title: 'no options case',
|
10
|
+
options: {},
|
11
|
+
expected: Kosi::HorizontalBorderChar::DEFAULT
|
12
|
+
},
|
13
|
+
{
|
14
|
+
case_no: 2,
|
15
|
+
case_title: 'valid horizontal_border_char options case',
|
16
|
+
options: { Kosi::OptionKeys::HORIZONTAL_BORDER_CHAR => '@' },
|
17
|
+
expected: '@'
|
18
|
+
},
|
19
|
+
{
|
20
|
+
case_no: 3,
|
21
|
+
case_title: 'invalid horizontal_border_char options case',
|
22
|
+
options: { Kosi::OptionKeys::HORIZONTAL_BORDER_CHAR => '--' },
|
23
|
+
expect_error: true
|
24
|
+
}
|
25
|
+
]
|
26
|
+
|
27
|
+
cases.each do |c|
|
28
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
29
|
+
begin
|
30
|
+
case_before c
|
31
|
+
|
32
|
+
# -- given --
|
33
|
+
if c[:expect_error]
|
34
|
+
-> { Kosi::HorizontalBorderChar.new(c[:options]) }
|
35
|
+
.should raise_error(ArgumentError)
|
36
|
+
next
|
37
|
+
end
|
38
|
+
horizontal_border_char = Kosi::HorizontalBorderChar.new(c[:options])
|
39
|
+
|
40
|
+
# -- when --
|
41
|
+
actual = horizontal_border_char.value
|
42
|
+
|
43
|
+
# -- then --
|
44
|
+
expect(actual).to eq(c[:expected])
|
45
|
+
ensure
|
46
|
+
case_after c
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def case_before(c)
|
51
|
+
# implement each case before
|
52
|
+
end
|
53
|
+
|
54
|
+
def case_after(c)
|
55
|
+
# implement each case after
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,55 +1,55 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'kosi'
|
4
|
-
|
5
|
-
describe Kosi::SeparateEachRow do
|
6
|
-
context :value do
|
7
|
-
cases = [
|
8
|
-
{
|
9
|
-
case_no: 1,
|
10
|
-
case_title: 'no options case',
|
11
|
-
options: {},
|
12
|
-
expected: Kosi::SeparateEachRow::DEFAULT
|
13
|
-
},
|
14
|
-
{
|
15
|
-
case_no: 2,
|
16
|
-
case_title: 'seprate_each_row options true case',
|
17
|
-
options: { Kosi::OptionKeys::SEPARATE_EACH_ROW => true },
|
18
|
-
expected: true
|
19
|
-
},
|
20
|
-
{
|
21
|
-
case_no: 3,
|
22
|
-
case_title: 'seprate_each_row options false case',
|
23
|
-
options: { Kosi::OptionKeys::SEPARATE_EACH_ROW => false },
|
24
|
-
expected: false
|
25
|
-
}
|
26
|
-
]
|
27
|
-
|
28
|
-
cases.each do |c|
|
29
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
30
|
-
begin
|
31
|
-
case_before c
|
32
|
-
|
33
|
-
# -- given --
|
34
|
-
separate_each_row = Kosi::SeparateEachRow.new(c[:options])
|
35
|
-
|
36
|
-
# -- when --
|
37
|
-
actual = separate_each_row.value
|
38
|
-
|
39
|
-
# -- then --
|
40
|
-
expect(actual).to eq(c[:expected])
|
41
|
-
ensure
|
42
|
-
case_after c
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def case_before(c)
|
47
|
-
# implement each case before
|
48
|
-
end
|
49
|
-
|
50
|
-
def case_after(c)
|
51
|
-
# implement each case after
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'kosi'
|
4
|
+
|
5
|
+
describe Kosi::SeparateEachRow do
|
6
|
+
context :value do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'no options case',
|
11
|
+
options: {},
|
12
|
+
expected: Kosi::SeparateEachRow::DEFAULT
|
13
|
+
},
|
14
|
+
{
|
15
|
+
case_no: 2,
|
16
|
+
case_title: 'seprate_each_row options true case',
|
17
|
+
options: { Kosi::OptionKeys::SEPARATE_EACH_ROW => true },
|
18
|
+
expected: true
|
19
|
+
},
|
20
|
+
{
|
21
|
+
case_no: 3,
|
22
|
+
case_title: 'seprate_each_row options false case',
|
23
|
+
options: { Kosi::OptionKeys::SEPARATE_EACH_ROW => false },
|
24
|
+
expected: false
|
25
|
+
}
|
26
|
+
]
|
27
|
+
|
28
|
+
cases.each do |c|
|
29
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
30
|
+
begin
|
31
|
+
case_before c
|
32
|
+
|
33
|
+
# -- given --
|
34
|
+
separate_each_row = Kosi::SeparateEachRow.new(c[:options])
|
35
|
+
|
36
|
+
# -- when --
|
37
|
+
actual = separate_each_row.value
|
38
|
+
|
39
|
+
# -- then --
|
40
|
+
expect(actual).to eq(c[:expected])
|
41
|
+
ensure
|
42
|
+
case_after c
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def case_before(c)
|
47
|
+
# implement each case before
|
48
|
+
end
|
49
|
+
|
50
|
+
def case_after(c)
|
51
|
+
# implement each case after
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,56 +1,56 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'kosi/validators/each_array_length_validator'
|
4
|
-
|
5
|
-
describe Kosi::Validators::EachArrayLength do
|
6
|
-
context :validate do
|
7
|
-
cases = [
|
8
|
-
{
|
9
|
-
case_no: 1,
|
10
|
-
case_title: 'Same Length Array case',
|
11
|
-
inputs: [[*1..5], [*6..10]],
|
12
|
-
},
|
13
|
-
{
|
14
|
-
case_no: 2,
|
15
|
-
case_title: 'Zero Length Array case',
|
16
|
-
inputs: [[], []],
|
17
|
-
},
|
18
|
-
{
|
19
|
-
case_no: 3,
|
20
|
-
case_title: 'Different Length Array case',
|
21
|
-
inputs: [[*1..5], [*6..11]],
|
22
|
-
expect_error: true,
|
23
|
-
error_class: ArgumentError
|
24
|
-
},
|
25
|
-
]
|
26
|
-
|
27
|
-
cases.each do |c|
|
28
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
29
|
-
begin
|
30
|
-
case_before c
|
31
|
-
|
32
|
-
# -- given --
|
33
|
-
# nothing
|
34
|
-
|
35
|
-
# -- when/then --
|
36
|
-
if c[:expect_error]
|
37
|
-
expect{ Kosi::Validators::EachArrayLength.validate(c[:inputs]) }.to raise_error(c[:error_class])
|
38
|
-
next
|
39
|
-
else
|
40
|
-
expect{ Kosi::Validators::EachArrayLength.validate(c[:inputs]) }.not_to raise_error
|
41
|
-
end
|
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
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'kosi/validators/each_array_length_validator'
|
4
|
+
|
5
|
+
describe Kosi::Validators::EachArrayLength do
|
6
|
+
context :validate do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'Same Length Array case',
|
11
|
+
inputs: [[*1..5], [*6..10]],
|
12
|
+
},
|
13
|
+
{
|
14
|
+
case_no: 2,
|
15
|
+
case_title: 'Zero Length Array case',
|
16
|
+
inputs: [[], []],
|
17
|
+
},
|
18
|
+
{
|
19
|
+
case_no: 3,
|
20
|
+
case_title: 'Different Length Array case',
|
21
|
+
inputs: [[*1..5], [*6..11]],
|
22
|
+
expect_error: true,
|
23
|
+
error_class: ArgumentError
|
24
|
+
},
|
25
|
+
]
|
26
|
+
|
27
|
+
cases.each do |c|
|
28
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
29
|
+
begin
|
30
|
+
case_before c
|
31
|
+
|
32
|
+
# -- given --
|
33
|
+
# nothing
|
34
|
+
|
35
|
+
# -- when/then --
|
36
|
+
if c[:expect_error]
|
37
|
+
expect{ Kosi::Validators::EachArrayLength.validate(c[:inputs]) }.to raise_error(c[:error_class])
|
38
|
+
next
|
39
|
+
else
|
40
|
+
expect{ Kosi::Validators::EachArrayLength.validate(c[:inputs]) }.not_to raise_error
|
41
|
+
end
|
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
|
+
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'kosi/validators/row_type_validator'
|
4
|
-
|
5
|
-
describe Kosi::Validators::RowType do
|
6
|
-
context :validate do
|
7
|
-
cases = [
|
8
|
-
{
|
9
|
-
case_no: 1,
|
10
|
-
case_title: 'Array case',
|
11
|
-
inputs: ['Array'],
|
12
|
-
},
|
13
|
-
{
|
14
|
-
case_no: 2,
|
15
|
-
case_title: 'Not Array case',
|
16
|
-
inputs: "not Array",
|
17
|
-
expect_error: true,
|
18
|
-
error_class: ArgumentError
|
19
|
-
},
|
20
|
-
]
|
21
|
-
|
22
|
-
cases.each do |c|
|
23
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
24
|
-
begin
|
25
|
-
case_before c
|
26
|
-
|
27
|
-
# -- given --
|
28
|
-
# nothing
|
29
|
-
|
30
|
-
# -- when/then --
|
31
|
-
if c[:expect_error]
|
32
|
-
expect{ Kosi::Validators::RowType.validate(c[:inputs]) }.to raise_error(c[:error_class])
|
33
|
-
next
|
34
|
-
else
|
35
|
-
expect{ Kosi::Validators::RowType.validate(c[:inputs]) }.not_to raise_error
|
36
|
-
end
|
37
|
-
ensure
|
38
|
-
case_after c
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def case_before(c)
|
43
|
-
# implement each case before
|
44
|
-
end
|
45
|
-
|
46
|
-
def case_after(c)
|
47
|
-
# implement each case after
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'kosi/validators/row_type_validator'
|
4
|
+
|
5
|
+
describe Kosi::Validators::RowType do
|
6
|
+
context :validate do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'Array case',
|
11
|
+
inputs: ['Array'],
|
12
|
+
},
|
13
|
+
{
|
14
|
+
case_no: 2,
|
15
|
+
case_title: 'Not Array case',
|
16
|
+
inputs: "not Array",
|
17
|
+
expect_error: true,
|
18
|
+
error_class: ArgumentError
|
19
|
+
},
|
20
|
+
]
|
21
|
+
|
22
|
+
cases.each do |c|
|
23
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
24
|
+
begin
|
25
|
+
case_before c
|
26
|
+
|
27
|
+
# -- given --
|
28
|
+
# nothing
|
29
|
+
|
30
|
+
# -- when/then --
|
31
|
+
if c[:expect_error]
|
32
|
+
expect{ Kosi::Validators::RowType.validate(c[:inputs]) }.to raise_error(c[:error_class])
|
33
|
+
next
|
34
|
+
else
|
35
|
+
expect{ Kosi::Validators::RowType.validate(c[:inputs]) }.not_to raise_error
|
36
|
+
end
|
37
|
+
ensure
|
38
|
+
case_after c
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def case_before(c)
|
43
|
+
# implement each case before
|
44
|
+
end
|
45
|
+
|
46
|
+
def case_after(c)
|
47
|
+
# implement each case after
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,59 +1,59 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'kosi'
|
3
|
-
|
4
|
-
describe Kosi::VerticalBorderChar do
|
5
|
-
context :value do
|
6
|
-
cases = [
|
7
|
-
{
|
8
|
-
case_no: 1,
|
9
|
-
case_title: 'no options case',
|
10
|
-
options: {},
|
11
|
-
expected: Kosi::VerticalBorderChar::DEFAULT
|
12
|
-
},
|
13
|
-
{
|
14
|
-
case_no: 2,
|
15
|
-
case_title: 'valid vertical_border_char options case',
|
16
|
-
options: { Kosi::OptionKeys::VERTICAL_BORDER_CHAR => '@' },
|
17
|
-
expected: '@'
|
18
|
-
},
|
19
|
-
{
|
20
|
-
case_no: 3,
|
21
|
-
case_title: 'invalid vertical_border_char options case',
|
22
|
-
options: { Kosi::OptionKeys::VERTICAL_BORDER_CHAR => '||' },
|
23
|
-
expect_error: true
|
24
|
-
}
|
25
|
-
]
|
26
|
-
|
27
|
-
cases.each do |c|
|
28
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
29
|
-
begin
|
30
|
-
case_before c
|
31
|
-
|
32
|
-
# -- given --
|
33
|
-
if c[:expect_error]
|
34
|
-
-> { Kosi::VerticalBorderChar.new(c[:options]) }
|
35
|
-
.should raise_error(ArgumentError)
|
36
|
-
next
|
37
|
-
end
|
38
|
-
vertical_border_char = Kosi::VerticalBorderChar.new(c[:options])
|
39
|
-
|
40
|
-
# -- when --
|
41
|
-
actual = vertical_border_char.value
|
42
|
-
|
43
|
-
# -- then --
|
44
|
-
expect(actual).to eq(c[:expected])
|
45
|
-
ensure
|
46
|
-
case_after c
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def case_before(c)
|
51
|
-
# implement each case before
|
52
|
-
end
|
53
|
-
|
54
|
-
def case_after(c)
|
55
|
-
# implement each case after
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kosi'
|
3
|
+
|
4
|
+
describe Kosi::VerticalBorderChar do
|
5
|
+
context :value do
|
6
|
+
cases = [
|
7
|
+
{
|
8
|
+
case_no: 1,
|
9
|
+
case_title: 'no options case',
|
10
|
+
options: {},
|
11
|
+
expected: Kosi::VerticalBorderChar::DEFAULT
|
12
|
+
},
|
13
|
+
{
|
14
|
+
case_no: 2,
|
15
|
+
case_title: 'valid vertical_border_char options case',
|
16
|
+
options: { Kosi::OptionKeys::VERTICAL_BORDER_CHAR => '@' },
|
17
|
+
expected: '@'
|
18
|
+
},
|
19
|
+
{
|
20
|
+
case_no: 3,
|
21
|
+
case_title: 'invalid vertical_border_char options case',
|
22
|
+
options: { Kosi::OptionKeys::VERTICAL_BORDER_CHAR => '||' },
|
23
|
+
expect_error: true
|
24
|
+
}
|
25
|
+
]
|
26
|
+
|
27
|
+
cases.each do |c|
|
28
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
29
|
+
begin
|
30
|
+
case_before c
|
31
|
+
|
32
|
+
# -- given --
|
33
|
+
if c[:expect_error]
|
34
|
+
-> { Kosi::VerticalBorderChar.new(c[:options]) }
|
35
|
+
.should raise_error(ArgumentError)
|
36
|
+
next
|
37
|
+
end
|
38
|
+
vertical_border_char = Kosi::VerticalBorderChar.new(c[:options])
|
39
|
+
|
40
|
+
# -- when --
|
41
|
+
actual = vertical_border_char.value
|
42
|
+
|
43
|
+
# -- then --
|
44
|
+
expect(actual).to eq(c[:expected])
|
45
|
+
ensure
|
46
|
+
case_after c
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def case_before(c)
|
51
|
+
# implement each case before
|
52
|
+
end
|
53
|
+
|
54
|
+
def case_after(c)
|
55
|
+
# implement each case after
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|