text-table 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +2 -3
- data/.gitignore +6 -24
- data/CHANGELOG.rdoc +6 -2
- data/Gemfile +3 -0
- data/README.rdoc +33 -35
- data/lib/text-table/table.rb +1 -0
- data/lib/text-table/version.rb +5 -0
- data/spec/cell_spec.rb +1 -1
- data/spec/enumerable_spec.rb +15 -15
- data/spec/integration/alignment_spec.rb +183 -0
- data/spec/integration/boundaries_spec.rb +113 -0
- data/spec/integration/column_spans_spec.rb +226 -0
- data/spec/integration/parts_spec.rb +68 -0
- data/spec/integration/performance_spec.rb +19 -0
- data/spec/integration_helper.rb +13 -0
- data/spec/spec_helper.rb +4 -10
- data/text-table.gemspec +19 -65
- metadata +57 -71
- data/Rakefile +0 -46
- data/VERSION +0 -1
- data/spec/spec.opts +0 -2
- data/spec/table_spec.rb +0 -491
data/text-table.gemspec
CHANGED
@@ -1,68 +1,22 @@
|
|
1
|
-
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
require File.expand_path('../lib/text-table/version', __FILE__)
|
5
2
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'text-table'
|
5
|
+
gem.version = Text::Table::VERSION
|
6
|
+
gem.authors = ['Aaron Tinio']
|
7
|
+
gem.email = 'aptinio@gmail.com'
|
8
|
+
gem.summary = 'A feature-rich, easy-to-use plain text table formatter.'
|
9
|
+
gem.description = %w[
|
10
|
+
Allows you to easily create and format plain text tables,
|
11
|
+
useful when working with the terminal or when you want to quickly print
|
12
|
+
formatted tables to a dot-matrix printer.
|
13
|
+
].join ' '
|
14
|
+
gem.homepage = 'https://github.com/aptinio/text-table'
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"CHANGELOG.rdoc",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/text-table.rb",
|
28
|
-
"lib/text-table/cell.rb",
|
29
|
-
"lib/text-table/enumerable.rb",
|
30
|
-
"lib/text-table/row.rb",
|
31
|
-
"lib/text-table/symbol.rb",
|
32
|
-
"lib/text-table/table.rb",
|
33
|
-
"spec/cell_spec.rb",
|
34
|
-
"spec/enumerable_spec.rb",
|
35
|
-
"spec/spec.opts",
|
36
|
-
"spec/spec_helper.rb",
|
37
|
-
"spec/table_spec.rb",
|
38
|
-
"text-table.gemspec"
|
39
|
-
]
|
40
|
-
s.homepage = %q{http://github.com/aptinio/text-table}
|
41
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
-
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version = %q{1.3.6}
|
44
|
-
s.summary = %q{A feature-rich, easy-to-use plain text table formatter.}
|
45
|
-
s.test_files = [
|
46
|
-
"spec/spec_helper.rb",
|
47
|
-
"spec/cell_spec.rb",
|
48
|
-
"spec/table_spec.rb",
|
49
|
-
"spec/enumerable_spec.rb"
|
50
|
-
]
|
51
|
-
|
52
|
-
if s.respond_to? :specification_version then
|
53
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
|
-
s.specification_version = 3
|
55
|
-
|
56
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
57
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
58
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
59
|
-
else
|
60
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
61
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
62
|
-
end
|
63
|
-
else
|
64
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
65
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
66
|
-
end
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.test_files = `git ls-files -- spec/*`.split($/)
|
19
|
+
gem.extra_rdoc_files = %w[LICENSE README.rdoc]
|
20
|
+
gem.add_development_dependency 'rspec', '~> 2'
|
21
|
+
gem.license = 'MIT'
|
67
22
|
end
|
68
|
-
|
metadata
CHANGED
@@ -1,107 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: text-table
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 2
|
8
|
-
- 2
|
9
|
-
version: 1.2.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.3
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Aaron Tinio
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: rspec
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
30
20
|
type: :development
|
31
|
-
version_requirements: *id001
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: jeweler
|
34
21
|
prerelease: false
|
35
|
-
|
36
|
-
requirements:
|
37
|
-
- -
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
description: Allows you to easily create and format plain text tables, useful when working with the terminal or when you want to quickly print formatted tables to a dot-matrix printer.
|
45
|
-
email: aptinio@yahoo.com
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
description: Allows you to easily create and format plain text tables, useful when
|
28
|
+
working with the terminal or when you want to quickly print formatted tables to
|
29
|
+
a dot-matrix printer.
|
30
|
+
email: aptinio@gmail.com
|
46
31
|
executables: []
|
47
|
-
|
48
32
|
extensions: []
|
49
|
-
|
50
|
-
extra_rdoc_files:
|
33
|
+
extra_rdoc_files:
|
51
34
|
- LICENSE
|
52
35
|
- README.rdoc
|
53
|
-
files:
|
36
|
+
files:
|
54
37
|
- .document
|
55
38
|
- .gitignore
|
56
39
|
- CHANGELOG.rdoc
|
40
|
+
- Gemfile
|
57
41
|
- LICENSE
|
58
42
|
- README.rdoc
|
59
|
-
- Rakefile
|
60
|
-
- VERSION
|
61
43
|
- lib/text-table.rb
|
62
44
|
- lib/text-table/cell.rb
|
63
45
|
- lib/text-table/enumerable.rb
|
64
46
|
- lib/text-table/row.rb
|
65
47
|
- lib/text-table/symbol.rb
|
66
48
|
- lib/text-table/table.rb
|
49
|
+
- lib/text-table/version.rb
|
67
50
|
- spec/cell_spec.rb
|
68
51
|
- spec/enumerable_spec.rb
|
69
|
-
- spec/
|
52
|
+
- spec/integration/alignment_spec.rb
|
53
|
+
- spec/integration/boundaries_spec.rb
|
54
|
+
- spec/integration/column_spans_spec.rb
|
55
|
+
- spec/integration/parts_spec.rb
|
56
|
+
- spec/integration/performance_spec.rb
|
57
|
+
- spec/integration_helper.rb
|
70
58
|
- spec/spec_helper.rb
|
71
|
-
- spec/table_spec.rb
|
72
59
|
- text-table.gemspec
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
60
|
+
homepage: https://github.com/aptinio/text-table
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
77
64
|
post_install_message:
|
78
|
-
rdoc_options:
|
79
|
-
|
80
|
-
require_paths:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
81
67
|
- lib
|
82
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
version: "0"
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
96
78
|
requirements: []
|
97
|
-
|
98
79
|
rubyforge_project:
|
99
|
-
rubygems_version:
|
80
|
+
rubygems_version: 2.0.3
|
100
81
|
signing_key:
|
101
|
-
specification_version:
|
82
|
+
specification_version: 4
|
102
83
|
summary: A feature-rich, easy-to-use plain text table formatter.
|
103
|
-
test_files:
|
104
|
-
- spec/spec_helper.rb
|
84
|
+
test_files:
|
105
85
|
- spec/cell_spec.rb
|
106
|
-
- spec/table_spec.rb
|
107
86
|
- spec/enumerable_spec.rb
|
87
|
+
- spec/integration/alignment_spec.rb
|
88
|
+
- spec/integration/boundaries_spec.rb
|
89
|
+
- spec/integration/column_spans_spec.rb
|
90
|
+
- spec/integration/parts_spec.rb
|
91
|
+
- spec/integration/performance_spec.rb
|
92
|
+
- spec/integration_helper.rb
|
93
|
+
- spec/spec_helper.rb
|
data/Rakefile
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "text-table"
|
8
|
-
gem.summary = %Q{A feature-rich, easy-to-use plain text table formatter.}
|
9
|
-
gem.description = %Q{Allows you to easily create and format plain text tables, useful when working with the terminal or when you want to quickly print formatted tables to a dot-matrix printer.}
|
10
|
-
gem.email = "aptinio@yahoo.com"
|
11
|
-
gem.homepage = "http://github.com/aptinio/text-table"
|
12
|
-
gem.authors = ["Aaron Tinio"]
|
13
|
-
gem.add_development_dependency 'rspec'
|
14
|
-
gem.add_development_dependency 'jeweler'
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
-
end
|
17
|
-
Jeweler::GemcutterTasks.new
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
-
end
|
21
|
-
|
22
|
-
require 'spec/rake/spectask'
|
23
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
-
spec.libs << 'lib' << 'spec'
|
25
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
-
end
|
27
|
-
|
28
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
-
spec.libs << 'lib' << 'spec'
|
30
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
-
spec.rcov = true
|
32
|
-
end
|
33
|
-
|
34
|
-
task :spec => :check_dependencies
|
35
|
-
|
36
|
-
task :default => :spec
|
37
|
-
|
38
|
-
require 'rake/rdoctask'
|
39
|
-
Rake::RDocTask.new do |rdoc|
|
40
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
-
|
42
|
-
rdoc.rdoc_dir = 'rdoc'
|
43
|
-
rdoc.title = "text-table #{version}"
|
44
|
-
rdoc.rdoc_files.include('README*')
|
45
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.2.2
|
data/spec/spec.opts
DELETED
data/spec/table_spec.rb
DELETED
@@ -1,491 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Text::Table do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@head = %w( a bb ccc dddd )
|
7
|
-
@rows = [
|
8
|
-
%w( aa bbb cccc d ),
|
9
|
-
%w( aaa bbbb c dd ),
|
10
|
-
]
|
11
|
-
@foot = %w( aaaa b cc ddd )
|
12
|
-
@table = Text::Table.new :rows => @rows, :head => @head, :foot => @foot
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should initialize with an empty array for its rows as default' do
|
16
|
-
@table = Text::Table.new
|
17
|
-
@table.rows.should == []
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'should allow setting of attributes' do
|
21
|
-
|
22
|
-
it 'passed as an options hash' do
|
23
|
-
@table = Text::Table.new :rows => @rows
|
24
|
-
@table.rows.should == @rows
|
25
|
-
@table = Text::Table.new :rows => @rows, :horizontal_padding => 2
|
26
|
-
@table.rows.should == @rows
|
27
|
-
@table.horizontal_padding.should == 2
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'inside a block' do
|
31
|
-
@table = Text::Table.new do |t|
|
32
|
-
t.rows = @rows
|
33
|
-
end
|
34
|
-
@table.rows.should == @rows
|
35
|
-
|
36
|
-
@table = Text::Table.new do |t|
|
37
|
-
t.horizontal_padding = 2
|
38
|
-
end
|
39
|
-
@table.horizontal_padding.should == 2
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
describe 'should properly render' do
|
45
|
-
|
46
|
-
it 'column widths' do
|
47
|
-
@table.column_widths.should == [4, 4, 4, 4]
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'rows' do
|
51
|
-
@table = Text::Table.new :rows => @rows
|
52
|
-
@table.to_s.should == <<-EOS.deindent
|
53
|
-
+-----+------+------+----+
|
54
|
-
| aa | bbb | cccc | d |
|
55
|
-
| aaa | bbbb | c | dd |
|
56
|
-
+-----+------+------+----+
|
57
|
-
EOS
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'rows with unequal number of cells'
|
61
|
-
|
62
|
-
it 'headers' do
|
63
|
-
@table = Text::Table.new :rows => @rows, :head => @head
|
64
|
-
@table.to_s.should == <<-EOS.deindent
|
65
|
-
+-----+------+------+------+
|
66
|
-
| a | bb | ccc | dddd |
|
67
|
-
+-----+------+------+------+
|
68
|
-
| aa | bbb | cccc | d |
|
69
|
-
| aaa | bbbb | c | dd |
|
70
|
-
+-----+------+------+------+
|
71
|
-
EOS
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'footers' do
|
75
|
-
@table = Text::Table.new :rows => @rows, :foot => @foot
|
76
|
-
@table.to_s.should == <<-EOS.deindent
|
77
|
-
+------+------+------+-----+
|
78
|
-
| aa | bbb | cccc | d |
|
79
|
-
| aaa | bbbb | c | dd |
|
80
|
-
+------+------+------+-----+
|
81
|
-
| aaaa | b | cc | ddd |
|
82
|
-
+------+------+------+-----+
|
83
|
-
EOS
|
84
|
-
end
|
85
|
-
|
86
|
-
it "separators" do
|
87
|
-
@table = Text::Table.new :rows => @rows.insert(1, :separator)
|
88
|
-
@table.to_s.should == <<-EOS.deindent
|
89
|
-
+-----+------+------+----+
|
90
|
-
| aa | bbb | cccc | d |
|
91
|
-
+-----+------+------+----+
|
92
|
-
| aaa | bbbb | c | dd |
|
93
|
-
+-----+------+------+----+
|
94
|
-
EOS
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'horizontal boundaries' do
|
98
|
-
@table.horizontal_boundary = ':'
|
99
|
-
@table.to_s.should == <<-EOS.deindent
|
100
|
-
+------+------+------+------+
|
101
|
-
: a : bb : ccc : dddd :
|
102
|
-
+------+------+------+------+
|
103
|
-
: aa : bbb : cccc : d :
|
104
|
-
: aaa : bbbb : c : dd :
|
105
|
-
+------+------+------+------+
|
106
|
-
: aaaa : b : cc : ddd :
|
107
|
-
+------+------+------+------+
|
108
|
-
EOS
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'vertical boundaries' do
|
112
|
-
@table.vertical_boundary = '='
|
113
|
-
@table.to_s.should == <<-EOS.deindent
|
114
|
-
+======+======+======+======+
|
115
|
-
| a | bb | ccc | dddd |
|
116
|
-
+======+======+======+======+
|
117
|
-
| aa | bbb | cccc | d |
|
118
|
-
| aaa | bbbb | c | dd |
|
119
|
-
+======+======+======+======+
|
120
|
-
| aaaa | b | cc | ddd |
|
121
|
-
+======+======+======+======+
|
122
|
-
EOS
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'boundary interserctions' do
|
126
|
-
@table.boundary_intersection = '*'
|
127
|
-
@table.to_s.should == <<-EOS.deindent
|
128
|
-
*------*------*------*------*
|
129
|
-
| a | bb | ccc | dddd |
|
130
|
-
*------*------*------*------*
|
131
|
-
| aa | bbb | cccc | d |
|
132
|
-
| aaa | bbbb | c | dd |
|
133
|
-
*------*------*------*------*
|
134
|
-
| aaaa | b | cc | ddd |
|
135
|
-
*------*------*------*------*
|
136
|
-
EOS
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'double horizontal boundaries' do
|
140
|
-
@table.horizontal_boundary = '||'
|
141
|
-
@table.boundary_intersection = '++'
|
142
|
-
@table.to_s.should == <<-EOS.deindent
|
143
|
-
++------++------++------++------++
|
144
|
-
|| a || bb || ccc || dddd ||
|
145
|
-
++------++------++------++------++
|
146
|
-
|| aa || bbb || cccc || d ||
|
147
|
-
|| aaa || bbbb || c || dd ||
|
148
|
-
++------++------++------++------++
|
149
|
-
|| aaaa || b || cc || ddd ||
|
150
|
-
++------++------++------++------++
|
151
|
-
EOS
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'double horizontal boundaries with spanned cells' do
|
155
|
-
@table.horizontal_boundary = '||'
|
156
|
-
@table.boundary_intersection = '++'
|
157
|
-
@table.rows << :separator
|
158
|
-
@table.rows << [{:value => 'x', :colspan => 2, :align => :right}, 'c', 'd']
|
159
|
-
@table.to_s.should == <<-EOS.deindent
|
160
|
-
++------++------++------++------++
|
161
|
-
|| a || bb || ccc || dddd ||
|
162
|
-
++------++------++------++------++
|
163
|
-
|| aa || bbb || cccc || d ||
|
164
|
-
|| aaa || bbbb || c || dd ||
|
165
|
-
++------++------++------++------++
|
166
|
-
|| x || c || d ||
|
167
|
-
++------++------++------++------++
|
168
|
-
|| aaaa || b || cc || ddd ||
|
169
|
-
++------++------++------++------++
|
170
|
-
EOS
|
171
|
-
end
|
172
|
-
|
173
|
-
describe 'alignment of' do
|
174
|
-
describe 'headers to the' do
|
175
|
-
it 'left' do
|
176
|
-
@table = Text::Table.new :rows => @rows, :head => @head.map {|h| {:value => h, :align => :left}}
|
177
|
-
@table.to_s.should == <<-EOS.deindent
|
178
|
-
+-----+------+------+------+
|
179
|
-
| a | bb | ccc | dddd |
|
180
|
-
+-----+------+------+------+
|
181
|
-
| aa | bbb | cccc | d |
|
182
|
-
| aaa | bbbb | c | dd |
|
183
|
-
+-----+------+------+------+
|
184
|
-
EOS
|
185
|
-
end
|
186
|
-
it 'center (default)' do
|
187
|
-
@table = Text::Table.new :rows => @rows, :head => @head
|
188
|
-
@table.to_s.should == <<-EOS.deindent
|
189
|
-
+-----+------+------+------+
|
190
|
-
| a | bb | ccc | dddd |
|
191
|
-
+-----+------+------+------+
|
192
|
-
| aa | bbb | cccc | d |
|
193
|
-
| aaa | bbbb | c | dd |
|
194
|
-
+-----+------+------+------+
|
195
|
-
EOS
|
196
|
-
end
|
197
|
-
it 'right' do
|
198
|
-
@table = Text::Table.new :rows => @rows, :head => @head.map {|h| {:value => h, :align => :right}}
|
199
|
-
@table.to_s.should == <<-EOS.deindent
|
200
|
-
+-----+------+------+------+
|
201
|
-
| a | bb | ccc | dddd |
|
202
|
-
+-----+------+------+------+
|
203
|
-
| aa | bbb | cccc | d |
|
204
|
-
| aaa | bbbb | c | dd |
|
205
|
-
+-----+------+------+------+
|
206
|
-
EOS
|
207
|
-
end
|
208
|
-
end
|
209
|
-
describe 'cells to the' do
|
210
|
-
it 'left (default)' do
|
211
|
-
@table.to_s.should == <<-EOS.deindent
|
212
|
-
+------+------+------+------+
|
213
|
-
| a | bb | ccc | dddd |
|
214
|
-
+------+------+------+------+
|
215
|
-
| aa | bbb | cccc | d |
|
216
|
-
| aaa | bbbb | c | dd |
|
217
|
-
+------+------+------+------+
|
218
|
-
| aaaa | b | cc | ddd |
|
219
|
-
+------+------+------+------+
|
220
|
-
EOS
|
221
|
-
end
|
222
|
-
it 'center' do
|
223
|
-
@table = Text::Table.new :rows => @rows.map {|r| r.map {|c| {:value => c, :align => :center}}}, :head => @head, :foot => @foot
|
224
|
-
@table.to_s.should == <<-EOS.deindent
|
225
|
-
+------+------+------+------+
|
226
|
-
| a | bb | ccc | dddd |
|
227
|
-
+------+------+------+------+
|
228
|
-
| aa | bbb | cccc | d |
|
229
|
-
| aaa | bbbb | c | dd |
|
230
|
-
+------+------+------+------+
|
231
|
-
| aaaa | b | cc | ddd |
|
232
|
-
+------+------+------+------+
|
233
|
-
EOS
|
234
|
-
end
|
235
|
-
it 'right' do
|
236
|
-
@table = Text::Table.new :rows => @rows.map {|r| r.map {|c| {:value => c, :align => :right}}}, :head => @head, :foot => @foot
|
237
|
-
@table.to_s.should == <<-EOS.deindent
|
238
|
-
+------+------+------+------+
|
239
|
-
| a | bb | ccc | dddd |
|
240
|
-
+------+------+------+------+
|
241
|
-
| aa | bbb | cccc | d |
|
242
|
-
| aaa | bbbb | c | dd |
|
243
|
-
+------+------+------+------+
|
244
|
-
| aaaa | b | cc | ddd |
|
245
|
-
+------+------+------+------+
|
246
|
-
EOS
|
247
|
-
end
|
248
|
-
end
|
249
|
-
describe 'footers to the' do
|
250
|
-
it 'left (default)' do
|
251
|
-
@table = Text::Table.new :rows => @rows, :foot => @foot
|
252
|
-
@table.to_s.should == <<-EOS.deindent
|
253
|
-
+------+------+------+-----+
|
254
|
-
| aa | bbb | cccc | d |
|
255
|
-
| aaa | bbbb | c | dd |
|
256
|
-
+------+------+------+-----+
|
257
|
-
| aaaa | b | cc | ddd |
|
258
|
-
+------+------+------+-----+
|
259
|
-
EOS
|
260
|
-
end
|
261
|
-
it 'center' do
|
262
|
-
@table = Text::Table.new :rows => @rows, :foot => @foot.map {|f| {:value => f, :align => :center}}
|
263
|
-
@table.to_s.should == <<-EOS.deindent
|
264
|
-
+------+------+------+-----+
|
265
|
-
| aa | bbb | cccc | d |
|
266
|
-
| aaa | bbbb | c | dd |
|
267
|
-
+------+------+------+-----+
|
268
|
-
| aaaa | b | cc | ddd |
|
269
|
-
+------+------+------+-----+
|
270
|
-
EOS
|
271
|
-
end
|
272
|
-
it 'right' do
|
273
|
-
@table = Text::Table.new :rows => @rows, :foot => @foot.map {|f| {:value => f, :align => :right}}
|
274
|
-
@table.to_s.should == <<-EOS.deindent
|
275
|
-
+------+------+------+-----+
|
276
|
-
| aa | bbb | cccc | d |
|
277
|
-
| aaa | bbbb | c | dd |
|
278
|
-
+------+------+------+-----+
|
279
|
-
| aaaa | b | cc | ddd |
|
280
|
-
+------+------+------+-----+
|
281
|
-
EOS
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|
285
|
-
describe 'last columns spanned by' do
|
286
|
-
describe '2 cells aligned to the' do
|
287
|
-
it 'left' do
|
288
|
-
@table.rows << ['a', 'b', {:value => 'x', :colspan => 2}]
|
289
|
-
@table.to_s.should == <<-EOS.deindent
|
290
|
-
+------+------+------+------+
|
291
|
-
| a | bb | ccc | dddd |
|
292
|
-
+------+------+------+------+
|
293
|
-
| aa | bbb | cccc | d |
|
294
|
-
| aaa | bbbb | c | dd |
|
295
|
-
| a | b | x |
|
296
|
-
+------+------+------+------+
|
297
|
-
| aaaa | b | cc | ddd |
|
298
|
-
+------+------+------+------+
|
299
|
-
EOS
|
300
|
-
end
|
301
|
-
it 'center' do
|
302
|
-
@table.rows << ['a', 'b', {:value => 'x', :colspan => 2, :align => :center}]
|
303
|
-
@table.to_s.should == <<-EOS.deindent
|
304
|
-
+------+------+------+------+
|
305
|
-
| a | bb | ccc | dddd |
|
306
|
-
+------+------+------+------+
|
307
|
-
| aa | bbb | cccc | d |
|
308
|
-
| aaa | bbbb | c | dd |
|
309
|
-
| a | b | x |
|
310
|
-
+------+------+------+------+
|
311
|
-
| aaaa | b | cc | ddd |
|
312
|
-
+------+------+------+------+
|
313
|
-
EOS
|
314
|
-
end
|
315
|
-
it 'right' do
|
316
|
-
@table.rows << ['a', 'b', {:value => 'x', :colspan => 2, :align => :right}]
|
317
|
-
@table.to_s.should == <<-EOS.deindent
|
318
|
-
+------+------+------+------+
|
319
|
-
| a | bb | ccc | dddd |
|
320
|
-
+------+------+------+------+
|
321
|
-
| aa | bbb | cccc | d |
|
322
|
-
| aaa | bbbb | c | dd |
|
323
|
-
| a | b | x |
|
324
|
-
+------+------+------+------+
|
325
|
-
| aaaa | b | cc | ddd |
|
326
|
-
+------+------+------+------+
|
327
|
-
EOS
|
328
|
-
end
|
329
|
-
end
|
330
|
-
describe '3 cells aligned to the' do
|
331
|
-
it 'left' do
|
332
|
-
@table.rows << ['a', {:value => 'x', :colspan => 3}]
|
333
|
-
@table.to_s.should == <<-EOS.deindent
|
334
|
-
+------+------+------+------+
|
335
|
-
| a | bb | ccc | dddd |
|
336
|
-
+------+------+------+------+
|
337
|
-
| aa | bbb | cccc | d |
|
338
|
-
| aaa | bbbb | c | dd |
|
339
|
-
| a | x |
|
340
|
-
+------+------+------+------+
|
341
|
-
| aaaa | b | cc | ddd |
|
342
|
-
+------+------+------+------+
|
343
|
-
EOS
|
344
|
-
end
|
345
|
-
it 'center' do
|
346
|
-
@table.rows << ['a', {:value => 'x', :colspan => 3, :align => :center}]
|
347
|
-
@table.to_s.should == <<-EOS.deindent
|
348
|
-
+------+------+------+------+
|
349
|
-
| a | bb | ccc | dddd |
|
350
|
-
+------+------+------+------+
|
351
|
-
| aa | bbb | cccc | d |
|
352
|
-
| aaa | bbbb | c | dd |
|
353
|
-
| a | x |
|
354
|
-
+------+------+------+------+
|
355
|
-
| aaaa | b | cc | ddd |
|
356
|
-
+------+------+------+------+
|
357
|
-
EOS
|
358
|
-
end
|
359
|
-
it 'right' do
|
360
|
-
@table.rows << ['a', {:value => 'x', :colspan => 3, :align => :right}]
|
361
|
-
@table.to_s.should == <<-EOS.deindent
|
362
|
-
+------+------+------+------+
|
363
|
-
| a | bb | ccc | dddd |
|
364
|
-
+------+------+------+------+
|
365
|
-
| aa | bbb | cccc | d |
|
366
|
-
| aaa | bbbb | c | dd |
|
367
|
-
| a | x |
|
368
|
-
+------+------+------+------+
|
369
|
-
| aaaa | b | cc | ddd |
|
370
|
-
+------+------+------+------+
|
371
|
-
EOS
|
372
|
-
end
|
373
|
-
end
|
374
|
-
end
|
375
|
-
describe 'first columns spanned by' do
|
376
|
-
describe '2 cells aligned to the' do
|
377
|
-
it 'left' do
|
378
|
-
@table.rows << [{:value => 'x', :colspan => 2}, 'c', 'd']
|
379
|
-
@table.to_s.should == <<-EOS.deindent
|
380
|
-
+------+------+------+------+
|
381
|
-
| a | bb | ccc | dddd |
|
382
|
-
+------+------+------+------+
|
383
|
-
| aa | bbb | cccc | d |
|
384
|
-
| aaa | bbbb | c | dd |
|
385
|
-
| x | c | d |
|
386
|
-
+------+------+------+------+
|
387
|
-
| aaaa | b | cc | ddd |
|
388
|
-
+------+------+------+------+
|
389
|
-
EOS
|
390
|
-
end
|
391
|
-
it 'center' do
|
392
|
-
@table.rows << [{:value => 'x', :colspan => 2, :align => :center}, 'c', 'd']
|
393
|
-
@table.to_s.should == <<-EOS.deindent
|
394
|
-
+------+------+------+------+
|
395
|
-
| a | bb | ccc | dddd |
|
396
|
-
+------+------+------+------+
|
397
|
-
| aa | bbb | cccc | d |
|
398
|
-
| aaa | bbbb | c | dd |
|
399
|
-
| x | c | d |
|
400
|
-
+------+------+------+------+
|
401
|
-
| aaaa | b | cc | ddd |
|
402
|
-
+------+------+------+------+
|
403
|
-
EOS
|
404
|
-
end
|
405
|
-
it 'right' do
|
406
|
-
@table.rows << [{:value => 'x', :colspan => 2, :align => :right}, 'c', 'd']
|
407
|
-
@table.to_s.should == <<-EOS.deindent
|
408
|
-
+------+------+------+------+
|
409
|
-
| a | bb | ccc | dddd |
|
410
|
-
+------+------+------+------+
|
411
|
-
| aa | bbb | cccc | d |
|
412
|
-
| aaa | bbbb | c | dd |
|
413
|
-
| x | c | d |
|
414
|
-
+------+------+------+------+
|
415
|
-
| aaaa | b | cc | ddd |
|
416
|
-
+------+------+------+------+
|
417
|
-
EOS
|
418
|
-
end
|
419
|
-
end
|
420
|
-
describe '3 cells aligned to the' do
|
421
|
-
it 'left' do
|
422
|
-
@table.rows << [{:value => 'x', :colspan => 3}, 'd']
|
423
|
-
@table.to_s.should == <<-EOS.deindent
|
424
|
-
+------+------+------+------+
|
425
|
-
| a | bb | ccc | dddd |
|
426
|
-
+------+------+------+------+
|
427
|
-
| aa | bbb | cccc | d |
|
428
|
-
| aaa | bbbb | c | dd |
|
429
|
-
| x | d |
|
430
|
-
+------+------+------+------+
|
431
|
-
| aaaa | b | cc | ddd |
|
432
|
-
+------+------+------+------+
|
433
|
-
EOS
|
434
|
-
end
|
435
|
-
it 'center' do
|
436
|
-
@table.rows << [{:value => 'x', :colspan => 3, :align => :center}, 'd']
|
437
|
-
@table.to_s.should == <<-EOS.deindent
|
438
|
-
+------+------+------+------+
|
439
|
-
| a | bb | ccc | dddd |
|
440
|
-
+------+------+------+------+
|
441
|
-
| aa | bbb | cccc | d |
|
442
|
-
| aaa | bbbb | c | dd |
|
443
|
-
| x | d |
|
444
|
-
+------+------+------+------+
|
445
|
-
| aaaa | b | cc | ddd |
|
446
|
-
+------+------+------+------+
|
447
|
-
EOS
|
448
|
-
end
|
449
|
-
it 'right' do
|
450
|
-
@table.rows << [{:value => 'x', :colspan => 3, :align => :right}, 'd']
|
451
|
-
@table.to_s.should == <<-EOS.deindent
|
452
|
-
+------+------+------+------+
|
453
|
-
| a | bb | ccc | dddd |
|
454
|
-
+------+------+------+------+
|
455
|
-
| aa | bbb | cccc | d |
|
456
|
-
| aaa | bbbb | c | dd |
|
457
|
-
| x | d |
|
458
|
-
+------+------+------+------+
|
459
|
-
| aaaa | b | cc | ddd |
|
460
|
-
+------+------+------+------+
|
461
|
-
EOS
|
462
|
-
end
|
463
|
-
end
|
464
|
-
end
|
465
|
-
end
|
466
|
-
|
467
|
-
describe 'should easily allow alignment of' do
|
468
|
-
it 'columns' do
|
469
|
-
@table.rows[1][2] = {:value => 'c', :align => :center}
|
470
|
-
@table.rows << [{:value => 'x', :colspan => 2}, 'c', 'd']
|
471
|
-
@table.rows << ['a', 'b', {:value => 'x', :colspan => 2}]
|
472
|
-
@table.align_column 2, :right
|
473
|
-
@table.align_column 3, :right
|
474
|
-
@table.to_s.should == <<-EOS.deindent
|
475
|
-
+------+------+------+------+
|
476
|
-
| a | bb | ccc | dddd |
|
477
|
-
+------+------+------+------+
|
478
|
-
| aa | bbb | cccc | d |
|
479
|
-
| aaa | bbbb | c | dd |
|
480
|
-
| x | c | d |
|
481
|
-
| a | b | x |
|
482
|
-
+------+------+------+------+
|
483
|
-
| aaaa | b | cc | ddd |
|
484
|
-
+------+------+------+------+
|
485
|
-
EOS
|
486
|
-
end
|
487
|
-
it 'rows'
|
488
|
-
it 'headers'
|
489
|
-
it 'footers'
|
490
|
-
end
|
491
|
-
end
|