html-table 1.5.0 → 1.5.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.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +3 -1
  3. data.tar.gz.sig +0 -0
  4. data/CHANGES +159 -155
  5. data/MANIFEST +59 -59
  6. data/README +132 -132
  7. data/certs/djberg96_pub.pem +22 -17
  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 +159 -158
  56. data/test/test_tablesection.rb +42 -42
  57. data/test/test_tag_handler.rb +90 -90
  58. metadata +25 -20
  59. metadata.gz.sig +0 -0
@@ -1,158 +1,158 @@
1
- == Description
2
- An interface for generating HTML Tables with Ruby.
3
-
4
- == Synopsis
5
- require "html/table"
6
- include HTML
7
-
8
- table = HTML::Table.new{ |t|
9
- t.border = 1
10
- t.bgcolor = "red"
11
- }
12
-
13
- table.push Table::Row.new{ |r|
14
- r.align = "left"
15
- r.bgcolor = "green"
16
- r.content = ["foo","bar","baz"]
17
- }
18
-
19
- row = Table::Row.new{ |r|
20
- r.align = "right"
21
- r.bgcolor = "blue"
22
- r.content = "hello world"
23
- }
24
-
25
- table[1] = row
26
-
27
- puts table.html
28
-
29
- #### output ####
30
- <table border=1 bgcolor='red'>
31
- <tr align='left' bgcolor='green'> # row 0
32
- <td>foo</td> # column 0
33
- <td>bar</td> # column 1
34
- <td>baz</td> # column 2
35
- </tr>
36
- <tr align='right' bgcolor='blue'> # row 1
37
- <td>hello world</td> # column 0
38
- </tr>
39
- </table>
40
-
41
- See the 'examples' directory for more examples.
42
-
43
- == Mixins
44
- Table is a subclass of Array, and therefore mixes in Enumerable. The
45
- push, unshift and []= methods have been modified. See below for details.
46
-
47
- Table also mixes in the AttributeHandler module which provides methods
48
- for adding attributes to each of the tag types. See attributes.rdoc for
49
- more details.
50
-
51
- == Constants
52
- VERSION
53
- The current version number (a String). This serves as the VERSION number
54
- for the entire html-table package.
55
-
56
- == Class Methods
57
- Table.new(arg=nil)
58
- Table.new(arg=nil){ |t| ... }
59
- Creates a new Table instance. You can set attributes for the Table by
60
- passing a block.
61
-
62
- If +arg+ is supplied, it is automatically interpreted to be content. This
63
- is a shortcut for Table.new{ |t| t.content = '...' }.
64
-
65
- Table.global_end_tags?
66
- Returns the value of the global_end_tags class variable. By default,
67
- this is true.
68
-
69
- Table.global_end_tags=(true|false)
70
- Sets the global_end_tags class variable. This determines class-wide, for
71
- those classes where end tags are optional, whether or not end tags are
72
- included in the final html. Classes where end tags are not optional are
73
- not affected.
74
-
75
- If set to false, this overrides individual class end tags settings.
76
-
77
- == Instance Methods
78
- Table#[]=(index, object)
79
- Assigns +object+ to +index+. There are restrictions to the data
80
- types that you can assign to a Table instance. They include Caption,
81
- ColGroup, Body, Foot, Head and Row. You cannot assign a slice (yet).
82
-
83
- Table#configure(row_num, col_num=0){ |td_object| block }
84
- Configures column +col_num+ at row +row_num+, using a block to set
85
- options. If only +row_num+ is specified, then you'll be configuring
86
- only the row. Generally speaking, that means you'll be configure a
87
- Table::Row and not a Data or Header object.
88
-
89
- Table#content
90
- Returns the HTML content.
91
-
92
- Table#content=(arg)
93
- Adds data to the Table. The +arg+ may be a Table::Row object, an
94
- Array of Table::Row objects, an Array of Array's, an Array of Strings,
95
- or a single String. In the last two cases, a single Table::Row with a
96
- single Table::Row::Data object is created, with the string as the content.
97
-
98
- Table#html
99
- Returns the entire HTML content for the Table Object. This is what you
100
- want to print when you're done creating your Table.
101
-
102
- Table#push(obj)
103
- Pushes +obj+ onto the Table, where +obj+ must be a Row, Caption,
104
- ColGroup, Body, Foot or Head object. Also note that the Caption and Head
105
- objects will automatically put themselves at row 0 (or possibly 1, in the
106
- case of a Head object where a Caption already exists).
107
-
108
- Table#unshift(obj)
109
- Unshifts +obj+ onto the Table. The same rules apply to unshift as
110
- they do to push.
111
-
112
- == Notes
113
- A Table consists of Table::Row, Table::Caption, Table::ColGroup,
114
- Table::Body, Table::Foot, Table::Head and Table::Row objects. Table::Row
115
- objects in turn consist of Table::Row::Data and Table::Row::Header
116
- objects. Table::ColGroup objects consist of Table::ColGroup::Col
117
- objects. Table::Head, Table::Body and Table::Foot objects consist
118
- of Table::Row objects.
119
-
120
- String attributes are quoted. Numeric attributes are not.
121
-
122
- Some attributes have type checking. Some check for valid arguments. In
123
- the latter case, it is case-insensitive. See the documentation on
124
- specific methods for more details.
125
-
126
- Using a non-standard extension (e.g. "background") will send a warning to
127
- STDERR in $VERBOSE (-w) mode.
128
-
129
- == Known Bugs
130
- None that I'm aware of. Please report bugs on the project page at
131
- http://www.rubyforge.org/projects/shards.
132
-
133
- == Future Plans
134
- Allow standard html tags to be added to elements as appropriate, such
135
- as <B>, <I>, etc.
136
-
137
- CSS support.
138
-
139
- == Acknowledgements
140
- Anthony Peacock, for giving me ideas with his HTML::Table Perl module.
141
- Holden Glova and Culley Harrelson for API suggestions and comments.
142
-
143
- == License
144
- Ruby's
145
-
146
- == Copyright
147
- (C) 2003-2008 Daniel J. Berger
148
- All Rights Reserved
149
-
150
- == Warranty
151
- This package is provided "as is" and without any express or
152
- implied warranties, including, without limitation, the implied
153
- warranties of merchantability and fitness for a particular purpose.
154
-
155
- == Author
156
- Daniel J. Berger
157
- djberg96 at nospam at gmail dot com
158
- imperator on IRC (irc.freenode.net)
1
+ == Description
2
+ An interface for generating HTML Tables with Ruby.
3
+
4
+ == Synopsis
5
+ require "html/table"
6
+ include HTML
7
+
8
+ table = HTML::Table.new{ |t|
9
+ t.border = 1
10
+ t.bgcolor = "red"
11
+ }
12
+
13
+ table.push Table::Row.new{ |r|
14
+ r.align = "left"
15
+ r.bgcolor = "green"
16
+ r.content = ["foo","bar","baz"]
17
+ }
18
+
19
+ row = Table::Row.new{ |r|
20
+ r.align = "right"
21
+ r.bgcolor = "blue"
22
+ r.content = "hello world"
23
+ }
24
+
25
+ table[1] = row
26
+
27
+ puts table.html
28
+
29
+ #### output ####
30
+ <table border=1 bgcolor='red'>
31
+ <tr align='left' bgcolor='green'> # row 0
32
+ <td>foo</td> # column 0
33
+ <td>bar</td> # column 1
34
+ <td>baz</td> # column 2
35
+ </tr>
36
+ <tr align='right' bgcolor='blue'> # row 1
37
+ <td>hello world</td> # column 0
38
+ </tr>
39
+ </table>
40
+
41
+ See the 'examples' directory for more examples.
42
+
43
+ == Mixins
44
+ Table is a subclass of Array, and therefore mixes in Enumerable. The
45
+ push, unshift and []= methods have been modified. See below for details.
46
+
47
+ Table also mixes in the AttributeHandler module which provides methods
48
+ for adding attributes to each of the tag types. See attributes.rdoc for
49
+ more details.
50
+
51
+ == Constants
52
+ VERSION
53
+ The current version number (a String). This serves as the VERSION number
54
+ for the entire html-table package.
55
+
56
+ == Class Methods
57
+ Table.new(arg=nil)
58
+ Table.new(arg=nil){ |t| ... }
59
+ Creates a new Table instance. You can set attributes for the Table by
60
+ passing a block.
61
+
62
+ If +arg+ is supplied, it is automatically interpreted to be content. This
63
+ is a shortcut for Table.new{ |t| t.content = '...' }.
64
+
65
+ Table.global_end_tags?
66
+ Returns the value of the global_end_tags class variable. By default,
67
+ this is true.
68
+
69
+ Table.global_end_tags=(true|false)
70
+ Sets the global_end_tags class variable. This determines class-wide, for
71
+ those classes where end tags are optional, whether or not end tags are
72
+ included in the final html. Classes where end tags are not optional are
73
+ not affected.
74
+
75
+ If set to false, this overrides individual class end tags settings.
76
+
77
+ == Instance Methods
78
+ Table#[]=(index, object)
79
+ Assigns +object+ to +index+. There are restrictions to the data
80
+ types that you can assign to a Table instance. They include Caption,
81
+ ColGroup, Body, Foot, Head and Row. You cannot assign a slice (yet).
82
+
83
+ Table#configure(row_num, col_num=0){ |td_object| block }
84
+ Configures column +col_num+ at row +row_num+, using a block to set
85
+ options. If only +row_num+ is specified, then you'll be configuring
86
+ only the row. Generally speaking, that means you'll be configure a
87
+ Table::Row and not a Data or Header object.
88
+
89
+ Table#content
90
+ Returns the HTML content.
91
+
92
+ Table#content=(arg)
93
+ Adds data to the Table. The +arg+ may be a Table::Row object, an
94
+ Array of Table::Row objects, an Array of Array's, an Array of Strings,
95
+ or a single String. In the last two cases, a single Table::Row with a
96
+ single Table::Row::Data object is created, with the string as the content.
97
+
98
+ Table#html
99
+ Returns the entire HTML content for the Table Object. This is what you
100
+ want to print when you're done creating your Table.
101
+
102
+ Table#push(obj)
103
+ Pushes +obj+ onto the Table, where +obj+ must be a Row, Caption,
104
+ ColGroup, Body, Foot or Head object. Also note that the Caption and Head
105
+ objects will automatically put themselves at row 0 (or possibly 1, in the
106
+ case of a Head object where a Caption already exists).
107
+
108
+ Table#unshift(obj)
109
+ Unshifts +obj+ onto the Table. The same rules apply to unshift as
110
+ they do to push.
111
+
112
+ == Notes
113
+ A Table consists of Table::Row, Table::Caption, Table::ColGroup,
114
+ Table::Body, Table::Foot, Table::Head and Table::Row objects. Table::Row
115
+ objects in turn consist of Table::Row::Data and Table::Row::Header
116
+ objects. Table::ColGroup objects consist of Table::ColGroup::Col
117
+ objects. Table::Head, Table::Body and Table::Foot objects consist
118
+ of Table::Row objects.
119
+
120
+ String attributes are quoted. Numeric attributes are not.
121
+
122
+ Some attributes have type checking. Some check for valid arguments. In
123
+ the latter case, it is case-insensitive. See the documentation on
124
+ specific methods for more details.
125
+
126
+ Using a non-standard extension (e.g. "background") will send a warning to
127
+ STDERR in $VERBOSE (-w) mode.
128
+
129
+ == Known Bugs
130
+ None that I'm aware of. Please report bugs on the project page at
131
+ http://www.rubyforge.org/projects/shards.
132
+
133
+ == Future Plans
134
+ Allow standard html tags to be added to elements as appropriate, such
135
+ as <B>, <I>, etc.
136
+
137
+ CSS support.
138
+
139
+ == Acknowledgements
140
+ Anthony Peacock, for giving me ideas with his HTML::Table Perl module.
141
+ Holden Glova and Culley Harrelson for API suggestions and comments.
142
+
143
+ == License
144
+ Ruby's
145
+
146
+ == Copyright
147
+ (C) 2003-2008 Daniel J. Berger
148
+ All Rights Reserved
149
+
150
+ == Warranty
151
+ This package is provided "as is" and without any express or
152
+ implied warranties, including, without limitation, the implied
153
+ warranties of merchantability and fitness for a particular purpose.
154
+
155
+ == Author
156
+ Daniel J. Berger
157
+ djberg96 at nospam at gmail dot com
158
+ imperator on IRC (irc.freenode.net)
@@ -1,9 +1,9 @@
1
- == Description
2
- A Table::Body object represents a single <TBODY></TBODY> instance for an
3
- HTML Table.
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.
1
+ == Description
2
+ A Table::Body object represents a single <TBODY></TBODY> instance for an
3
+ HTML Table.
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.
@@ -1,9 +1,9 @@
1
- == Description
2
- A Table::Caption object represents a single <CAPTION></CAPTION> instance
3
- for an HTML Table.
4
- == Notes
5
- The Table::Caption class is virtually identical to the Table::Row::Data
6
- class. There is one important behavioral difference, however. First,
7
- there can only be one Table::Caption. If you attempt to add a second one,
8
- it will merely overwrite the existing one. Second, a Table::Caption is
9
- always bumped to index 0.
1
+ == Description
2
+ A Table::Caption object represents a single <CAPTION></CAPTION> instance
3
+ for an HTML Table.
4
+ == Notes
5
+ The Table::Caption class is virtually identical to the Table::Row::Data
6
+ class. There is one important behavioral difference, however. First,
7
+ there can only be one Table::Caption. If you attempt to add a second one,
8
+ it will merely overwrite the existing one. Second, a Table::Caption is
9
+ always bumped to index 0.
@@ -1,8 +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.
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.
@@ -1,9 +1,9 @@
1
- == Description
2
- A Table::ColGroup::Col object represents a single <COL> instance for an
3
- HTML Table.
4
-
5
- == Notes
6
- In virtually every respect the Table::ColGroup::Col class is identical to
7
- the Table::Row::Data class. The only differences are that a
8
- Table::ColGroup::Col instance does not contain any content, nor does it
9
- include an end tag.
1
+ == Description
2
+ A Table::ColGroup::Col object represents a single <COL> instance for an
3
+ HTML Table.
4
+
5
+ == Notes
6
+ In virtually every respect the Table::ColGroup::Col class is identical to
7
+ the Table::Row::Data class. The only differences are that a
8
+ Table::ColGroup::Col instance does not contain any content, nor does it
9
+ include an end tag.
@@ -1,15 +1,15 @@
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
- content = Table::Content.new('my content') do
12
- bold true
13
- italics true
14
- underline true
15
- end
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
+ content = Table::Content.new('my content') do
12
+ bold true
13
+ italics true
14
+ underline true
15
+ end
@@ -1,8 +1,8 @@
1
- == Description
2
- A Table::Foot object represents a single <TFOOT></TFOOT> instance for an
3
- HTML Table.
4
- == Notes
5
- In virtually every respect the Table::Foot class is identical to
6
- the Table or Table::Row class. There is one significant difference.
7
- The Table::Foot class is a singleton. There can be only one
8
- Table::Foot instance per table.
1
+ == Description
2
+ A Table::Foot object represents a single <TFOOT></TFOOT> instance for an
3
+ HTML Table.
4
+ == Notes
5
+ In virtually every respect the Table::Foot class is identical to
6
+ the Table or Table::Row class. There is one significant difference.
7
+ The Table::Foot class is a singleton. There can be only one
8
+ Table::Foot instance per table.
@@ -1,11 +1,11 @@
1
- == Description
2
- A Table::Head object represents a single <THEAD></THEAD> instance for an
3
- HTML Table.
4
-
5
- == Notes
6
- In virtually every respect the Table::Head class is identical to
7
- the Table or Table::Row class. There are two significant differences.
8
- First, the Table::Head class is a singleton. There can be only one
9
- Table::Head instance per table. Second, if an instance of Table::Head
10
- is added to a table, it will be automatically be put at index 0 (or 1
11
- if a Table::Caption exists).
1
+ == Description
2
+ A Table::Head object represents a single <THEAD></THEAD> instance for an
3
+ HTML Table.
4
+
5
+ == Notes
6
+ In virtually every respect the Table::Head class is identical to
7
+ the Table or Table::Row class. There are two significant differences.
8
+ First, the Table::Head class is a singleton. There can be only one
9
+ Table::Head instance per table. Second, if an instance of Table::Head
10
+ is added to a table, it will be automatically be put at index 0 (or 1
11
+ if a Table::Caption exists).