html-table 1.4.2 → 1.5.0

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGES +155 -149
  5. data/MANIFEST +59 -59
  6. data/README +132 -132
  7. data/certs/djberg96_pub.pem +15 -15
  8. data/doc/attributes.rdoc +143 -143
  9. data/doc/table.rdoc +158 -158
  10. data/doc/table_body.rdoc +9 -9
  11. data/doc/table_caption.rdoc +9 -9
  12. data/doc/table_colgroup.rdoc +8 -8
  13. data/doc/table_colgroup_col.rdoc +9 -9
  14. data/doc/table_content.rdoc +15 -15
  15. data/doc/table_foot.rdoc +8 -8
  16. data/doc/table_head.rdoc +11 -11
  17. data/doc/table_row.rdoc +105 -105
  18. data/doc/table_row_data.rdoc +92 -92
  19. data/doc/table_row_header.rdoc +7 -7
  20. data/examples/advanced.rb +128 -128
  21. data/examples/intermediate1.rb +72 -72
  22. data/examples/intermediate2.rb +62 -62
  23. data/examples/intermediate3.rb +46 -46
  24. data/examples/simple1.rb +39 -39
  25. data/examples/simple2.rb +47 -47
  26. data/examples/simple3.rb +41 -41
  27. data/html-table.gemspec +28 -28
  28. data/lib/html-table.rb +1 -1
  29. data/lib/html/attribute_handler.rb +403 -403
  30. data/lib/html/body.rb +37 -37
  31. data/lib/html/caption.rb +49 -49
  32. data/lib/html/col.rb +41 -41
  33. data/lib/html/colgroup.rb +113 -113
  34. data/lib/html/content.rb +18 -18
  35. data/lib/html/data.rb +69 -69
  36. data/lib/html/foot.rb +49 -49
  37. data/lib/html/head.rb +49 -49
  38. data/lib/html/header.rb +65 -65
  39. data/lib/html/html_handler.rb +120 -120
  40. data/lib/html/row.rb +188 -188
  41. data/lib/html/table.rb +323 -323
  42. data/lib/html/tablesection.rb +48 -48
  43. data/lib/html/tag_handler.rb +121 -121
  44. data/test/test_attribute_handler.rb +361 -361
  45. data/test/test_body.rb +87 -87
  46. data/test/test_caption.rb +80 -80
  47. data/test/test_col.rb +40 -40
  48. data/test/test_colgroup.rb +89 -89
  49. data/test/test_data.rb +77 -77
  50. data/test/test_foot.rb +111 -111
  51. data/test/test_head.rb +104 -104
  52. data/test/test_header.rb +77 -77
  53. data/test/test_html_handler.rb +37 -37
  54. data/test/test_row.rb +141 -141
  55. data/test/test_table.rb +158 -158
  56. data/test/test_tablesection.rb +42 -42
  57. data/test/test_tag_handler.rb +90 -90
  58. metadata +22 -22
  59. metadata.gz.sig +0 -0
@@ -1,7 +1,7 @@
1
- == Description
2
- A Table::Row::Header object represents a single <TH></TH> instance for
3
- an HTML Table.
4
-
5
- == Notes
6
- The Table::Row::Header class is identical in every way to the
7
- Table::Row::Data class, except for the begin and end tags.
1
+ == Description
2
+ A Table::Row::Header object represents a single <TH></TH> instance for
3
+ an HTML Table.
4
+
5
+ == Notes
6
+ The Table::Row::Header class is identical in every way to the
7
+ Table::Row::Data class, except for the begin and end tags.
@@ -1,128 +1,128 @@
1
- ##############################################################################
2
- # advanced1.rb
3
- #
4
- # For this example we'll use every feature I can think of to come up with
5
- # the example found in "HTML: The Definitive Guide", pp. 395-396 (O'Reilly
6
- # & Associates, 3rd ed).
7
- #
8
- # You can run this example via the 'example:advanced' rake task.
9
- ##############################################################################
10
- require 'html/table'
11
- include HTML
12
-
13
- Table::Row::Data.end_tags = false
14
- Table::Row::Header.end_tags = false
15
-
16
- # Demonstrates the DSL style syntax
17
- table = Table.new do
18
- border 1
19
- cellspacing 0
20
- cellpadding 0
21
- rules 'groups'
22
- end
23
-
24
- # Demonstrates the use of setters after object creation
25
- caption = Table::Caption.new
26
- caption.align = "bottom"
27
- caption.content = "Kumquat versus a poked eye, by gender"
28
-
29
- thead = Table::Head.create
30
- tbody = Table::Body.new
31
- tfoot = Table::Foot.create
32
-
33
- # Add a row with a td and th, then configure after the fact.
34
- thead.push Table::Row.new{ |r|
35
- r.content = Table::Row::Data.new, Table::Row::Header.new
36
- }
37
-
38
- # And again, longhand
39
- hrow = Table::Row.new
40
- h1 = Table::Row::Header.new('Eating Kumquats')
41
- h2 = Table::Row::Header.new('Poke In The Eye')
42
- hrow.push h1, h2
43
- thead.push hrow
44
-
45
- # Configure a row after the fact
46
- thead.configure(0,0){ |d|
47
- d.colspan = 2
48
- d.rowspan = 2
49
- }
50
-
51
- thead.configure(0,1){ |h|
52
- h.colspan = 2
53
- h.align = "center"
54
- h.content = "Preference"
55
- }
56
-
57
- # Ugly, but just to show you that it's possible
58
- tbody.push(
59
- Table::Row.new{ |r|
60
- r.align = "center"
61
- r.content =
62
- Table::Row::Header.new{ |h|
63
- h.rowspan = 2
64
- h.content = "Gender"
65
- },
66
- Table::Row::Header.new{ |h| h.content = "Male" },
67
- "73%",
68
- "27%"
69
- }
70
- )
71
-
72
- brow = Table::Row.new{ |r| r.align = "center" }
73
- bheader = Table::Row::Header.new('Female')
74
- brow.push(bheader,"16%","84%")
75
-
76
- tbody.push(brow)
77
-
78
- frow = Table::Row.new{ |r|
79
- r.content = Table::Row::Data.new{ |d|
80
- d.colspan = 4
81
- d.align = "center"
82
- d.content = "Note: eye pokes did not result in permanent injury"
83
- }
84
- }
85
-
86
- tfoot[0] = frow
87
-
88
- table.push thead, tbody, tfoot
89
-
90
- # caption is added last, but does the right thing
91
- table.push caption
92
-
93
- puts table.html
94
-
95
- =begin
96
- ### OUTPUT ###
97
- <table border=1 cellspacing=0 cellpadding=0 rules='groups'>
98
- <caption align='bottom'>Kumquat versus a poked eye, by gender</caption>
99
- <thead>
100
- <tr>
101
- <td colspan=2 rowspan=2>
102
- <th colspan=2 align='center'>Preference
103
- </tr>
104
- <tr>
105
- <th>Eating Kumquats
106
- <th>Poke In The Eye
107
- </tr>
108
- </thead>
109
- <tbody>
110
- <tr align='center'>
111
- <th rowspan=2>Gender
112
- <th>Male
113
- <td>73%
114
- <td>27%
115
- </tr>
116
- <tr align='center'>
117
- <th>Female
118
- <td>16%
119
- <td>84%
120
- </tr>
121
- </tbody>
122
- <tfoot>
123
- <tr>
124
- <td colspan=4 align='center'>Note: eye pokes did not result in permanent injury
125
- </tr>
126
- </tfoot>
127
- </table>
128
- =end
1
+ ##############################################################################
2
+ # advanced1.rb
3
+ #
4
+ # For this example we'll use every feature I can think of to come up with
5
+ # the example found in "HTML: The Definitive Guide", pp. 395-396 (O'Reilly
6
+ # & Associates, 3rd ed).
7
+ #
8
+ # You can run this example via the 'example:advanced' rake task.
9
+ ##############################################################################
10
+ require 'html/table'
11
+ include HTML
12
+
13
+ Table::Row::Data.end_tags = false
14
+ Table::Row::Header.end_tags = false
15
+
16
+ # Demonstrates the DSL style syntax
17
+ table = Table.new do
18
+ border 1
19
+ cellspacing 0
20
+ cellpadding 0
21
+ rules 'groups'
22
+ end
23
+
24
+ # Demonstrates the use of setters after object creation
25
+ caption = Table::Caption.new
26
+ caption.align = "bottom"
27
+ caption.content = "Kumquat versus a poked eye, by gender"
28
+
29
+ thead = Table::Head.create
30
+ tbody = Table::Body.new
31
+ tfoot = Table::Foot.create
32
+
33
+ # Add a row with a td and th, then configure after the fact.
34
+ thead.push Table::Row.new{ |r|
35
+ r.content = Table::Row::Data.new, Table::Row::Header.new
36
+ }
37
+
38
+ # And again, longhand
39
+ hrow = Table::Row.new
40
+ h1 = Table::Row::Header.new('Eating Kumquats')
41
+ h2 = Table::Row::Header.new('Poke In The Eye')
42
+ hrow.push h1, h2
43
+ thead.push hrow
44
+
45
+ # Configure a row after the fact
46
+ thead.configure(0,0){ |d|
47
+ d.colspan = 2
48
+ d.rowspan = 2
49
+ }
50
+
51
+ thead.configure(0,1){ |h|
52
+ h.colspan = 2
53
+ h.align = "center"
54
+ h.content = "Preference"
55
+ }
56
+
57
+ # Ugly, but just to show you that it's possible
58
+ tbody.push(
59
+ Table::Row.new{ |r|
60
+ r.align = "center"
61
+ r.content =
62
+ Table::Row::Header.new{ |h|
63
+ h.rowspan = 2
64
+ h.content = "Gender"
65
+ },
66
+ Table::Row::Header.new{ |h| h.content = "Male" },
67
+ "73%",
68
+ "27%"
69
+ }
70
+ )
71
+
72
+ brow = Table::Row.new{ |r| r.align = "center" }
73
+ bheader = Table::Row::Header.new('Female')
74
+ brow.push(bheader,"16%","84%")
75
+
76
+ tbody.push(brow)
77
+
78
+ frow = Table::Row.new{ |r|
79
+ r.content = Table::Row::Data.new{ |d|
80
+ d.colspan = 4
81
+ d.align = "center"
82
+ d.content = "Note: eye pokes did not result in permanent injury"
83
+ }
84
+ }
85
+
86
+ tfoot[0] = frow
87
+
88
+ table.push thead, tbody, tfoot
89
+
90
+ # caption is added last, but does the right thing
91
+ table.push caption
92
+
93
+ puts table.html
94
+
95
+ =begin
96
+ ### OUTPUT ###
97
+ <table border=1 cellspacing=0 cellpadding=0 rules='groups'>
98
+ <caption align='bottom'>Kumquat versus a poked eye, by gender</caption>
99
+ <thead>
100
+ <tr>
101
+ <td colspan=2 rowspan=2>
102
+ <th colspan=2 align='center'>Preference
103
+ </tr>
104
+ <tr>
105
+ <th>Eating Kumquats
106
+ <th>Poke In The Eye
107
+ </tr>
108
+ </thead>
109
+ <tbody>
110
+ <tr align='center'>
111
+ <th rowspan=2>Gender
112
+ <th>Male
113
+ <td>73%
114
+ <td>27%
115
+ </tr>
116
+ <tr align='center'>
117
+ <th>Female
118
+ <td>16%
119
+ <td>84%
120
+ </tr>
121
+ </tbody>
122
+ <tfoot>
123
+ <tr>
124
+ <td colspan=4 align='center'>Note: eye pokes did not result in permanent injury
125
+ </tr>
126
+ </tfoot>
127
+ </table>
128
+ =end
@@ -1,72 +1,72 @@
1
- ##############################################################################
2
- # intermediate1.rb
3
- #
4
- # A slightly more advanced HTML Table. This time we'll add some attributes,
5
- # add a few rows both implicitly and explicitly, then configure it
6
- # after-the-fact.
7
- #
8
- # You can run this via the "example:intermediate1" rake task.
9
- ##############################################################################
10
- require 'html/table'
11
- include HTML
12
-
13
- # Create a table, add two rows implicitly
14
- table = Table.new{ |t|
15
- t.border = 1
16
- t.align = "left"
17
- t.content = [
18
- ["foo","bar","baz"],
19
- [1,2]
20
- ]
21
- }
22
-
23
- # Create a Table::Row object with one Data object added implicitly
24
- row1 = Table::Row.new{ |r|
25
- r.bgcolor = "red"
26
- r.nowrap = true
27
- r.content = "test"
28
- }
29
-
30
- # Create a Table::Row object, add a Data object explicitly (with some
31
- # configuration to boot)
32
- row2 = Table::Row.new{ |r|
33
- r.bgcolor = "blue"
34
- r.align = "right"
35
- r.content = Table::Row::Data.new{ |d|
36
- d.content = "hello world!"
37
- d.abbr = "test abbr"
38
- }
39
- }
40
-
41
- # Add the rows explicitly to the table
42
- table.push row1, row2
43
-
44
- # Let's configure the row that contains "foo","bar","baz"
45
- # Remember, row and column counts start at 0, not 1
46
- table.configure(0){ |r|
47
- r.bgcolor = "green"
48
- r.align = "right"
49
- }
50
-
51
- puts table.html
52
-
53
- =begin
54
- ### OUTPUT ###
55
- <table border=1 align='left'>
56
- <tr bgcolor='green' align='right'>
57
- <td>foo</td>
58
- <td>bar</td>
59
- <td>baz</td>
60
- </tr>
61
- <tr>
62
- <td>1</td>
63
- <td>2</td>
64
- </tr>
65
- <tr bgcolor='red' nowrap>
66
- <td>test</td>
67
- </tr>
68
- <tr bgcolor='blue' align='right'>
69
- <td abbr='test abbr'>hello world!</td>
70
- </tr>
71
- </table>
72
- =end
1
+ ##############################################################################
2
+ # intermediate1.rb
3
+ #
4
+ # A slightly more advanced HTML Table. This time we'll add some attributes,
5
+ # add a few rows both implicitly and explicitly, then configure it
6
+ # after-the-fact.
7
+ #
8
+ # You can run this via the "example:intermediate1" rake task.
9
+ ##############################################################################
10
+ require 'html/table'
11
+ include HTML
12
+
13
+ # Create a table, add two rows implicitly
14
+ table = Table.new{ |t|
15
+ t.border = 1
16
+ t.align = "left"
17
+ t.content = [
18
+ ["foo","bar","baz"],
19
+ [1,2]
20
+ ]
21
+ }
22
+
23
+ # Create a Table::Row object with one Data object added implicitly
24
+ row1 = Table::Row.new{ |r|
25
+ r.bgcolor = "red"
26
+ r.nowrap = true
27
+ r.content = "test"
28
+ }
29
+
30
+ # Create a Table::Row object, add a Data object explicitly (with some
31
+ # configuration to boot)
32
+ row2 = Table::Row.new{ |r|
33
+ r.bgcolor = "blue"
34
+ r.align = "right"
35
+ r.content = Table::Row::Data.new{ |d|
36
+ d.content = "hello world!"
37
+ d.abbr = "test abbr"
38
+ }
39
+ }
40
+
41
+ # Add the rows explicitly to the table
42
+ table.push row1, row2
43
+
44
+ # Let's configure the row that contains "foo","bar","baz"
45
+ # Remember, row and column counts start at 0, not 1
46
+ table.configure(0){ |r|
47
+ r.bgcolor = "green"
48
+ r.align = "right"
49
+ }
50
+
51
+ puts table.html
52
+
53
+ =begin
54
+ ### OUTPUT ###
55
+ <table border=1 align='left'>
56
+ <tr bgcolor='green' align='right'>
57
+ <td>foo</td>
58
+ <td>bar</td>
59
+ <td>baz</td>
60
+ </tr>
61
+ <tr>
62
+ <td>1</td>
63
+ <td>2</td>
64
+ </tr>
65
+ <tr bgcolor='red' nowrap>
66
+ <td>test</td>
67
+ </tr>
68
+ <tr bgcolor='blue' align='right'>
69
+ <td abbr='test abbr'>hello world!</td>
70
+ </tr>
71
+ </table>
72
+ =end
@@ -1,62 +1,62 @@
1
- ##############################################################################
2
- # intermediate2.rb
3
- #
4
- # A slightly more advanced HTML Table. This time we'll add some attributes,
5
- # add a few rows both implicitly and explicitly, then configure it
6
- # after-the-fact. We'll also play with Captions and Headers and generally
7
- # do things slightly different that intermdiate1.rb.
8
- #
9
- # You can run this via the "example:intermediate2" rake task.
10
- ##############################################################################
11
- require 'html/table'
12
- include HTML
13
-
14
- table = Table.new
15
- table.border = 1
16
- table.cellpadding = 5
17
-
18
- caption = Table::Caption.new
19
- caption.content = "This is a caption!"
20
-
21
- row1 = Table::Row.new
22
- row2 = Table::Row.new
23
-
24
- row1.bgcolor = "red"
25
- row2.bgcolor = "blue"
26
-
27
- d1 = Table::Row::Data.new{ |d| d.content = "foo" }
28
- d2 = Table::Row::Data.new{ |d| d.content = "bar" }
29
- d3 = Table::Row::Data.new{ |d| d.content = "baz" }
30
-
31
- row1[0..2] = d1, d2, d3
32
-
33
- d4 = Table::Row::Data.new{ |d| d.content = "hello" }
34
- d5 = Table::Row::Data.new{ |d| d.content = "world" }
35
-
36
- h1 = Table::Row::Header.new
37
- h1.content = "This is a header"
38
- h1.colspan = 2
39
-
40
- row2.unshift h1
41
- row2.push d4, d5
42
-
43
- table.push row1, row2
44
- table.push caption # automatically bumped to row 0
45
-
46
- puts table.html
47
-
48
- =begin
49
- <table border=1 cellpadding=5>
50
- <caption>This is a caption!</caption>
51
- <tr bgcolor='red'>
52
- <td>foo</td>
53
- <td>bar</td>
54
- <td>baz</td>
55
- </tr>
56
- <tr bgcolor='blue'>
57
- <th colspan=2>This is a header</th>
58
- <td>hello</td>
59
- <td>world</td>
60
- </tr>
61
- </table>
62
- =end
1
+ ##############################################################################
2
+ # intermediate2.rb
3
+ #
4
+ # A slightly more advanced HTML Table. This time we'll add some attributes,
5
+ # add a few rows both implicitly and explicitly, then configure it
6
+ # after-the-fact. We'll also play with Captions and Headers and generally
7
+ # do things slightly different that intermdiate1.rb.
8
+ #
9
+ # You can run this via the "example:intermediate2" rake task.
10
+ ##############################################################################
11
+ require 'html/table'
12
+ include HTML
13
+
14
+ table = Table.new
15
+ table.border = 1
16
+ table.cellpadding = 5
17
+
18
+ caption = Table::Caption.new
19
+ caption.content = "This is a caption!"
20
+
21
+ row1 = Table::Row.new
22
+ row2 = Table::Row.new
23
+
24
+ row1.bgcolor = "red"
25
+ row2.bgcolor = "blue"
26
+
27
+ d1 = Table::Row::Data.new{ |d| d.content = "foo" }
28
+ d2 = Table::Row::Data.new{ |d| d.content = "bar" }
29
+ d3 = Table::Row::Data.new{ |d| d.content = "baz" }
30
+
31
+ row1[0..2] = d1, d2, d3
32
+
33
+ d4 = Table::Row::Data.new{ |d| d.content = "hello" }
34
+ d5 = Table::Row::Data.new{ |d| d.content = "world" }
35
+
36
+ h1 = Table::Row::Header.new
37
+ h1.content = "This is a header"
38
+ h1.colspan = 2
39
+
40
+ row2.unshift h1
41
+ row2.push d4, d5
42
+
43
+ table.push row1, row2
44
+ table.push caption # automatically bumped to row 0
45
+
46
+ puts table.html
47
+
48
+ =begin
49
+ <table border=1 cellpadding=5>
50
+ <caption>This is a caption!</caption>
51
+ <tr bgcolor='red'>
52
+ <td>foo</td>
53
+ <td>bar</td>
54
+ <td>baz</td>
55
+ </tr>
56
+ <tr bgcolor='blue'>
57
+ <th colspan=2>This is a header</th>
58
+ <td>hello</td>
59
+ <td>world</td>
60
+ </tr>
61
+ </table>
62
+ =end