galileo 0.1.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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/bin/galileo +9 -0
- data/galileo.gemspec +29 -0
- data/lib/galileo/version.rb +3 -0
- data/lib/galileo.rb +136 -0
- data/lib/terminal-table/.DS_Store +0 -0
- data/lib/terminal-table/Gemfile +7 -0
- data/lib/terminal-table/History.rdoc +48 -0
- data/lib/terminal-table/Manifest +24 -0
- data/lib/terminal-table/README.rdoc +240 -0
- data/lib/terminal-table/Rakefile +15 -0
- data/lib/terminal-table/Todo.rdoc +14 -0
- data/lib/terminal-table/examples/examples.rb +83 -0
- data/lib/terminal-table/lib/terminal-table/cell.rb +98 -0
- data/lib/terminal-table/lib/terminal-table/core_ext.rb +8 -0
- data/lib/terminal-table/lib/terminal-table/row.rb +53 -0
- data/lib/terminal-table/lib/terminal-table/separator.rb +14 -0
- data/lib/terminal-table/lib/terminal-table/style.rb +65 -0
- data/lib/terminal-table/lib/terminal-table/table.rb +261 -0
- data/lib/terminal-table/lib/terminal-table/table_helper.rb +9 -0
- data/lib/terminal-table/lib/terminal-table/version.rb +5 -0
- data/lib/terminal-table/lib/terminal-table.rb +13 -0
- data/lib/terminal-table/spec/cell_spec.rb +60 -0
- data/lib/terminal-table/spec/core_ext_spec.rb +18 -0
- data/lib/terminal-table/spec/import_spec.rb +11 -0
- data/lib/terminal-table/spec/row_spec.rb +25 -0
- data/lib/terminal-table/spec/spec.opts +1 -0
- data/lib/terminal-table/spec/spec_helper.rb +8 -0
- data/lib/terminal-table/spec/table_spec.rb +544 -0
- data/lib/terminal-table/tasks/docs.rake +13 -0
- data/lib/terminal-table/tasks/gemspec.rake +3 -0
- data/lib/terminal-table/tasks/spec.rake +25 -0
- data/lib/terminal-table/terminal-table.gemspec +30 -0
- data/lib/time/time-ago-in-words.rb +32 -0
- metadata +181 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
require "terminal-table/import"
|
4
|
+
|
5
|
+
describe Object do
|
6
|
+
describe "#table" do
|
7
|
+
it "should allow creation of a terminal table" do
|
8
|
+
table(['foo', 'bar'], ['a', 'b'], [1, 2]).should be_instance_of(Terminal::Table)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe Terminal::Table do
|
5
|
+
Row = Terminal::Table::Row
|
6
|
+
|
7
|
+
it "should default alignment to the left" do
|
8
|
+
row = Row.new Terminal::Table.new, ["a", "b", "c"]
|
9
|
+
cell = row.cells.first
|
10
|
+
cell.value.should == 'a'
|
11
|
+
cell.alignment.should == :left
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should allow overriding of alignment" do
|
15
|
+
row = Row.new Terminal::Table.new, [{:value => 'a', :alignment => :center}, "b", "c"]
|
16
|
+
cell = row.cells.first
|
17
|
+
cell.value.should == 'a'
|
18
|
+
cell.alignment.should == :center
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should calculate height for multiline cells" do
|
22
|
+
row = Row.new Terminal::Table.new, [{:value => 'a', :alignment => :center}, "b", "c\nb"]
|
23
|
+
row.height.should == 2
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -0,0 +1,544 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
module Terminal
|
5
|
+
describe Table do
|
6
|
+
before :each do
|
7
|
+
@table = Table.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should select columns" do
|
11
|
+
@table << ['foo', 'bar']
|
12
|
+
@table << ['big foo', 'big foo bar']
|
13
|
+
@table.column(1).should == ['bar', 'big foo bar']
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should select the column with headings at an index" do
|
17
|
+
@table << [1,2,3]
|
18
|
+
@table << [4,5,6]
|
19
|
+
@table.column_with_headings(2).should == [3,6]
|
20
|
+
end
|
21
|
+
|
22
|
+
#it "should select the columns with colspans > 1 in the index" do
|
23
|
+
# @table << [1,{:value => 2, :colspan => 2}]
|
24
|
+
# @table << [{:value => 3, :colspan => 2}, 4]
|
25
|
+
#end
|
26
|
+
|
27
|
+
it "should account for the colspan when selecting columns" do
|
28
|
+
@table << [1,2,3]
|
29
|
+
@table << [{:value => "4,5", :colspan => 2}, 6]
|
30
|
+
@table.column_with_headings(0).should == [1,"4,5"]
|
31
|
+
@table.column_with_headings(1).should == [2,"4,5"]
|
32
|
+
@table.column_with_headings(2).should == [3,6]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should render tables with colspan properly" do
|
36
|
+
@table << [1,2,3]
|
37
|
+
@table << [4,5,6]
|
38
|
+
@table << [{:value => "7", :colspan => 2}, 88]
|
39
|
+
@table.render.should == <<-EOF.deindent
|
40
|
+
+---+---+----+
|
41
|
+
| 1 | 2 | 3 |
|
42
|
+
| 4 | 5 | 6 |
|
43
|
+
| 7 | 88 |
|
44
|
+
+---+---+----+
|
45
|
+
EOF
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should count columns" do
|
49
|
+
@table << [1, 2, 3]
|
50
|
+
@table.number_of_columns.should == 3
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should iterate columns" do
|
54
|
+
@table << [1, 2, 3]
|
55
|
+
@table << [4, 5, 6]
|
56
|
+
@table.columns.should == [[1, 4], [2, 5], [3, 6]]
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should select columns" do
|
60
|
+
@table.headings = ['one', 'two']
|
61
|
+
@table << ['foo', 'bar']
|
62
|
+
@table << ['big foo', 'big foo bar']
|
63
|
+
@table.column(1).should == ['bar', 'big foo bar']
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should select columns when using hashes" do
|
67
|
+
@table.headings = ['one', 'two']
|
68
|
+
@table.rows = [[{ :value => 'a', :align => :left }, 1], ['b', 2], ['c', 3]]
|
69
|
+
@table.column(0).should == ['a', 'b', 'c']
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should find column length" do
|
73
|
+
@table << ['foo', 'bar', 'a']
|
74
|
+
@table << ['big foo', 'big foo bar']
|
75
|
+
@table.column_width(1).should == 11
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should find column length with headings" do
|
79
|
+
@table.headings = ['one', 'super long heading']
|
80
|
+
@table << ['foo', 'bar', 'a']
|
81
|
+
@table << ['big foo', 'big foo bar']
|
82
|
+
@table.column_width(1).should == 18
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should render separators" do
|
86
|
+
@table.headings = ['Char', 'Num']
|
87
|
+
@table << ['a', 1]
|
88
|
+
separator = Terminal::Table::Separator.new(@table)
|
89
|
+
separator.render.should == '+------+-----+'
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should add separator" do
|
93
|
+
@table << ['a', 1]
|
94
|
+
@table.add_separator
|
95
|
+
@table << ['b', 2]
|
96
|
+
@table.rows.size.should == 2
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should render an empty table properly" do
|
100
|
+
@table.render.should == <<-EOF.deindent
|
101
|
+
++
|
102
|
+
++
|
103
|
+
EOF
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should render properly" do
|
107
|
+
@table.headings = ['Char', 'Num']
|
108
|
+
@table << ['a', 1]
|
109
|
+
@table << ['b', 2]
|
110
|
+
@table << ['c', 3]
|
111
|
+
@table.render.should == <<-EOF.deindent
|
112
|
+
+------+-----+
|
113
|
+
| Char | Num |
|
114
|
+
+------+-----+
|
115
|
+
| a | 1 |
|
116
|
+
| b | 2 |
|
117
|
+
| c | 3 |
|
118
|
+
+------+-----+
|
119
|
+
EOF
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should render styles properly" do
|
123
|
+
@table.headings = ['Char', 'Num']
|
124
|
+
@table.style = {:border_x => "=", :border_y => ":", :border_i => "x", :padding_left => 0, :padding_right => 2}
|
125
|
+
@table << ['a', 1]
|
126
|
+
@table << ['b', 2]
|
127
|
+
@table << ['c', 3]
|
128
|
+
@table.style.padding_right.should == 2
|
129
|
+
@table.render.should == <<-EOF.deindent
|
130
|
+
x======x=====x
|
131
|
+
:Char :Num :
|
132
|
+
x======x=====x
|
133
|
+
:a :1 :
|
134
|
+
:b :2 :
|
135
|
+
:c :3 :
|
136
|
+
x======x=====x
|
137
|
+
EOF
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
it "should render default alignment properly" do
|
142
|
+
@table.headings = ['Char', 'Num']
|
143
|
+
@table << ['a', 1]
|
144
|
+
@table << ['b', 2]
|
145
|
+
@table << ['c', 3]
|
146
|
+
@table.style.width = 21
|
147
|
+
@table.style.alignment = :right
|
148
|
+
@table.render.should == <<-EOF.deindent
|
149
|
+
+---------+---------+
|
150
|
+
| Char | Num |
|
151
|
+
+---------+---------+
|
152
|
+
| a | 1 |
|
153
|
+
| b | 2 |
|
154
|
+
| c | 3 |
|
155
|
+
+---------+---------+
|
156
|
+
EOF
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should render width properly" do
|
160
|
+
@table.headings = ['Char', 'Num']
|
161
|
+
@table << ['a', 1]
|
162
|
+
@table << ['b', 2]
|
163
|
+
@table << ['c', 3]
|
164
|
+
@table.style.width = 21
|
165
|
+
@table.render.should == <<-EOF.deindent
|
166
|
+
+---------+---------+
|
167
|
+
| Char | Num |
|
168
|
+
+---------+---------+
|
169
|
+
| a | 1 |
|
170
|
+
| b | 2 |
|
171
|
+
| c | 3 |
|
172
|
+
+---------+---------+
|
173
|
+
EOF
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should render title properly" do
|
177
|
+
@table.title = "Title"
|
178
|
+
@table.headings = ['Char', 'Num']
|
179
|
+
@table << ['a', 1]
|
180
|
+
@table << ['b', 2]
|
181
|
+
@table << ['c', 3]
|
182
|
+
@table.render.should == <<-EOF.deindent
|
183
|
+
+------+-----+
|
184
|
+
| Title |
|
185
|
+
+------+-----+
|
186
|
+
| Char | Num |
|
187
|
+
+------+-----+
|
188
|
+
| a | 1 |
|
189
|
+
| b | 2 |
|
190
|
+
| c | 3 |
|
191
|
+
+------+-----+
|
192
|
+
EOF
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should render properly without headings" do
|
196
|
+
@table << ['a', 1]
|
197
|
+
@table << ['b', 2]
|
198
|
+
@table << ['c', 3]
|
199
|
+
@table.render.should == <<-EOF.deindent
|
200
|
+
+---+---+
|
201
|
+
| a | 1 |
|
202
|
+
| b | 2 |
|
203
|
+
| c | 3 |
|
204
|
+
+---+---+
|
205
|
+
EOF
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should render separators" do
|
209
|
+
@table.headings = ['Char', 'Num']
|
210
|
+
@table << ['a', 1]
|
211
|
+
@table << ['b', 2]
|
212
|
+
@table.add_separator
|
213
|
+
@table << ['c', 3]
|
214
|
+
@table.render.should == <<-EOF.deindent
|
215
|
+
+------+-----+
|
216
|
+
| Char | Num |
|
217
|
+
+------+-----+
|
218
|
+
| a | 1 |
|
219
|
+
| b | 2 |
|
220
|
+
+------+-----+
|
221
|
+
| c | 3 |
|
222
|
+
+------+-----+
|
223
|
+
EOF
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should align columns with separators" do
|
227
|
+
@table.headings = ['Char', 'Num']
|
228
|
+
@table << ['a', 1]
|
229
|
+
@table << ['b', 2]
|
230
|
+
@table.add_separator
|
231
|
+
@table << ['c', 3]
|
232
|
+
@table.align_column 1, :right
|
233
|
+
@table.render.should == <<-EOF.deindent
|
234
|
+
+------+-----+
|
235
|
+
| Char | Num |
|
236
|
+
+------+-----+
|
237
|
+
| a | 1 |
|
238
|
+
| b | 2 |
|
239
|
+
+------+-----+
|
240
|
+
| c | 3 |
|
241
|
+
+------+-----+
|
242
|
+
EOF
|
243
|
+
end
|
244
|
+
|
245
|
+
|
246
|
+
it "should render properly using block syntax" do
|
247
|
+
table = Terminal::Table.new do |t|
|
248
|
+
t << ['a', 1]
|
249
|
+
t << ['b', 2]
|
250
|
+
t << ['c', 3]
|
251
|
+
end
|
252
|
+
table.render.should == <<-EOF.deindent
|
253
|
+
+---+---+
|
254
|
+
| a | 1 |
|
255
|
+
| b | 2 |
|
256
|
+
| c | 3 |
|
257
|
+
+---+---+
|
258
|
+
EOF
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should render properly using instance_eval block syntax" do
|
262
|
+
table = Terminal::Table.new do
|
263
|
+
add_row ['a', 1]
|
264
|
+
add_row ['b', 2]
|
265
|
+
add_row ['c', 3]
|
266
|
+
end
|
267
|
+
table.render.should == <<-EOF.deindent
|
268
|
+
+---+---+
|
269
|
+
| a | 1 |
|
270
|
+
| b | 2 |
|
271
|
+
| c | 3 |
|
272
|
+
+---+---+
|
273
|
+
EOF
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should allows a hash of options for creation" do
|
277
|
+
headings = ['Char', 'Num']
|
278
|
+
rows = [['a', 1], ['b', 2], ['c', 3]]
|
279
|
+
Terminal::Table.new(:rows => rows, :headings => headings).render.should == <<-EOF.deindent
|
280
|
+
+------+-----+
|
281
|
+
| Char | Num |
|
282
|
+
+------+-----+
|
283
|
+
| a | 1 |
|
284
|
+
| b | 2 |
|
285
|
+
| c | 3 |
|
286
|
+
+------+-----+
|
287
|
+
EOF
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should flex for large cells" do
|
291
|
+
@table.headings = ['Just some characters', 'Num']
|
292
|
+
@table.rows = [['a', 1], ['b', 2], ['c', 3]]
|
293
|
+
@table.render.should == <<-EOF.deindent
|
294
|
+
+----------------------+-----+
|
295
|
+
| Just some characters | Num |
|
296
|
+
+----------------------+-----+
|
297
|
+
| a | 1 |
|
298
|
+
| b | 2 |
|
299
|
+
| c | 3 |
|
300
|
+
+----------------------+-----+
|
301
|
+
EOF
|
302
|
+
end
|
303
|
+
|
304
|
+
it "should allow alignment of headings and cells" do
|
305
|
+
@table.headings = ['Characters', {:value => 'Nums', :alignment => :right} ]
|
306
|
+
@table << [{:value => 'a', :alignment => :center}, 1]
|
307
|
+
@table << ['b', 222222222222222]
|
308
|
+
@table << ['c', 3]
|
309
|
+
@table.render.should == <<-EOF.deindent
|
310
|
+
+------------+-----------------+
|
311
|
+
| Characters | Nums |
|
312
|
+
+------------+-----------------+
|
313
|
+
| a | 1 |
|
314
|
+
| b | 222222222222222 |
|
315
|
+
| c | 3 |
|
316
|
+
+------------+-----------------+
|
317
|
+
EOF
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should align columns, but allow specifics to remain" do
|
322
|
+
@table.headings = ['Just some characters', 'Num']
|
323
|
+
@table.rows = [[{:value => 'a', :alignment => :left}, 1], ['b', 2], ['c', 3]]
|
324
|
+
@table.align_column 0, :center
|
325
|
+
@table.align_column 1, :right
|
326
|
+
@table.render.should == <<-EOF.deindent
|
327
|
+
+----------------------+-----+
|
328
|
+
| Just some characters | Num |
|
329
|
+
+----------------------+-----+
|
330
|
+
| a | 1 |
|
331
|
+
| b | 2 |
|
332
|
+
| c | 3 |
|
333
|
+
+----------------------+-----+
|
334
|
+
EOF
|
335
|
+
end
|
336
|
+
|
337
|
+
describe "#==" do
|
338
|
+
it "should be equal to itself" do
|
339
|
+
t = Table.new
|
340
|
+
t.should == t
|
341
|
+
end
|
342
|
+
|
343
|
+
# it "should be equal with two empty tables" do
|
344
|
+
# table_one = Table.new
|
345
|
+
# table_two = Table.new
|
346
|
+
#
|
347
|
+
# table_one.should == table_two
|
348
|
+
# table_two.should == table_one
|
349
|
+
# end
|
350
|
+
|
351
|
+
it "should not be equal with different headings" do
|
352
|
+
table_one = Table.new
|
353
|
+
table_two = Table.new
|
354
|
+
|
355
|
+
table_one.headings << "a"
|
356
|
+
|
357
|
+
table_one.should_not == table_two
|
358
|
+
table_two.should_not == table_one
|
359
|
+
end
|
360
|
+
|
361
|
+
it "should not be equal with different rows" do
|
362
|
+
table_one = Table.new
|
363
|
+
table_two = Table.new
|
364
|
+
|
365
|
+
table_one.should_not == table_two
|
366
|
+
table_two.should_not == table_one
|
367
|
+
end
|
368
|
+
|
369
|
+
it "should not be equal if the other object does not respond_to? :headings" do
|
370
|
+
table_one = Table.new
|
371
|
+
table_two = Object.new
|
372
|
+
table_two.stub!(:rows).and_return([])
|
373
|
+
table_one.should_not == table_two
|
374
|
+
end
|
375
|
+
|
376
|
+
it "should not be equal if the other object does not respond_to? :rows" do
|
377
|
+
table_one = Table.new
|
378
|
+
table_two = Object.new
|
379
|
+
table_two.stub!(:rows).and_return([])
|
380
|
+
table_one.should_not == table_two
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
it "should handle colspan inside heading" do
|
385
|
+
@table.headings = ['one', { :value => 'two', :alignment => :center, :colspan => 2}]
|
386
|
+
@table.rows = [['a', 1, 2], ['b', 3, 4], ['c', 3, 4]]
|
387
|
+
@table.render.should == <<-EOF.deindent
|
388
|
+
+-----+---+---+
|
389
|
+
| one | two |
|
390
|
+
+-----+---+---+
|
391
|
+
| a | 1 | 2 |
|
392
|
+
| b | 3 | 4 |
|
393
|
+
| c | 3 | 4 |
|
394
|
+
+-----+---+---+
|
395
|
+
EOF
|
396
|
+
end
|
397
|
+
|
398
|
+
it "should handle colspan inside cells" do
|
399
|
+
@table.headings = ['one', 'two', 'three']
|
400
|
+
@table.rows = [['a', 1, 2], ['b', 3, 4], [{:value => "joined", :colspan => 2,:alignment => :center}, 'c']]
|
401
|
+
@table.render.should == <<-EOF.deindent
|
402
|
+
+-----+-----+-------+
|
403
|
+
| one | two | three |
|
404
|
+
+-----+-----+-------+
|
405
|
+
| a | 1 | 2 |
|
406
|
+
| b | 3 | 4 |
|
407
|
+
| joined | c |
|
408
|
+
+-----+-----+-------+
|
409
|
+
EOF
|
410
|
+
end
|
411
|
+
|
412
|
+
it "should handle colspan inside cells regardless of colspan position" do
|
413
|
+
@table.headings = ['one', 'two', 'three']
|
414
|
+
@table.rows = [['a', 1, 2], ['b', 3, 4], ['c', {:value => "joined", :colspan => 2,:alignment => :center}]]
|
415
|
+
@table.render.should == <<-EOF.deindent
|
416
|
+
+-----+-----+-------+
|
417
|
+
| one | two | three |
|
418
|
+
+-----+-----+-------+
|
419
|
+
| a | 1 | 2 |
|
420
|
+
| b | 3 | 4 |
|
421
|
+
| c | joined |
|
422
|
+
+-----+-----+-------+
|
423
|
+
EOF
|
424
|
+
end
|
425
|
+
|
426
|
+
it "should handle overflowing colspans" do
|
427
|
+
@table.headings = ['one', 'two', 'three']
|
428
|
+
@table.rows = [['a', 1, 2], ['b', 3, 4], ['c', {:value => "joined that is very very long", :colspan => 2,:alignment => :center}]]
|
429
|
+
@table.render.should == <<-EOF.deindent
|
430
|
+
+-----+---------------+---------------+
|
431
|
+
| one | two | three |
|
432
|
+
+-----+---------------+---------------+
|
433
|
+
| a | 1 | 2 |
|
434
|
+
| b | 3 | 4 |
|
435
|
+
| c | joined that is very very long |
|
436
|
+
+-----+---------------+---------------+
|
437
|
+
EOF
|
438
|
+
end
|
439
|
+
|
440
|
+
it "should only increase column size for multi-column if it is unavoidable" do
|
441
|
+
@table << [12345,2,3]
|
442
|
+
@table << [{:value => 123456789, :colspan => 2}, 4]
|
443
|
+
@table.render.should == <<-EOF.deindent
|
444
|
+
+-------+---+---+
|
445
|
+
| 12345 | 2 | 3 |
|
446
|
+
| 123456789 | 4 |
|
447
|
+
+-------+---+---+
|
448
|
+
EOF
|
449
|
+
end
|
450
|
+
|
451
|
+
|
452
|
+
it "should handle colspan 1" do
|
453
|
+
@table.headings = ['name', { :value => 'values', :colspan => 1}]
|
454
|
+
@table.rows = [['a', 1], ['b', 4], ['c', 7]]
|
455
|
+
@table.render.should == <<-EOF.deindent
|
456
|
+
+------+--------+
|
457
|
+
| name | values |
|
458
|
+
+------+--------+
|
459
|
+
| a | 1 |
|
460
|
+
| b | 4 |
|
461
|
+
| c | 7 |
|
462
|
+
+------+--------+
|
463
|
+
EOF
|
464
|
+
end
|
465
|
+
|
466
|
+
it "should handle big colspan" do
|
467
|
+
@table.headings = ['name', { :value => 'values', :alignment => :right, :colspan => 3}]
|
468
|
+
@table.headings = ['name', { :value => 'values', :colspan => 3}]
|
469
|
+
@table.rows = [['a', 1, 2, 3], ['b', 4, 5, 6], ['c', 7, 8, 9]]
|
470
|
+
|
471
|
+
@table.render.should == <<-EOF.deindent
|
472
|
+
+------+---+---+---+
|
473
|
+
| name | values |
|
474
|
+
+------+---+---+---+
|
475
|
+
| a | 1 | 2 | 3 |
|
476
|
+
| b | 4 | 5 | 6 |
|
477
|
+
| c | 7 | 8 | 9 |
|
478
|
+
+------+---+---+---+
|
479
|
+
EOF
|
480
|
+
end
|
481
|
+
|
482
|
+
it "should handle multiple colspan" do
|
483
|
+
@table.headings = [
|
484
|
+
'name',
|
485
|
+
{ :value => 'Values', :alignment => :right, :colspan => 2},
|
486
|
+
{ :value => 'Other values', :alignment => :right, :colspan => 2},
|
487
|
+
{ :value => 'Column 3', :alignment => :right, :colspan => 2}
|
488
|
+
]
|
489
|
+
|
490
|
+
3.times do |row_index|
|
491
|
+
row = ["row ##{row_index+1}"]
|
492
|
+
6.times do |i|
|
493
|
+
row << row_index*6 + i
|
494
|
+
end
|
495
|
+
@table.add_row(row)
|
496
|
+
end
|
497
|
+
|
498
|
+
@table.render.should == <<-EOF.deindent
|
499
|
+
+--------+----+----+-------+-------+-----+-----+
|
500
|
+
| name | Values | Other values | Column 3 |
|
501
|
+
+--------+----+----+-------+-------+-----+-----+
|
502
|
+
| row #1 | 0 | 1 | 2 | 3 | 4 | 5 |
|
503
|
+
| row #2 | 6 | 7 | 8 | 9 | 10 | 11 |
|
504
|
+
| row #3 | 12 | 13 | 14 | 15 | 16 | 17 |
|
505
|
+
+--------+----+----+-------+-------+-----+-----+
|
506
|
+
EOF
|
507
|
+
end
|
508
|
+
|
509
|
+
it "should render a table with only X cell borders" do
|
510
|
+
@table.style = {:border_x => "-", :border_y => "", :border_i => ""}
|
511
|
+
|
512
|
+
@table.headings = ['name', { :value => 'values', :alignment => :right, :colspan => 3}]
|
513
|
+
@table.headings = ['name', { :value => 'values', :colspan => 3}]
|
514
|
+
@table.rows = [['a', 1, 2, 3], ['b', 4, 5, 6], ['c', 7, 8, 9]]
|
515
|
+
|
516
|
+
@table.render.should == <<-EOF.strip
|
517
|
+
---------------
|
518
|
+
name values
|
519
|
+
---------------
|
520
|
+
a 1 2 3
|
521
|
+
b 4 5 6
|
522
|
+
c 7 8 9
|
523
|
+
---------------
|
524
|
+
EOF
|
525
|
+
end
|
526
|
+
|
527
|
+
it "should render a table without cell borders" do
|
528
|
+
@table.style = {:border_x => "", :border_y => "", :border_i => ""}
|
529
|
+
|
530
|
+
@table.headings = ['name', { :value => 'values', :alignment => :right, :colspan => 3}]
|
531
|
+
@table.headings = ['name', { :value => 'values', :colspan => 3}]
|
532
|
+
@table.rows = [['a', 1, 2, 3], ['b', 4, 5, 6], ['c', 7, 8, 9]]
|
533
|
+
|
534
|
+
@table.render.should == <<-EOF
|
535
|
+
|
536
|
+
name values
|
537
|
+
|
538
|
+
a 1 2 3
|
539
|
+
b 4 5 6
|
540
|
+
c 7 8 9
|
541
|
+
EOF
|
542
|
+
end
|
543
|
+
end
|
544
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
namespace :docs do
|
3
|
+
|
4
|
+
desc 'Remove rdoc products'
|
5
|
+
task :remove => [:clobber_docs]
|
6
|
+
|
7
|
+
desc 'Build docs, and open in browser for viewing (specify BROWSER)'
|
8
|
+
task :open => [:docs] do
|
9
|
+
browser = ENV["BROWSER"] || "safari"
|
10
|
+
sh "open -a #{browser} doc/index.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc "Run all specifications"
|
5
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
6
|
+
t.libs << "lib"
|
7
|
+
t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :spec do
|
11
|
+
|
12
|
+
desc "Run all specifications verbosely"
|
13
|
+
Spec::Rake::SpecTask.new(:verbose) do |t|
|
14
|
+
t.libs << "lib"
|
15
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run specific specification verbosely (specify SPEC)"
|
19
|
+
Spec::Rake::SpecTask.new(:select) do |t|
|
20
|
+
t.libs << "lib"
|
21
|
+
t.spec_files = [ENV["SPEC"]]
|
22
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{terminal-table}
|
5
|
+
s.version = "1.4.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["TJ Holowaychuk", "Scott J. Goldman"]
|
9
|
+
s.date = %q{2011-10-13}
|
10
|
+
s.description = %q{Simple, feature rich ascii table generation library}
|
11
|
+
s.email = %q{tj@vision-media.ca}
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/terminal-table.rb", "lib/terminal-table/cell.rb", "lib/terminal-table/core_ext.rb", "lib/terminal-table/heading.rb", "lib/terminal-table/import.rb", "lib/terminal-table/table.rb", "lib/terminal-table/table_helper.rb", "lib/terminal-table/version.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
|
13
|
+
s.files = ["History.rdoc", "Manifest", "README.rdoc", "Rakefile", "Todo.rdoc", "examples/examples.rb", "lib/terminal-table.rb", "lib/terminal-table/cell.rb", "lib/terminal-table/core_ext.rb", "lib/terminal-table/heading.rb", "lib/terminal-table/import.rb", "lib/terminal-table/table.rb", "lib/terminal-table/table_helper.rb", "lib/terminal-table/version.rb", "spec/cell_spec.rb", "spec/core_ext_spec.rb", "spec/import_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/table_spec.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "terminal-table.gemspec"]
|
14
|
+
s.homepage = %q{http://github.com/visionmedia/terminal-table}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Terminal-table", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{terminal-table}
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
|
+
s.summary = %q{Simple, feature rich ascii table generation library}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|