html-table 1.6.3 → 1.7.1
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
- checksums.yaml.gz.sig +0 -0
- data/{CHANGES.rdoc → CHANGES.md} +76 -68
- data/Gemfile +2 -0
- data/MANIFEST.md +57 -0
- data/{README.rdoc → README.md} +80 -71
- data/Rakefile +122 -146
- data/doc/attributes.md +160 -0
- data/doc/table.md +173 -0
- data/doc/table_body.md +9 -0
- data/doc/table_caption.md +10 -0
- data/doc/table_colgroup.md +8 -0
- data/doc/table_colgroup_col.md +7 -0
- data/doc/table_content.md +17 -0
- data/doc/table_foot.md +8 -0
- data/doc/table_head.md +10 -0
- data/doc/table_row.md +114 -0
- data/doc/table_row_data.md +100 -0
- data/doc/table_row_header.md +6 -0
- data/examples/simple1.rb +7 -5
- data/html-table.gemspec +16 -11
- data/lib/html/body.rb +9 -7
- data/lib/html/caption.rb +4 -2
- data/lib/html/col.rb +37 -34
- data/lib/html/colgroup.rb +90 -97
- data/lib/html/content.rb +3 -6
- data/lib/html/data.rb +3 -1
- data/lib/html/foot.rb +53 -45
- data/lib/html/head.rb +54 -47
- data/lib/html/header.rb +5 -3
- data/lib/html/mixin/attribute_handler.rb +59 -55
- data/lib/html/mixin/html_handler.rb +33 -35
- data/lib/html/mixin/strongtyping.rb +6 -6
- data/lib/html/mixin/tag_handler.rb +6 -2
- data/lib/html/row.rb +156 -183
- data/lib/html/table.rb +45 -45
- data/lib/html/tablesection.rb +51 -46
- data/spec/attribute_handler_spec.rb +374 -0
- data/spec/body_spec.rb +98 -0
- data/spec/caption_spec.rb +83 -0
- data/spec/colgroup_col_spec.rb +34 -0
- data/spec/colgroup_spec.rb +97 -0
- data/spec/data_spec.rb +88 -0
- data/spec/foot_spec.rb +116 -0
- data/spec/head_spec.rb +116 -0
- data/spec/header_spec.rb +85 -0
- data/spec/html_handler_spec.rb +35 -0
- data/spec/row_spec.rb +163 -0
- data/spec/table_spec.rb +186 -0
- data/spec/tablesection_spec.rb +36 -0
- data/spec/tag_handler_spec.rb +85 -0
- data.tar.gz.sig +0 -0
- metadata +118 -92
- metadata.gz.sig +0 -0
- data/MANIFEST.rdoc +0 -56
- data/doc/attributes.rdoc +0 -143
- data/doc/table.rdoc +0 -156
- data/doc/table_body.rdoc +0 -9
- data/doc/table_caption.rdoc +0 -9
- data/doc/table_colgroup.rdoc +0 -8
- data/doc/table_colgroup_col.rdoc +0 -9
- data/doc/table_content.rdoc +0 -15
- data/doc/table_foot.rdoc +0 -8
- data/doc/table_head.rdoc +0 -11
- data/doc/table_row.rdoc +0 -105
- data/doc/table_row_data.rdoc +0 -92
- data/doc/table_row_header.rdoc +0 -7
- data/test/test_attribute_handler.rb +0 -361
- data/test/test_body.rb +0 -87
- data/test/test_caption.rb +0 -80
- data/test/test_col.rb +0 -40
- data/test/test_colgroup.rb +0 -89
- data/test/test_data.rb +0 -77
- data/test/test_foot.rb +0 -111
- data/test/test_head.rb +0 -104
- data/test/test_header.rb +0 -77
- data/test/test_html_handler.rb +0 -37
- data/test/test_row.rb +0 -141
- data/test/test_table.rb +0 -159
- data/test/test_tablesection.rb +0 -42
- data/test/test_tag_handler.rb +0 -90
data/Rakefile
CHANGED
@@ -1,146 +1,122 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
spec
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
t.
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
t.
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
t.
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
t.
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
t.
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
t.
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
t.
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
t.
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
t.
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
|
-
t.
|
117
|
-
t.
|
118
|
-
t.
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
t.verbose = true
|
124
|
-
t.test_files = FileList['test/test_row.rb']
|
125
|
-
end
|
126
|
-
|
127
|
-
Rake::TestTask.new('table') do |t|
|
128
|
-
t.warning = true
|
129
|
-
t.verbose = true
|
130
|
-
t.test_files = FileList['test/test_table.rb']
|
131
|
-
end
|
132
|
-
|
133
|
-
Rake::TestTask.new('tablesection') do |t|
|
134
|
-
t.warning = true
|
135
|
-
t.verbose = true
|
136
|
-
t.test_files = FileList['test/test_tablesection.rb']
|
137
|
-
end
|
138
|
-
|
139
|
-
Rake::TestTask.new('tag_handler') do |t|
|
140
|
-
t.warning = true
|
141
|
-
t.verbose = true
|
142
|
-
t.test_files = FileList['test/test_tag_handler.rb']
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
task :default => :test
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'rubocop/rake_task'
|
5
|
+
|
6
|
+
CLEAN.include("**/*.gem", "**/*.rbc", "**/*.lock")
|
7
|
+
|
8
|
+
namespace :gem do
|
9
|
+
desc 'Build the html-table gem'
|
10
|
+
task :create => [:clean] do
|
11
|
+
require 'rubygems/package'
|
12
|
+
spec = Gem::Specification.load('html-table.gemspec')
|
13
|
+
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
14
|
+
Gem::Package.build(spec)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Install the html-table package as a gem"
|
18
|
+
task :install => [:create] do
|
19
|
+
file = Dir["*.gem"].first
|
20
|
+
sh "gem install -l #{file}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace 'example' do
|
25
|
+
desc "Run the first simple html-table example"
|
26
|
+
task :simple1 do
|
27
|
+
sh 'ruby -Ilib examples/simple1.rb'
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Run the second simple html-table example"
|
31
|
+
task :simple2 do
|
32
|
+
sh 'ruby -Ilib examples/simple2.rb'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Run the third simple html-table example"
|
36
|
+
task :simple3 do
|
37
|
+
sh 'ruby -Ilib examples/simple3.rb'
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Run the first intermediate html-table example"
|
41
|
+
task :intermediate1 do
|
42
|
+
sh 'ruby -Ilib examples/intermediate1.rb'
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Run the second intermediate html-table example"
|
46
|
+
task :intermediate2 do
|
47
|
+
sh 'ruby -Ilib examples/intermediate2.rb'
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Run the advanced html-table example"
|
51
|
+
task :advanced do
|
52
|
+
sh 'ruby -Ilib examples/advanced.rb'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
RuboCop::RakeTask.new
|
57
|
+
|
58
|
+
namespace :spec do
|
59
|
+
RSpec::Core::RakeTask.new(:attribute_handler) do |t|
|
60
|
+
t.pattern = 'spec/attribute_handler_spec.rb'
|
61
|
+
end
|
62
|
+
|
63
|
+
RSpec::Core::RakeTask.new(:body) do |t|
|
64
|
+
t.pattern = 'spec/body_spec.rb'
|
65
|
+
end
|
66
|
+
|
67
|
+
RSpec::Core::RakeTask.new(:caption) do |t|
|
68
|
+
t.pattern = 'spec/caption_spec.rb'
|
69
|
+
end
|
70
|
+
|
71
|
+
RSpec::Core::RakeTask.new(:col) do |t|
|
72
|
+
t.pattern = 'spec/col_spec.rb'
|
73
|
+
end
|
74
|
+
|
75
|
+
RSpec::Core::RakeTask.new(:colgroup) do |t|
|
76
|
+
t.pattern = 'spec/colgroup_spec.rb'
|
77
|
+
end
|
78
|
+
|
79
|
+
RSpec::Core::RakeTask.new(:data) do |t|
|
80
|
+
t.pattern = 'spec/data_spec.rb'
|
81
|
+
end
|
82
|
+
|
83
|
+
RSpec::Core::RakeTask.new(:foot) do |t|
|
84
|
+
t.pattern = 'spec/foot_spec.rb'
|
85
|
+
end
|
86
|
+
|
87
|
+
RSpec::Core::RakeTask.new(:head) do |t|
|
88
|
+
t.pattern = 'spec/head_spec.rb'
|
89
|
+
end
|
90
|
+
|
91
|
+
RSpec::Core::RakeTask.new(:header) do |t|
|
92
|
+
t.pattern = 'spec/header_spec.rb'
|
93
|
+
end
|
94
|
+
|
95
|
+
RSpec::Core::RakeTask.new(:html_handler) do |t|
|
96
|
+
t.pattern = 'spec/html_handler_spec.rb'
|
97
|
+
end
|
98
|
+
|
99
|
+
RSpec::Core::RakeTask.new(:row) do |t|
|
100
|
+
t.pattern = 'spec/row_spec.rb'
|
101
|
+
end
|
102
|
+
|
103
|
+
RSpec::Core::RakeTask.new(:table) do |t|
|
104
|
+
t.pattern = 'spec/table_spec.rb'
|
105
|
+
end
|
106
|
+
|
107
|
+
RSpec::Core::RakeTask.new(:tablesection) do |t|
|
108
|
+
t.pattern = 'spec/tablesection_spec.rb'
|
109
|
+
end
|
110
|
+
|
111
|
+
RSpec::Core::RakeTask.new(:tag_handler) do |t|
|
112
|
+
t.pattern = 'spec/tag_handler_spec.rb'
|
113
|
+
end
|
114
|
+
|
115
|
+
RSpec::Core::RakeTask.new(:all) do |t|
|
116
|
+
t.verbose = false
|
117
|
+
t.pattern = 'spec/*_spec.rb'
|
118
|
+
t.rspec_opts = '-f documentation'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
task :default => ['spec:all', :clean]
|
data/doc/attributes.md
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
## Description
|
2
|
+
A list of attributes handled by html-table. Each of the writers has a
|
3
|
+
corresponding reader unless otherwise stated.
|
4
|
+
|
5
|
+
## Attributes
|
6
|
+
`abbr=(string)`
|
7
|
+
|
8
|
+
Sets the value for the abbr attribute.
|
9
|
+
|
10
|
+
`align=(string)`
|
11
|
+
|
12
|
+
Sets the align attribute. Valid arguments are 'left', 'center' and
|
13
|
+
'right'. An ArgumentError is raised if an invalid argument is passed.
|
14
|
+
|
15
|
+
`axis=(string)`
|
16
|
+
|
17
|
+
Sets the value for the axis attribute.
|
18
|
+
|
19
|
+
`background=(url)`
|
20
|
+
|
21
|
+
Sets the background attribute. The url must be a String or a TypeError
|
22
|
+
is raised. This is a non-standard extension.
|
23
|
+
|
24
|
+
`bgcolor=(color)`
|
25
|
+
|
26
|
+
Sets the color for the bgcolor attribute. Hex values should still be
|
27
|
+
quoted, e.g. "#F80000".
|
28
|
+
|
29
|
+
`border=(num)`
|
30
|
+
|
31
|
+
Sets the value for the border attribute.
|
32
|
+
|
33
|
+
`bordercolor=(color)`
|
34
|
+
|
35
|
+
Sets the color for the bordercolor attribute. This is a non-standard extension.
|
36
|
+
|
37
|
+
`bordercolordark=(color)`
|
38
|
+
|
39
|
+
Sets the color for the bordercolordark attribute. This is a non-standard extension.
|
40
|
+
|
41
|
+
`bordercolorlight=(color)`
|
42
|
+
|
43
|
+
Sets the color for the bordercolorlight attribute. This is a non-standard extension.
|
44
|
+
|
45
|
+
`cellpadding=(num)`
|
46
|
+
|
47
|
+
Sets the value for the cellpadding attribute. Raises an ArgumentError if num.to_i is less than 0.
|
48
|
+
|
49
|
+
`cellspacing=(num)`
|
50
|
+
|
51
|
+
Sets the value for the cellspacing attribute. Raises an ArgumentError if num.to_i is less than 0.
|
52
|
+
|
53
|
+
`char=(character)`
|
54
|
+
|
55
|
+
Sets the value for the char attribute. An ArgumentError is raised if the
|
56
|
+
argument passed has a length greater than 1 (i.e. it may only be a char).
|
57
|
+
|
58
|
+
`charoff=(value)`
|
59
|
+
|
60
|
+
Sets the value for the charoff attribute.
|
61
|
+
|
62
|
+
`colspan=(num)`
|
63
|
+
|
64
|
+
Sets the colspan attribute.
|
65
|
+
|
66
|
+
`content=(*args)`
|
67
|
+
|
68
|
+
The behavior of this method varies largely based on the type of instance
|
69
|
+
that invokes it. Here are the rules for each argument in `args`:
|
70
|
+
|
71
|
+
* `Table`:
|
72
|
+
|
73
|
+
If `arg` is a `Row`, `Head`, `Foot`, `Body` or `ColGroup` object, it is
|
74
|
+
pushed onto the table. If `arg` is a string, one `Row` object with
|
75
|
+
one one `Data` object is pushed onto the `Table`. If `arg` is an `Array`,
|
76
|
+
then one `Row` object is created and each element of the array is pushed
|
77
|
+
onto that Row.
|
78
|
+
|
79
|
+
* `Table::Row`:
|
80
|
+
|
81
|
+
If `arg` is a `Header` or `Data` object, it is pushed onto the `Row`. If
|
82
|
+
`arg` is a `String`, it is created as a single `Data` object. Any attempt
|
83
|
+
to assign any other type will raise a `TypeError`.
|
84
|
+
|
85
|
+
* `Table::Head`, `Table::Foot`, `Table::Body`:
|
86
|
+
|
87
|
+
Behave identically to `Table::Row` except that they accept Table::Row objects as well.
|
88
|
+
|
89
|
+
* `Table::ColGroup`:
|
90
|
+
|
91
|
+
Behaves identically to Table::Row except that it only accepts Col objects.
|
92
|
+
|
93
|
+
* `Table::Col`:
|
94
|
+
|
95
|
+
This method is undefined for Table::Col, because they do not accept content.
|
96
|
+
|
97
|
+
* `Table::Data and Table::Header`:
|
98
|
+
|
99
|
+
Sets the text string for the `Data` or `Header` object. Arrays are join'd.
|
100
|
+
Any other type raises a `TypeError`.
|
101
|
+
|
102
|
+
`frame=(type)`
|
103
|
+
|
104
|
+
Sets the value for the frame attribute. Valid values are border, void,
|
105
|
+
above, below, hsides, lhs, rhs, vsides, and box. An ArgumentError is
|
106
|
+
raised if an invalid type is detected.
|
107
|
+
|
108
|
+
`height=(num)`
|
109
|
+
|
110
|
+
Sets the value for the height attribute. Raises an ArgumentError if
|
111
|
+
num.to_i is less than 0.
|
112
|
+
|
113
|
+
`hspace=(num)`
|
114
|
+
|
115
|
+
Sets the value for the hspace attribute. Raises an ArgumentError if
|
116
|
+
num.to_i is less than 0.
|
117
|
+
|
118
|
+
`nowrap=(bool)`
|
119
|
+
|
120
|
+
Sets the value for the nowrap attribute. Setting it to true means it will be
|
121
|
+
included as an attribute for the Table object. The default is false (i.e. not included).
|
122
|
+
|
123
|
+
`rowspan=(num)`
|
124
|
+
|
125
|
+
Sets the value for the rowspan attribute.
|
126
|
+
|
127
|
+
`rules=(edges)`
|
128
|
+
|
129
|
+
Sets the value for the rules attribute. Valid values are "all", "groups",
|
130
|
+
"rows", "cols", or "none". An `ArgumentError` is raised if an invalid edges value
|
131
|
+
is detected.
|
132
|
+
|
133
|
+
`scope=(scope)`
|
134
|
+
|
135
|
+
Sets the value for the scope attribute. Valid values for +scope+ are
|
136
|
+
row, col, rowgroup or colgroup. An ArgumentError is raised if an invalid
|
137
|
+
scope value is passed.
|
138
|
+
|
139
|
+
`span=(num)`
|
140
|
+
|
141
|
+
Sets the span attribute. If num.to_i is less than 0, and ArgumentError is raised.
|
142
|
+
|
143
|
+
`summary=(string)`
|
144
|
+
|
145
|
+
Sets the value for the summary attribute.
|
146
|
+
|
147
|
+
`valign=(position)`
|
148
|
+
|
149
|
+
Sets the value for the valign attribute. Valid values are top, center,
|
150
|
+
bottom, and baseline. This is a non-standard extension.
|
151
|
+
|
152
|
+
`vspace=(num)`
|
153
|
+
|
154
|
+
Sets the value for the vspace attribute. This is a non-standard extension.
|
155
|
+
|
156
|
+
`width=(num)`
|
157
|
+
|
158
|
+
Sets the value for the width attribute. If num is in 'x%' format, it
|
159
|
+
is retained as a string. If num is a Fixnum (or stringified number), an
|
160
|
+
ArgumentError is raised if num.to_i is less than 0.
|
data/doc/table.md
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
## Description
|
2
|
+
An interface for generating HTML Tables with Ruby.
|
3
|
+
|
4
|
+
## Synopsis
|
5
|
+
```ruby
|
6
|
+
require "html/table"
|
7
|
+
include HTML
|
8
|
+
|
9
|
+
table = HTML::Table.new{ |t|
|
10
|
+
t.border = 1
|
11
|
+
t.bgcolor = "red"
|
12
|
+
}
|
13
|
+
|
14
|
+
table.push Table::Row.new{ |r|
|
15
|
+
r.align = "left"
|
16
|
+
r.bgcolor = "green"
|
17
|
+
r.content = ["foo","bar","baz"]
|
18
|
+
}
|
19
|
+
|
20
|
+
row = Table::Row.new{ |r|
|
21
|
+
r.align = "right"
|
22
|
+
r.bgcolor = "blue"
|
23
|
+
r.content = "hello world"
|
24
|
+
}
|
25
|
+
|
26
|
+
table[1] = row
|
27
|
+
|
28
|
+
puts table.html
|
29
|
+
|
30
|
+
#### output ####
|
31
|
+
<table border=1 bgcolor='red'>
|
32
|
+
<tr align='left' bgcolor='green'> # row 0
|
33
|
+
<td>foo</td> # column 0
|
34
|
+
<td>bar</td> # column 1
|
35
|
+
<td>baz</td> # column 2
|
36
|
+
</tr>
|
37
|
+
<tr align='right' bgcolor='blue'> # row 1
|
38
|
+
<td>hello world</td> # column 0
|
39
|
+
</tr>
|
40
|
+
</table>
|
41
|
+
```
|
42
|
+
|
43
|
+
See the 'examples' directory for more examples.
|
44
|
+
|
45
|
+
## Mixins
|
46
|
+
`Table` is a subclass of `Array`, and therefore mixes in `Enumerable`. The
|
47
|
+
`push`, `unshift` and `[]=` methods have been modified. See below for details.
|
48
|
+
|
49
|
+
Table also mixes in the `AttributeHandler` module which provides methods
|
50
|
+
for adding attributes to each of the tag types. See attributes.md for
|
51
|
+
more details.
|
52
|
+
|
53
|
+
## Constants
|
54
|
+
`VERSION`
|
55
|
+
|
56
|
+
The current version number (a String). This serves as the VERSION number
|
57
|
+
for the entire html-table package.
|
58
|
+
|
59
|
+
## Class Methods
|
60
|
+
```
|
61
|
+
Table.new(arg=nil)
|
62
|
+
Table.new(arg=nil){ |t| ... }
|
63
|
+
```
|
64
|
+
|
65
|
+
Creates a new Table instance. You can set attributes for the Table by
|
66
|
+
passing a block.
|
67
|
+
|
68
|
+
If `arg` is supplied, it is automatically interpreted to be content. This
|
69
|
+
is a shortcut for `Table.new{ |t| t.content = '...' }`.
|
70
|
+
|
71
|
+
`Table.global_end_tags?`
|
72
|
+
|
73
|
+
Returns the value of the `global_end_tags` class variable. By default,
|
74
|
+
this is true.
|
75
|
+
|
76
|
+
`Table.global_end_tags=(true|false)`
|
77
|
+
|
78
|
+
Sets the `global_end_tags` class variable. This determines class-wide, for
|
79
|
+
those classes where end tags are optional, whether or not end tags are
|
80
|
+
included in the final html. Classes where end tags are not optional are
|
81
|
+
not affected.
|
82
|
+
|
83
|
+
If set to false, this overrides individual class end tags settings.
|
84
|
+
|
85
|
+
## Instance Methods
|
86
|
+
`Table#[]=(index, object)`
|
87
|
+
|
88
|
+
Assigns `object` to `index`. There are restrictions to the data
|
89
|
+
types that you can assign to a Table instance. They include `Caption`,
|
90
|
+
`ColGroup`, `Body`, `Foot`, `Head` and `Row`. You cannot assign a slice (yet).
|
91
|
+
|
92
|
+
`Table#configure(row_num, col_num=0){ |td_object| block }`
|
93
|
+
|
94
|
+
Configures column `col_num` at row `row_num`, using a block to set
|
95
|
+
options. If only `row_num` is specified, then you'll be configuring
|
96
|
+
only the row. Generally speaking, that means you'll be configure a
|
97
|
+
Table::Row and not a Data or Header object.
|
98
|
+
|
99
|
+
`Table#content`
|
100
|
+
|
101
|
+
Returns the HTML content.
|
102
|
+
|
103
|
+
`Table#content=(arg)`
|
104
|
+
|
105
|
+
Adds data to the Table. The `arg` may be a Table::Row object, an
|
106
|
+
Array of Table::Row objects, an Array of Array's, an Array of Strings,
|
107
|
+
or a single String. In the last two cases, a single Table::Row with a
|
108
|
+
single Table::Row::Data object is created, with the string as the content.
|
109
|
+
|
110
|
+
`Table#html`
|
111
|
+
|
112
|
+
Returns the entire HTML content for the Table Object. This is what you
|
113
|
+
want to print when you're done creating your Table.
|
114
|
+
|
115
|
+
`Table#push(obj)`
|
116
|
+
|
117
|
+
Pushes `obj` onto the Table, where `obj` must be a Row, Caption,
|
118
|
+
ColGroup, Body, Foot or Head object. Also note that the Caption and Head
|
119
|
+
objects will automatically put themselves at row 0 (or possibly 1, in the
|
120
|
+
case of a Head object where a Caption already exists).
|
121
|
+
|
122
|
+
`Table#unshift(obj)`
|
123
|
+
|
124
|
+
Unshifts `obj` onto the Table. The same rules apply to `unshift` as
|
125
|
+
they do to `push`.
|
126
|
+
|
127
|
+
## Notes
|
128
|
+
A Table consists of Table::Row, Table::Caption, Table::ColGroup,
|
129
|
+
Table::Body, Table::Foot, Table::Head and Table::Row objects.
|
130
|
+
|
131
|
+
Table::Row objects in turn consist of Table::Row::Data and Table::Row::Header objects.
|
132
|
+
|
133
|
+
Table::ColGroup objects consist of Table::ColGroup::Col objects.
|
134
|
+
|
135
|
+
Table::Head, Table::Body and Table::Foot objects consist of Table::Row objects.
|
136
|
+
|
137
|
+
String attributes are quoted. Numeric attributes are not.
|
138
|
+
|
139
|
+
Some attributes have type checking. Some check for valid arguments. In
|
140
|
+
the latter case, it is case-insensitive. See the documentation on
|
141
|
+
specific methods for more details.
|
142
|
+
|
143
|
+
Using a non-standard extension (e.g. "background") will send a warning to
|
144
|
+
STDERR in `$VERBOSE` (-w) mode.
|
145
|
+
|
146
|
+
## Known Bugs
|
147
|
+
None that I'm aware of. Please report bugs on the project page at
|
148
|
+
https://github.com/djberg96/html-table
|
149
|
+
|
150
|
+
## Future Plans
|
151
|
+
Allow standard html tags to be added to elements as appropriate, such
|
152
|
+
as `<B>`, `<I>`, etc.
|
153
|
+
|
154
|
+
CSS support.
|
155
|
+
|
156
|
+
## Acknowledgements
|
157
|
+
Anthony Peacock, for giving me ideas with his HTML::Table Perl module.
|
158
|
+
Holden Glova and Culley Harrelson for API suggestions and comments.
|
159
|
+
|
160
|
+
## License
|
161
|
+
Apache-2.0
|
162
|
+
|
163
|
+
## Copyright
|
164
|
+
(C) 2003-2021 Daniel J. Berger
|
165
|
+
All Rights Reserved
|
166
|
+
|
167
|
+
## Warranty
|
168
|
+
This package is provided "as is" and without any express or
|
169
|
+
implied warranties, including, without limitation, the implied
|
170
|
+
warranties of merchantability and fitness for a particular purpose.
|
171
|
+
|
172
|
+
## Author
|
173
|
+
Daniel J. Berger
|
data/doc/table_body.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
## Description
|
2
|
+
A Table::Body object represents a single `<TBODY></TBODY>` instance for an HTML Table.
|
3
|
+
|
4
|
+
## Notes
|
5
|
+
In virtually every respect the Table::Body class is identical to
|
6
|
+
the Table or Table::Row class. Unlike Table::Foot or Table::Head, there
|
7
|
+
can be more than one instance (i.e. it's not a singleton class).
|
8
|
+
|
9
|
+
A Table::Body contains Table::Row objects.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
## Description
|
2
|
+
A Table::Caption object represents a single `<CAPTION></CAPTION>` instance
|
3
|
+
for an HTML Table.
|
4
|
+
|
5
|
+
## Notes
|
6
|
+
The Table::Caption class is virtually identical to the Table::Row::Data
|
7
|
+
class. There is one important behavioral difference, however. First,
|
8
|
+
there can only be one Table::Caption. If you attempt to add a second one,
|
9
|
+
it will merely overwrite the existing one. Second, a Table::Caption is
|
10
|
+
always bumped to index 0.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
## Description
|
2
|
+
A Table::ColGroup object represents a single `<COLGROUP></COLGROUP>`
|
3
|
+
instance for an HTML Table.
|
4
|
+
|
5
|
+
## Notes
|
6
|
+
In virtually every respect the Table::ColGroup class is identical to the
|
7
|
+
Table::Row class. The only difference, beyond the begin and end tags, is
|
8
|
+
that a ColGroup may only contain instances of the Col class.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
## Description
|
2
|
+
A Table::ColGroup::Col object represents a single `<COL>` instance for an HTML Table.
|
3
|
+
|
4
|
+
## Notes
|
5
|
+
In virtually every respect the Table::ColGroup::Col class is identical to
|
6
|
+
the Table::Row::Data class. The only differences are that a Table::ColGroup::Col
|
7
|
+
instance does not contain any content, nor does it include an end tag.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
## Description
|
2
|
+
A Table::Content is a wrapper for content used for Table::Row::Data and
|
3
|
+
Table::Row::Header objects. Although it can be instantiated directly, in
|
4
|
+
practice it is autogenerated for you.
|
5
|
+
|
6
|
+
## Notes
|
7
|
+
Table::Content is a subclass of String and was mostly created in order
|
8
|
+
to support a DSL style syntax as well as physical tags.
|
9
|
+
|
10
|
+
## Synopsis
|
11
|
+
```ruby
|
12
|
+
content = Table::Content.new('my content') do
|
13
|
+
bold true
|
14
|
+
italics true
|
15
|
+
underline true
|
16
|
+
end
|
17
|
+
```
|
data/doc/table_foot.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
## Description
|
2
|
+
A Table::Foot object represents a single `<TFOOT></TFOOT>` instance for an HTML Table.
|
3
|
+
|
4
|
+
## Notes
|
5
|
+
In virtually every respect the Table::Foot class is identical to the
|
6
|
+
Table or Table::Row class. There is one significant difference. The
|
7
|
+
Table::Foot class is a singleton. There can be only one Table::Foot
|
8
|
+
instance per table.
|
data/doc/table_head.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
## Description
|
2
|
+
A Table::Head object represents a single `<THEAD></THEAD>` instance for an HTML Table.
|
3
|
+
|
4
|
+
## Notes
|
5
|
+
In virtually every respect the Table::Head class is identical to
|
6
|
+
the Table or Table::Row class. There are two significant differences.
|
7
|
+
First, the Table::Head class is a singleton. There can be only one
|
8
|
+
Table::Head instance per table. Second, if an instance of Table::Head
|
9
|
+
is added to a table, it will be automatically be put at index 0 (or 1
|
10
|
+
if a Table::Caption exists).
|