terminal-table 1.4.5 → 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 690e92a400d543a8d7b55922fda25db11d1aa46d
4
+ data.tar.gz: 3b71abe9af27c9dc2360a7c3bd9651b00ff9de0d
5
+ SHA512:
6
+ metadata.gz: a5cae8343447741182f569b19661341ee1b01daf5ac8ca20dea290a1e66aa8dedb00215cd9e67ea55cad9b1e3bcbf8b1dad27533c069b689033a184ad376f269
7
+ data.tar.gz: 78cd38cbb66f3c98b74cdc869a30447da2751d06baf4bd853206e7ecaf4e7444ff4c286a0b93c64fc3fbe4c741033c9aaec6362e98a1f354eb69926288692c5f
data/History.rdoc CHANGED
@@ -1,54 +1,48 @@
1
- 1.4.5 / 2012-3-15
2
- ==================
3
-
4
- * Add color support.
5
- * Various bugfixes
6
-
7
- 1.4.3 / 2011-10-13
8
- ==================
9
-
10
- * Optimize for faster table output.
11
-
12
- 1.4.2 / 2010-01-14
13
- ==================
14
-
15
- * Fixed some bugs with colspan
16
-
17
- === 1.4.1 / 2009-12-18
18
-
19
- * Fix column alignment with separators.
20
-
21
- === 1.4.0 / 2009-12-18
22
-
23
- * Can now add :seperator arbitrarily in a table [thanks splattael]
24
- * Fix common typo: seperator -> separator [thanks splattael]
25
-
26
- === 1.3.0 / 2009-10-16
27
-
28
- * Major refactoring (functionality remains the same)
29
-
30
- === 1.2.0 / 2009-08-06
31
-
32
- * Added colspan support to table
33
-
34
- === 1.1.0 / 2009-08-06
35
-
36
- * Added colspan support to table
37
-
38
- === 1.1.0 / 2009-07-13
39
-
40
- * Added Table#==
41
-
42
- === 1.0.5 / 2009-03-14
43
-
44
- * Allowing nil to be passed to table for headings
45
- * Revised doc to show that rows can be splatted now
46
- * Misc refactoring
47
-
48
- === 1.0.3 / 2009-01-15
49
-
50
- * Moved yield or eval to Terminal::Table initialize where it belongs
51
-
52
- === 1.0.0 / 2009-01-13
53
-
54
- * Initial release
1
+ 1.4.3 / 2011-10-13
2
+ ==================
3
+
4
+ * Optimize for faster table output.
5
+
6
+ 1.4.2 / 2010-01-14
7
+ ==================
8
+
9
+ * Fixed some bugs with colspan
10
+
11
+ === 1.4.1 / 2009-12-18
12
+
13
+ * Fix column alignment with separators.
14
+
15
+ === 1.4.0 / 2009-12-18
16
+
17
+ * Can now add :seperator arbitrarily in a table [thanks splattael]
18
+ * Fix common typo: seperator -> separator [thanks splattael]
19
+
20
+ === 1.3.0 / 2009-10-16
21
+
22
+ * Major refactoring (functionality remains the same)
23
+
24
+ === 1.2.0 / 2009-08-06
25
+
26
+ * Added colspan support to table
27
+
28
+ === 1.1.0 / 2009-08-06
29
+
30
+ * Added colspan support to table
31
+
32
+ === 1.1.0 / 2009-07-13
33
+
34
+ * Added Table#==
35
+
36
+ === 1.0.5 / 2009-03-14
37
+
38
+ * Allowing nil to be passed to table for headings
39
+ * Revised doc to show that rows can be splatted now
40
+ * Misc refactoring
41
+
42
+ === 1.0.3 / 2009-01-15
43
+
44
+ * Moved yield or eval to Terminal::Table initialize where it belongs
45
+
46
+ === 1.0.0 / 2009-01-13
47
+
48
+ * Initial release
data/Manifest CHANGED
@@ -6,16 +6,12 @@ Todo.rdoc
6
6
  examples/examples.rb
7
7
  lib/terminal-table.rb
8
8
  lib/terminal-table/cell.rb
9
- lib/terminal-table/core_ext.rb
10
- lib/terminal-table/heading.rb
11
9
  lib/terminal-table/import.rb
12
10
  lib/terminal-table/table.rb
13
11
  lib/terminal-table/table_helper.rb
14
12
  lib/terminal-table/version.rb
15
13
  spec/cell_spec.rb
16
- spec/core_ext_spec.rb
17
14
  spec/import_spec.rb
18
- spec/spec.opts
19
15
  spec/spec_helper.rb
20
16
  spec/table_spec.rb
21
17
  tasks/docs.rake
data/README.rdoc CHANGED
@@ -1,240 +1,240 @@
1
- = Terminal Table
2
-
3
- == Description
4
-
5
- Terminal Table is a fast and simple, yet feature rich ASCII table generator written in Ruby.
6
-
7
- == Installation
8
-
9
- Install http://gemcutter.org and execute:
10
-
11
- $ gem install terminal-table
12
-
13
- == Usage
14
-
15
- === Basics
16
-
17
- To use Terminal Table:
18
-
19
- require 'terminal-table'
20
-
21
- To generate a table, provide an array of arrays (which are interpreted as rows):
22
-
23
- rows = []
24
- rows << ['One', 1]
25
- rows << ['Two', 2]
26
- rows << ['Three', 3]
27
- table = Terminal::Table.new :rows => rows
28
-
29
- # > puts table
30
- #
31
- # +-------+---+
32
- # | One | 1 |
33
- # | Two | 2 |
34
- # | Three | 3 |
35
- # +-------+---+
36
-
37
-
38
- The constructor can also be given a block which is either yielded the Table object or instance evaluated:
39
-
40
- table = Terminal::Table.new do |t|
41
- t.rows = rows
42
- end
43
-
44
- table = Terminal::Table.new do
45
- self.rows = rows
46
- end
47
-
48
- Adding rows one by one:
49
-
50
- table = Terminal::Table.new do |t|
51
- t << ['One', 1]
52
- t.add_row ['Two', 2]
53
- end
54
-
55
- To add separators between rows:
56
-
57
- table = Terminal::Table.new do |t|
58
- t << ['One', 1]
59
- t << :separator
60
- t.add_row ['Two', 2]
61
- t.add_separator
62
- t.add_row ['Three', 3]
63
- end
64
-
65
- # > puts table
66
- #
67
- # +-------+---+
68
- # | One | 1 |
69
- # +-------+---+
70
- # | Two | 2 |
71
- # +-------+---+
72
- # | Three | 3 |
73
- # +-------+---+
74
-
75
- Cells can handle multiline content:
76
-
77
- table = Terminal::Table.new do |t|
78
- t << ['One', 1]
79
- t << :separator
80
- t.add_row ["Two\nDouble", 2]
81
- t.add_separator
82
- t.add_row ['Three', 3]
83
- end
84
-
85
- # > puts table
86
- #
87
- # +--------+---+
88
- # | One | 1 |
89
- # +--------+---+
90
- # | Two | 2 |
91
- # | Double | |
92
- # +--------+---+
93
- # | Three | 3 |
94
- # +--------+---+
95
-
96
- === Head
97
-
98
- To add a head to the table:
99
-
100
- table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows
101
-
102
- # > puts table
103
- #
104
- # +-------+--------+
105
- # | Word | Number |
106
- # +-------+--------+
107
- # | One | 1 |
108
- # | Two | 2 |
109
- # | Three | 3 |
110
- # +-------+--------+
111
-
112
- === Title
113
-
114
- To add a title to the table:
115
-
116
- table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows
117
-
118
- # > puts table
119
- #
120
- # +------------+--------+
121
- # | Cheatsheet |
122
- # +------------+--------+
123
- # | Word | Number |
124
- # +------------+--------+
125
- # | One | 1 |
126
- # | Two | 2 |
127
- # | Three | 3 |
128
- # +------------+--------+
129
-
130
- === Alignment
131
-
132
- To align the second column to the right:
133
-
134
- table.align_column(1, :right)
135
-
136
- # > puts table
137
- #
138
- # +-------+--------+
139
- # | Word | Number |
140
- # +-------+--------+
141
- # | One | 1 |
142
- # | Two | 2 |
143
- # | Three | 3 |
144
- # +-------+--------+
145
-
146
- To align an individual cell, you specify the cell value in a hash along the alignment:
147
-
148
- table << ["Four", {:value => 4.0, :alignment => :center}]
149
-
150
- # > puts table
151
- #
152
- # +-------+--------+
153
- # | Word | Number |
154
- # +-------+--------+
155
- # | One | 1 |
156
- # | Two | 2 |
157
- # | Three | 3 |
158
- # | Four | 4.0 |
159
- # +-------+--------+
160
-
161
- === Style
162
-
163
- To specifify style options:
164
-
165
- table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80}
166
-
167
- # > puts table
168
- #
169
- # +--------------------------------------+---------------------------------------+
170
- # | Word | Number |
171
- # +--------------------------------------+---------------------------------------+
172
- # | One | 1 |
173
- # | Two | 2 |
174
- # | Three | 3 |
175
- # +--------------------------------------+---------------------------------------+
176
-
177
- And change styles on the fly:
178
-
179
- table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"}
180
-
181
- # > puts table
182
- #
183
- # x====================x=================x
184
- # | Cheatsheet |
185
- # x====================x=================x
186
- # | Word | Number |
187
- # x====================x=================x
188
- # | One | 1 |
189
- # | Two | 2 |
190
- # | Three | 3 |
191
- # x====================x=================x
192
-
193
- To change the default style options:
194
-
195
- Terminal::Style.defaults = {:width => 80}
196
-
197
- All Table objects created afterwards will inherit these defaults.
198
-
199
- === Constructor options and setter methods
200
-
201
- Valid options for the constructor are :rows, :headings, :style and :title - and all options can also be set on the created table object by their setter method:
202
-
203
- table = Terminal::Table.new
204
- table.title = "Cheatsheet"
205
- table.headings = ['Word', 'Number']
206
- table.rows = rows
207
- table.style = {:width => 40}
208
-
209
- == More examples
210
-
211
- For more examples, please see the examples/examples.rb file included in the source distribution.
212
-
213
- == Author
214
-
215
- TJ Holowaychuk <tj@vision-media.ca>
216
-
217
- == License
218
-
219
- (The MIT License)
220
-
221
- Copyright (c) 2008-2009 TJ Holowaychuk <tj@vision-media.ca>
222
-
223
- Permission is hereby granted, free of charge, to any person obtaining
224
- a copy of this software and associated documentation files (the
225
- 'Software'), to deal in the Software without restriction, including
226
- without limitation the rights to use, copy, modify, merge, publish,
227
- distribute, sublicense, an d/or sell copies of the Software, and to
228
- permit persons to whom the Software is furnished to do so, subject to
229
- the following conditions:
230
-
231
- The above copyright notice and this permission notice shall be
232
- included in all copies or substantial portions of the Software.
233
-
234
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
235
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
236
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
237
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
238
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
239
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
240
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ = Terminal Table
2
+
3
+ == Description
4
+
5
+ Terminal Table is a fast and simple, yet feature rich ASCII table generator written in Ruby.
6
+
7
+ == Installation
8
+
9
+ Install http://gemcutter.org and execute:
10
+
11
+ $ gem install terminal-table
12
+
13
+ == Usage
14
+
15
+ === Basics
16
+
17
+ To use Terminal Table:
18
+
19
+ require 'terminal-table'
20
+
21
+ To generate a table, provide an array of arrays (which are interpreted as rows):
22
+
23
+ rows = []
24
+ rows << ['One', 1]
25
+ rows << ['Two', 2]
26
+ rows << ['Three', 3]
27
+ table = Terminal::Table.new :rows => rows
28
+
29
+ # > puts table
30
+ #
31
+ # +-------+---+
32
+ # | One | 1 |
33
+ # | Two | 2 |
34
+ # | Three | 3 |
35
+ # +-------+---+
36
+
37
+
38
+ The constructor can also be given a block which is either yielded the Table object or instance evaluated:
39
+
40
+ table = Terminal::Table.new do |t|
41
+ t.rows = rows
42
+ end
43
+
44
+ table = Terminal::Table.new do
45
+ self.rows = rows
46
+ end
47
+
48
+ Adding rows one by one:
49
+
50
+ table = Terminal::Table.new do |t|
51
+ t << ['One', 1]
52
+ t.add_row ['Two', 2]
53
+ end
54
+
55
+ To add separators between rows:
56
+
57
+ table = Terminal::Table.new do |t|
58
+ t << ['One', 1]
59
+ t << :separator
60
+ t.add_row ['Two', 2]
61
+ t.add_separator
62
+ t.add_row ['Three', 3]
63
+ end
64
+
65
+ # > puts table
66
+ #
67
+ # +-------+---+
68
+ # | One | 1 |
69
+ # +-------+---+
70
+ # | Two | 2 |
71
+ # +-------+---+
72
+ # | Three | 3 |
73
+ # +-------+---+
74
+
75
+ Cells can handle multiline content:
76
+
77
+ table = Terminal::Table.new do |t|
78
+ t << ['One', 1]
79
+ t << :separator
80
+ t.add_row ["Two\nDouble", 2]
81
+ t.add_separator
82
+ t.add_row ['Three', 3]
83
+ end
84
+
85
+ # > puts table
86
+ #
87
+ # +--------+---+
88
+ # | One | 1 |
89
+ # +--------+---+
90
+ # | Two | 2 |
91
+ # | Double | |
92
+ # +--------+---+
93
+ # | Three | 3 |
94
+ # +--------+---+
95
+
96
+ === Head
97
+
98
+ To add a head to the table:
99
+
100
+ table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows
101
+
102
+ # > puts table
103
+ #
104
+ # +-------+--------+
105
+ # | Word | Number |
106
+ # +-------+--------+
107
+ # | One | 1 |
108
+ # | Two | 2 |
109
+ # | Three | 3 |
110
+ # +-------+--------+
111
+
112
+ === Title
113
+
114
+ To add a title to the table:
115
+
116
+ table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows
117
+
118
+ # > puts table
119
+ #
120
+ # +------------+--------+
121
+ # | Cheatsheet |
122
+ # +------------+--------+
123
+ # | Word | Number |
124
+ # +------------+--------+
125
+ # | One | 1 |
126
+ # | Two | 2 |
127
+ # | Three | 3 |
128
+ # +------------+--------+
129
+
130
+ === Alignment
131
+
132
+ To align the second column to the right:
133
+
134
+ table.align_column(1, :right)
135
+
136
+ # > puts table
137
+ #
138
+ # +-------+--------+
139
+ # | Word | Number |
140
+ # +-------+--------+
141
+ # | One | 1 |
142
+ # | Two | 2 |
143
+ # | Three | 3 |
144
+ # +-------+--------+
145
+
146
+ To align an individual cell, you specify the cell value in a hash along the alignment:
147
+
148
+ table << ["Four", {:value => 4.0, :alignment => :center}]
149
+
150
+ # > puts table
151
+ #
152
+ # +-------+--------+
153
+ # | Word | Number |
154
+ # +-------+--------+
155
+ # | One | 1 |
156
+ # | Two | 2 |
157
+ # | Three | 3 |
158
+ # | Four | 4.0 |
159
+ # +-------+--------+
160
+
161
+ === Style
162
+
163
+ To specify style options:
164
+
165
+ table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80}
166
+
167
+ # > puts table
168
+ #
169
+ # +--------------------------------------+---------------------------------------+
170
+ # | Word | Number |
171
+ # +--------------------------------------+---------------------------------------+
172
+ # | One | 1 |
173
+ # | Two | 2 |
174
+ # | Three | 3 |
175
+ # +--------------------------------------+---------------------------------------+
176
+
177
+ And change styles on the fly:
178
+
179
+ table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"}
180
+
181
+ # > puts table
182
+ #
183
+ # x====================x=================x
184
+ # | Cheatsheet |
185
+ # x====================x=================x
186
+ # | Word | Number |
187
+ # x====================x=================x
188
+ # | One | 1 |
189
+ # | Two | 2 |
190
+ # | Three | 3 |
191
+ # x====================x=================x
192
+
193
+ To change the default style options:
194
+
195
+ Terminal::Style.defaults = {:width => 80}
196
+
197
+ All Table objects created afterwards will inherit these defaults.
198
+
199
+ === Constructor options and setter methods
200
+
201
+ Valid options for the constructor are :rows, :headings, :style and :title - and all options can also be set on the created table object by their setter method:
202
+
203
+ table = Terminal::Table.new
204
+ table.title = "Cheatsheet"
205
+ table.headings = ['Word', 'Number']
206
+ table.rows = rows
207
+ table.style = {:width => 40}
208
+
209
+ == More examples
210
+
211
+ For more examples, please see the examples/examples.rb file included in the source distribution.
212
+
213
+ == Author
214
+
215
+ TJ Holowaychuk <tj@vision-media.ca>
216
+
217
+ == License
218
+
219
+ (The MIT License)
220
+
221
+ Copyright (c) 2008-2009 TJ Holowaychuk <tj@vision-media.ca>
222
+
223
+ Permission is hereby granted, free of charge, to any person obtaining
224
+ a copy of this software and associated documentation files (the
225
+ 'Software'), to deal in the Software without restriction, including
226
+ without limitation the rights to use, copy, modify, merge, publish,
227
+ distribute, sublicense, an d/or sell copies of the Software, and to
228
+ permit persons to whom the Software is furnished to do so, subject to
229
+ the following conditions:
230
+
231
+ The above copyright notice and this permission notice shall be
232
+ included in all copies or substantial portions of the Software.
233
+
234
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
235
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
236
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
237
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
238
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
239
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
240
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.