Merge lp:~noskcaj/ubuntu/trusty/ruby-terminal-table/1.4.5 into lp:ubuntu/trusty/ruby-terminal-table
- Trusty (14.04)
- 1.4.5
- Merge into trusty
Proposed by
Jackson Doak
Status: | Needs review |
---|---|
Proposed branch: | lp:~noskcaj/ubuntu/trusty/ruby-terminal-table/1.4.5 |
Merge into: | lp:ubuntu/trusty/ruby-terminal-table |
Diff against target: |
1820 lines (+840/-561) 22 files modified
History.rdoc (+11/-1) README.rdoc (+215/-133) Todo.rdoc (+0/-1) debian/changelog (+11/-0) debian/compat (+1/-1) debian/control (+2/-3) debian/copyright (+2/-2) examples/examples.rb (+20/-7) lib/terminal-table.rb (+3/-7) lib/terminal-table/cell.rb (+57/-16) lib/terminal-table/core_ext.rb (+1/-21) lib/terminal-table/heading.rb (+0/-10) lib/terminal-table/row.rb (+48/-0) lib/terminal-table/separator.rb (+14/-0) lib/terminal-table/style.rb (+61/-0) lib/terminal-table/table.rb (+159/-230) lib/terminal-table/version.rb (+2/-2) metadata.yml (+49/-53) spec/cell_spec.rb (+38/-2) spec/spec_helper.rb (+1/-1) spec/table_spec.rb (+139/-65) terminal-table.gemspec (+6/-6) |
To merge this branch: | bzr merge lp:~noskcaj/ubuntu/trusty/ruby-terminal-table/1.4.5 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
Review via email: mp+198677@code.launchpad.net |
Commit message
Description of the change
New upstream release, update packaging
To post a comment you must log in.
Unmerged revisions
- 7. By Jackson Doak
-
Use DEP5 copyright format
- 6. By Jackson Doak
-
Bump standards-version to 3.9.5
- 5. By Jackson Doak
-
Bump debhelper to 9
- 4. By Jackson Doak
-
* debian/control:
- Drop DM-Upload-Allowed field - 3. By Jackson Doak
-
New upstream release.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'History.rdoc' |
2 | --- History.rdoc 2011-06-17 13:38:26 +0000 |
3 | +++ History.rdoc 2013-12-12 07:49:48 +0000 |
4 | @@ -1,9 +1,19 @@ |
5 | +1.4.5 / 2012-3-15 |
6 | +================== |
7 | + |
8 | + * Add color support. |
9 | + * Various bugfixes |
10 | + |
11 | +1.4.3 / 2011-10-13 |
12 | +================== |
13 | + |
14 | + * Optimize for faster table output. |
15 | |
16 | 1.4.2 / 2010-01-14 |
17 | ================== |
18 | |
19 | * Fixed some bugs with colspan |
20 | - |
21 | + |
22 | === 1.4.1 / 2009-12-18 |
23 | |
24 | * Fix column alignment with separators. |
25 | |
26 | === modified file 'README.rdoc' |
27 | --- README.rdoc 2011-06-17 13:38:26 +0000 |
28 | +++ README.rdoc 2013-12-12 07:49:48 +0000 |
29 | @@ -1,138 +1,220 @@ |
30 | - |
31 | = Terminal Table |
32 | |
33 | -Simple, feature rich ASCII table generator. |
34 | - |
35 | -== Installation: |
36 | - |
37 | - Install [Gemcutter](http://gemcutter.org) then execute: |
38 | - $ sudo gem install terminal-table |
39 | - |
40 | -== Features: |
41 | - |
42 | -* Fast |
43 | -* Simple |
44 | -* Optional headings |
45 | -* Alignment of columns, headings, or cells |
46 | -* Supports column span |
47 | -* Easy modification of table strings (+, -, |) |
48 | - |
49 | -== Examples: |
50 | - |
51 | - require 'rubygems' |
52 | - require 'terminal-table/import' |
53 | - |
54 | - puts table(['a', 'b'], [1, 2], [3, 4], :separator, [4, 6]) |
55 | - |
56 | - t = table ['a', 'b'] |
57 | - t << [1, 2] |
58 | - t << [3, 4] |
59 | - t.add_separator |
60 | - t << [4, 6] |
61 | - puts t |
62 | - |
63 | - user_table = table do |t| |
64 | - t.headings = 'First Name', 'Last Name', 'Email' |
65 | - t << ['TJ', 'Holowaychuk', 'tj@vision-media.ca'] |
66 | - t << ['Bob', 'Someone', 'bob@vision-media.ca'] |
67 | - t << ['Joe', 'Whatever', 'joe@vision-media.ca'] |
68 | - end |
69 | - puts user_table |
70 | - |
71 | - user_table = table do |
72 | - self.headings = 'First Name', 'Last Name', 'Email' |
73 | - add_row ['TJ', 'Holowaychuk', { :value => 'tj@vision-media.ca', :alignment => :right }] |
74 | - add_row ['Bob', 'Someone', 'bob@vision-media.ca'] |
75 | - add_row ['Joe', 'Whatever', 'joe@vision-media.ca'] |
76 | - align_column 1, :center |
77 | - end |
78 | - puts user_table |
79 | - |
80 | - puts |
81 | - user_table = table do |
82 | - self.headings = ['First Name', 'Last Name', {:value => 'Phones', :colspan => 2, :alignment => :center}] |
83 | - add_row ['Bob', 'Someone', '123', '456'] |
84 | - add_row ['TJ', 'Holowaychuk', {:value => "No phones", :colspan => 2, :alignment => :center}] |
85 | - add_row ['Joe', 'Whatever', '4324', '343242'] |
86 | - end |
87 | - puts user_table |
88 | - |
89 | - rows = [] |
90 | - rows << ['Lines', 100] |
91 | - rows << ['Comments', 20] |
92 | - rows << ['Ruby', 70] |
93 | - rows << ['JavaScript', 30] |
94 | - puts table([nil, 'Lines'], *rows) |
95 | - |
96 | - rows = [] |
97 | - rows << ['Lines', 100] |
98 | - rows << ['Comments', 20] |
99 | - rows << ['Ruby', 70] |
100 | - rows << ['JavaScript', 30] |
101 | - puts table(nil, *rows) |
102 | - |
103 | -== Results: |
104 | - |
105 | - +---+---+ |
106 | - | a | b | |
107 | - +---+---+ |
108 | - | 1 | 2 | |
109 | - | 3 | 4 | |
110 | - +---+---+ |
111 | - | 4 | 6 | |
112 | - +---+---+ |
113 | - |
114 | - |
115 | - +---+---+ |
116 | - | a | b | |
117 | - +---+---+ |
118 | - | 1 | 2 | |
119 | - | 3 | 4 | |
120 | - +---+---+ |
121 | - | 4 | 6 | |
122 | - +---+---+ |
123 | - |
124 | - +------------+-------------+---------------------+ |
125 | - | First Name | Last Name | Email | |
126 | - +------------+-------------+---------------------+ |
127 | - | TJ | Holowaychuk | tj@vision-media.ca | |
128 | - | Bob | Someone | bob@vision-media.ca | |
129 | - | Joe | Whatever | joe@vision-media.ca | |
130 | - +------------+-------------+---------------------+ |
131 | - |
132 | - +------------+-----------------------------+---------------------+ |
133 | - | First Name | Last Name | Email | |
134 | - +------------+-----------------------------+---------------------+ |
135 | - | TJ | Holowaychuk | tj@vision-media.ca | |
136 | - | Bob | Someone | bob@vision-media.ca | |
137 | - | Joe | Whatever | joe@vision-media.ca | |
138 | - +------------+-----------------------------+---------------------+ |
139 | - |
140 | - +------------+-------------+-----------+--------+ |
141 | - | First Name | Last Name | Phones | |
142 | - +------------+-------------+-----------+--------+ |
143 | - | Bob | Someone | 123 | 456 | |
144 | - | TJ | Holowaychuk | No phones | |
145 | - | Joe | Whatever | 4324 | 343242 | |
146 | - +------------+-------------+-----------+--------+ |
147 | - |
148 | - +------------+-------+ |
149 | - | | Lines | |
150 | - +------------+-------+ |
151 | - | Lines | 100 | |
152 | - | Comments | 20 | |
153 | - | Ruby | 70 | |
154 | - | JavaScript | 30 | |
155 | - +------------+-------+ |
156 | - |
157 | - +------------+-----+ |
158 | - | Lines | 100 | |
159 | - | Comments | 20 | |
160 | - | Ruby | 70 | |
161 | - | JavaScript | 30 | |
162 | - +------------+-----+ |
163 | - |
164 | -== License: |
165 | +== Description |
166 | + |
167 | +Terminal Table is a fast and simple, yet feature rich ASCII table generator written in Ruby. |
168 | + |
169 | +== Installation |
170 | + |
171 | +Install http://gemcutter.org and execute: |
172 | + |
173 | + $ gem install terminal-table |
174 | + |
175 | +== Usage |
176 | + |
177 | +=== Basics |
178 | + |
179 | +To use Terminal Table: |
180 | + |
181 | + require 'terminal-table' |
182 | + |
183 | +To generate a table, provide an array of arrays (which are interpreted as rows): |
184 | + |
185 | + rows = [] |
186 | + rows << ['One', 1] |
187 | + rows << ['Two', 2] |
188 | + rows << ['Three', 3] |
189 | + table = Terminal::Table.new :rows => rows |
190 | + |
191 | + # > puts table |
192 | + # |
193 | + # +-------+---+ |
194 | + # | One | 1 | |
195 | + # | Two | 2 | |
196 | + # | Three | 3 | |
197 | + # +-------+---+ |
198 | + |
199 | + |
200 | +The constructor can also be given a block which is either yielded the Table object or instance evaluated: |
201 | + |
202 | + table = Terminal::Table.new do |t| |
203 | + t.rows = rows |
204 | + end |
205 | + |
206 | + table = Terminal::Table.new do |
207 | + self.rows = rows |
208 | + end |
209 | + |
210 | +Adding rows one by one: |
211 | + |
212 | + table = Terminal::Table.new do |t| |
213 | + t << ['One', 1] |
214 | + t.add_row ['Two', 2] |
215 | + end |
216 | + |
217 | +To add separators between rows: |
218 | + |
219 | + table = Terminal::Table.new do |t| |
220 | + t << ['One', 1] |
221 | + t << :separator |
222 | + t.add_row ['Two', 2] |
223 | + t.add_separator |
224 | + t.add_row ['Three', 3] |
225 | + end |
226 | + |
227 | + # > puts table |
228 | + # |
229 | + # +-------+---+ |
230 | + # | One | 1 | |
231 | + # +-------+---+ |
232 | + # | Two | 2 | |
233 | + # +-------+---+ |
234 | + # | Three | 3 | |
235 | + # +-------+---+ |
236 | + |
237 | +Cells can handle multiline content: |
238 | + |
239 | + table = Terminal::Table.new do |t| |
240 | + t << ['One', 1] |
241 | + t << :separator |
242 | + t.add_row ["Two\nDouble", 2] |
243 | + t.add_separator |
244 | + t.add_row ['Three', 3] |
245 | + end |
246 | + |
247 | + # > puts table |
248 | + # |
249 | + # +--------+---+ |
250 | + # | One | 1 | |
251 | + # +--------+---+ |
252 | + # | Two | 2 | |
253 | + # | Double | | |
254 | + # +--------+---+ |
255 | + # | Three | 3 | |
256 | + # +--------+---+ |
257 | + |
258 | +=== Head |
259 | + |
260 | +To add a head to the table: |
261 | + |
262 | + table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows |
263 | + |
264 | + # > puts table |
265 | + # |
266 | + # +-------+--------+ |
267 | + # | Word | Number | |
268 | + # +-------+--------+ |
269 | + # | One | 1 | |
270 | + # | Two | 2 | |
271 | + # | Three | 3 | |
272 | + # +-------+--------+ |
273 | + |
274 | +=== Title |
275 | + |
276 | +To add a title to the table: |
277 | + |
278 | + table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows |
279 | + |
280 | + # > puts table |
281 | + # |
282 | + # +------------+--------+ |
283 | + # | Cheatsheet | |
284 | + # +------------+--------+ |
285 | + # | Word | Number | |
286 | + # +------------+--------+ |
287 | + # | One | 1 | |
288 | + # | Two | 2 | |
289 | + # | Three | 3 | |
290 | + # +------------+--------+ |
291 | + |
292 | +=== Alignment |
293 | + |
294 | +To align the second column to the right: |
295 | + |
296 | + table.align_column(1, :right) |
297 | + |
298 | + # > puts table |
299 | + # |
300 | + # +-------+--------+ |
301 | + # | Word | Number | |
302 | + # +-------+--------+ |
303 | + # | One | 1 | |
304 | + # | Two | 2 | |
305 | + # | Three | 3 | |
306 | + # +-------+--------+ |
307 | + |
308 | +To align an individual cell, you specify the cell value in a hash along the alignment: |
309 | + |
310 | + table << ["Four", {:value => 4.0, :alignment => :center}] |
311 | + |
312 | + # > puts table |
313 | + # |
314 | + # +-------+--------+ |
315 | + # | Word | Number | |
316 | + # +-------+--------+ |
317 | + # | One | 1 | |
318 | + # | Two | 2 | |
319 | + # | Three | 3 | |
320 | + # | Four | 4.0 | |
321 | + # +-------+--------+ |
322 | + |
323 | +=== Style |
324 | + |
325 | +To specifify style options: |
326 | + |
327 | + table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80} |
328 | + |
329 | + # > puts table |
330 | + # |
331 | + # +--------------------------------------+---------------------------------------+ |
332 | + # | Word | Number | |
333 | + # +--------------------------------------+---------------------------------------+ |
334 | + # | One | 1 | |
335 | + # | Two | 2 | |
336 | + # | Three | 3 | |
337 | + # +--------------------------------------+---------------------------------------+ |
338 | + |
339 | +And change styles on the fly: |
340 | + |
341 | + table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"} |
342 | + |
343 | + # > puts table |
344 | + # |
345 | + # x====================x=================x |
346 | + # | Cheatsheet | |
347 | + # x====================x=================x |
348 | + # | Word | Number | |
349 | + # x====================x=================x |
350 | + # | One | 1 | |
351 | + # | Two | 2 | |
352 | + # | Three | 3 | |
353 | + # x====================x=================x |
354 | + |
355 | +To change the default style options: |
356 | + |
357 | + Terminal::Style.defaults = {:width => 80} |
358 | + |
359 | +All Table objects created afterwards will inherit these defaults. |
360 | + |
361 | +=== Constructor options and setter methods |
362 | + |
363 | +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: |
364 | + |
365 | + table = Terminal::Table.new |
366 | + table.title = "Cheatsheet" |
367 | + table.headings = ['Word', 'Number'] |
368 | + table.rows = rows |
369 | + table.style = {:width => 40} |
370 | + |
371 | +== More examples |
372 | + |
373 | +For more examples, please see the examples/examples.rb file included in the source distribution. |
374 | + |
375 | +== Author |
376 | + |
377 | +TJ Holowaychuk <tj@vision-media.ca> |
378 | + |
379 | +== License |
380 | |
381 | (The MIT License) |
382 | |
383 | |
384 | === modified file 'Todo.rdoc' |
385 | --- Todo.rdoc 2011-06-17 13:38:26 +0000 |
386 | +++ Todo.rdoc 2013-12-12 07:49:48 +0000 |
387 | @@ -6,7 +6,6 @@ |
388 | == Minor: |
389 | |
390 | * Programmatically add separator rows |
391 | -* Arbitrary dimensions |
392 | * Add multi-column sorting |
393 | * Change; pre-create Cell and Heading objects to clean up Table a bit |
394 | |
395 | |
396 | === modified file 'debian/changelog' |
397 | --- debian/changelog 2011-06-17 13:38:26 +0000 |
398 | +++ debian/changelog 2013-12-12 07:49:48 +0000 |
399 | @@ -1,3 +1,14 @@ |
400 | +ruby-terminal-table (1.4.5-0ubuntu1) trusty; urgency=low |
401 | + |
402 | + * New upstream release. |
403 | + * debian/control: |
404 | + - Drop DM-Upload-Allowed field |
405 | + - Bump debhelper to 9 |
406 | + - Bump standards-version to 3.9.5 |
407 | + * Use DEP5 copyright format |
408 | + |
409 | + -- Jackson Doak <noskcaj@ubuntu.com> Thu, 12 Dec 2013 17:59:06 +1100 |
410 | + |
411 | ruby-terminal-table (1.4.2-0ubuntu3) oneiric; urgency=low |
412 | |
413 | * Updated Maintainer field |
414 | |
415 | === modified file 'debian/compat' |
416 | --- debian/compat 2011-06-17 13:38:26 +0000 |
417 | +++ debian/compat 2013-12-12 07:49:48 +0000 |
418 | @@ -1,1 +1,1 @@ |
419 | -7 |
420 | +9 |
421 | |
422 | === modified file 'debian/control' |
423 | --- debian/control 2011-06-17 13:38:26 +0000 |
424 | +++ debian/control 2013-12-12 07:49:48 +0000 |
425 | @@ -3,9 +3,8 @@ |
426 | Priority: optional |
427 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
428 | XSBC-Original-Maintainer: Brian Thomason <brian.thomason@canonical.com> |
429 | -DM-Upload-Allowed: yes |
430 | -Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.2.3) |
431 | -Standards-Version: 3.9.1 |
432 | +Build-Depends: debhelper (>= 9), gem2deb (>= 0.2.3) |
433 | +Standards-Version: 3.9.5 |
434 | Homepage: http://github.com/visionmedia/terminal-table |
435 | XS-Ruby-Versions: all |
436 | |
437 | |
438 | === modified file 'debian/copyright' |
439 | --- debian/copyright 2011-06-17 13:38:26 +0000 |
440 | +++ debian/copyright 2013-12-12 07:49:48 +0000 |
441 | @@ -1,6 +1,6 @@ |
442 | -Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=173 |
443 | +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ |
444 | Upstream-Name: terminal-table |
445 | -Source: http://rubygems.org/downloads/terminal-table-1.4.2.gem |
446 | +Source: http://rubygems.org/downloads/terminal-table-1.4.5.gem |
447 | |
448 | Files: * |
449 | Copyright: Copyright (c) 2008-2009 TJ Holowaychuk <tj@vision-media.ca> |
450 | |
451 | === modified file 'examples/examples.rb' |
452 | --- examples/examples.rb 2011-06-17 13:38:26 +0000 |
453 | +++ examples/examples.rb 2013-12-12 07:49:48 +0000 |
454 | @@ -1,4 +1,3 @@ |
455 | - |
456 | $:.unshift File.dirname(__FILE__) + '/../lib' |
457 | require 'terminal-table/import' |
458 | |
459 | @@ -7,6 +6,7 @@ |
460 | |
461 | puts |
462 | t = table ['a', 'b'] |
463 | +t.style = {:padding_left => 2, :width => 80} |
464 | t << [1, 2] |
465 | t << [3, 4] |
466 | t << :separator |
467 | @@ -14,11 +14,22 @@ |
468 | puts t |
469 | |
470 | puts |
471 | -user_table = table do |t| |
472 | - t.headings = 'First Name', 'Last Name', 'Email' |
473 | - t << %w( TJ Holowaychuk tj@vision-media.ca ) |
474 | - t << %w( Bob Someone bob@vision-media.ca ) |
475 | - t << %w( Joe Whatever bob@vision-media.ca ) |
476 | +user_table = table do |v| |
477 | + v.title = "Contact Information" |
478 | + v.headings = 'First Name', 'Last Name', 'Email' |
479 | + v << %w( TJ Holowaychuk tj@vision-media.ca ) |
480 | + v << %w( Bob Someone bob@vision-media.ca ) |
481 | + v << %w( Joe Whatever bob@vision-media.ca ) |
482 | +end |
483 | +puts user_table |
484 | + |
485 | +puts |
486 | +user_table = table do |v| |
487 | + v.style.width = 80 |
488 | + v.headings = 'First Name', 'Last Name', 'Email' |
489 | + v << %w( TJ Holowaychuk tj@vision-media.ca ) |
490 | + v << %w( Bob Someone bob@vision-media.ca ) |
491 | + v << %w( Joe Whatever bob@vision-media.ca ) |
492 | end |
493 | puts user_table |
494 | |
495 | @@ -38,7 +49,9 @@ |
496 | user_table = table do |
497 | self.headings = ['First Name', 'Last Name', {:value => 'Phones', :colspan => 2, :alignment => :center}] |
498 | add_row ['Bob', 'Someone', '123', '456'] |
499 | - add_row ['TJ', 'Holowaychuk', {:value => "No phones", :colspan => 2, :alignment => :center}] |
500 | + add_row :separator |
501 | + add_row ['TJ', 'Holowaychuk', {:value => "No phones\navaiable", :colspan => 2, :alignment => :center}] |
502 | + add_row :separator |
503 | add_row ['Joe', 'Whatever', '4324', '343242'] |
504 | end |
505 | puts user_table |
506 | |
507 | === modified file 'lib/terminal-table.rb' |
508 | --- lib/terminal-table.rb 2011-06-17 13:38:26 +0000 |
509 | +++ lib/terminal-table.rb 2013-12-12 07:49:48 +0000 |
510 | @@ -22,10 +22,6 @@ |
511 | #++ |
512 | |
513 | $:.unshift File.dirname(__FILE__) |
514 | - |
515 | -require 'terminal-table/version' |
516 | -require 'terminal-table/core_ext' |
517 | -require 'terminal-table/table' |
518 | -require 'terminal-table/cell' |
519 | -require 'terminal-table/heading' |
520 | -require 'terminal-table/table_helper' |
521 | +%w(version core_ext table cell row separator style table_helper).each do |file| |
522 | + require "terminal-table/#{file}" |
523 | +end |
524 | \ No newline at end of file |
525 | |
526 | === modified file 'lib/terminal-table/cell.rb' |
527 | --- lib/terminal-table/cell.rb 2011-06-17 13:38:26 +0000 |
528 | +++ lib/terminal-table/cell.rb 2013-12-12 07:49:48 +0000 |
529 | @@ -14,40 +14,81 @@ |
530 | attr_reader :value |
531 | |
532 | ## |
533 | - # Cell alignment. |
534 | - |
535 | - attr_reader :alignment |
536 | - |
537 | - ## |
538 | # Column span. |
539 | |
540 | attr_reader :colspan |
541 | |
542 | ## |
543 | - # Initialize with _width_ and _options_. |
544 | + # Initialize with _options_. |
545 | |
546 | - def initialize width, options = nil |
547 | - @width = width |
548 | + def initialize options = nil |
549 | @value, options = options, {} unless Hash === options |
550 | @value = options.fetch :value, value |
551 | - @alignment = options.fetch :alignment, :left |
552 | + @alignment = options.fetch :alignment, nil |
553 | @colspan = options.fetch :colspan, 1 |
554 | + @width = options.fetch :width, @value.to_s.size |
555 | + @index = options.fetch :index |
556 | + @table = options.fetch :table |
557 | + end |
558 | + |
559 | + def alignment? |
560 | + !@alignment.nil? |
561 | + end |
562 | + |
563 | + def alignment |
564 | + @alignment || :left |
565 | + end |
566 | + |
567 | + def alignment=(val) |
568 | + supported = %w(left center right) |
569 | + if supported.include?(val.to_s) |
570 | + @alignment = val |
571 | + else |
572 | + raise "Aligment must be one of: #{supported.join(' ')}" |
573 | + end |
574 | + end |
575 | + |
576 | + def lines |
577 | + @value.to_s.split(/\n/) |
578 | end |
579 | |
580 | ## |
581 | # Render the cell. |
582 | |
583 | - def render |
584 | - " #{value} ".align alignment, width + 2 |
585 | + def render(line = 0) |
586 | + left = " " * @table.style.padding_left |
587 | + right = " " * @table.style.padding_right |
588 | + render_width = lines[line].to_s.size - escape(lines[line]).size + width |
589 | + "#{left}#{lines[line]}#{right}".align(alignment, render_width + @table.cell_padding) |
590 | end |
591 | alias :to_s :render |
592 | |
593 | ## |
594 | - # Cell length. |
595 | - |
596 | - def length |
597 | - value.to_s.length + 2 |
598 | + # Returns the longest line in the cell and |
599 | + # removes all ANSI escape sequences (e.g. color) |
600 | + |
601 | + def value_for_column_width_recalc |
602 | + lines.map{ |s| escape(s) }.max_by{ |s| s.size } |
603 | + end |
604 | + |
605 | + ## |
606 | + # Returns the width of this cell |
607 | + |
608 | + def width |
609 | + padding = (colspan - 1) * @table.cell_spacing |
610 | + inner_width = (1..@colspan).to_a.inject(0) do |w, counter| |
611 | + w + @table.column_width(@index + counter - 1) |
612 | + end |
613 | + inner_width + padding |
614 | + end |
615 | + |
616 | + ## |
617 | + # removes all ANSI escape sequences (e.g. color) |
618 | + def escape(line) |
619 | + line.to_s.gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, ''). |
620 | + gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, ''). |
621 | + gsub(/[\x03|\x1a]/, '') |
622 | end |
623 | end |
624 | end |
625 | -end |
626 | \ No newline at end of file |
627 | +end |
628 | |
629 | === modified file 'lib/terminal-table/core_ext.rb' |
630 | --- lib/terminal-table/core_ext.rb 2011-06-17 13:38:26 +0000 |
631 | +++ lib/terminal-table/core_ext.rb 2013-12-12 07:49:48 +0000 |
632 | @@ -1,28 +1,8 @@ |
633 | |
634 | class String |
635 | def align position, length |
636 | - send position, length |
637 | + self.__send__ position, length |
638 | end |
639 | alias_method :left, :ljust |
640 | alias_method :right, :rjust |
641 | -end |
642 | - |
643 | -module Enumerable |
644 | - def map_with_index &block |
645 | - vals = [] |
646 | - each_with_index { |v, i| vals << yield(v, i) } |
647 | - vals |
648 | - end |
649 | - alias :collect_with_index :map_with_index |
650 | -end |
651 | - |
652 | -class Object |
653 | - def yield_or_eval &block |
654 | - return unless block |
655 | - if block.arity > 0 |
656 | - yield self |
657 | - else |
658 | - self.instance_eval &block |
659 | - end |
660 | - end |
661 | end |
662 | \ No newline at end of file |
663 | |
664 | === removed file 'lib/terminal-table/heading.rb' |
665 | --- lib/terminal-table/heading.rb 2011-06-17 13:38:26 +0000 |
666 | +++ lib/terminal-table/heading.rb 1970-01-01 00:00:00 +0000 |
667 | @@ -1,10 +0,0 @@ |
668 | - |
669 | -module Terminal |
670 | - class Table |
671 | - class Heading < Cell |
672 | - def initialize width, params |
673 | - super |
674 | - end |
675 | - end |
676 | - end |
677 | -end |
678 | \ No newline at end of file |
679 | |
680 | === added file 'lib/terminal-table/row.rb' |
681 | --- lib/terminal-table/row.rb 1970-01-01 00:00:00 +0000 |
682 | +++ lib/terminal-table/row.rb 2013-12-12 07:49:48 +0000 |
683 | @@ -0,0 +1,48 @@ |
684 | +module Terminal |
685 | + class Table |
686 | + class Row |
687 | + |
688 | + ## |
689 | + # Row cells |
690 | + |
691 | + attr_reader :cells |
692 | + |
693 | + attr_reader :table |
694 | + |
695 | + ## |
696 | + # Initialize with _width_ and _options_. |
697 | + |
698 | + def initialize table, array = [] |
699 | + @cell_index = 0 |
700 | + @table = table |
701 | + @cells = [] |
702 | + array.each { |item| self << item } |
703 | + end |
704 | + |
705 | + def add_cell item |
706 | + options = item.is_a?(Hash) ? item : {:value => item} |
707 | + cell = Cell.new(options.merge(:index => @cell_index, :table => @table)) |
708 | + @cell_index += cell.colspan |
709 | + @cells << cell |
710 | + end |
711 | + alias << add_cell |
712 | + |
713 | + def [] index |
714 | + cells[index] |
715 | + end |
716 | + |
717 | + def height |
718 | + cells.map { |c| c.lines.count }.max |
719 | + end |
720 | + |
721 | + def render |
722 | + y = @table.style.border_y |
723 | + (0...height).to_a.map do |line| |
724 | + y + cells.map do |cell| |
725 | + cell.render(line) |
726 | + end.join(y) + y |
727 | + end.join("\n") |
728 | + end |
729 | + end |
730 | + end |
731 | +end |
732 | \ No newline at end of file |
733 | |
734 | === added file 'lib/terminal-table/separator.rb' |
735 | --- lib/terminal-table/separator.rb 1970-01-01 00:00:00 +0000 |
736 | +++ lib/terminal-table/separator.rb 2013-12-12 07:49:48 +0000 |
737 | @@ -0,0 +1,14 @@ |
738 | +module Terminal |
739 | + class Table |
740 | + class Separator < Row |
741 | + |
742 | + def render |
743 | + arr_x = (0...@table.number_of_columns).to_a.map do |i| |
744 | + @table.style.border_x * (@table.column_width(i) + @table.cell_padding) |
745 | + end |
746 | + border_i = @table.style.border_i |
747 | + border_i + arr_x.join(border_i) + border_i |
748 | + end |
749 | + end |
750 | + end |
751 | +end |
752 | \ No newline at end of file |
753 | |
754 | === added file 'lib/terminal-table/style.rb' |
755 | --- lib/terminal-table/style.rb 1970-01-01 00:00:00 +0000 |
756 | +++ lib/terminal-table/style.rb 2013-12-12 07:49:48 +0000 |
757 | @@ -0,0 +1,61 @@ |
758 | + |
759 | +module Terminal |
760 | + class Table |
761 | + # A Style object holds all the formatting information for a Table object |
762 | + # |
763 | + # To create a table with a certain style, use either the constructor |
764 | + # option <tt>:style</tt>, the Table#style object or the Table#style= method |
765 | + # |
766 | + # All these examples have the same effect: |
767 | + # |
768 | + # # by constructor |
769 | + # @table = Table.new(:style => {:padding_left => 2, :width => 40}) |
770 | + # |
771 | + # # by object |
772 | + # @table.style.padding_left = 2 |
773 | + # @table.style.width = 40 |
774 | + # |
775 | + # # by method |
776 | + # @table.style = {:padding_left => 2, :width => 40} |
777 | + # |
778 | + # To set a default style for all tables created afterwards use Style.defaults= |
779 | + # |
780 | + # Terminal::Table::Style.defaults = {:width => 80} |
781 | + # |
782 | + class Style |
783 | + @@defaults = { |
784 | + :border_x => "-", :border_y => "|", :border_i => "+", |
785 | + :padding_left => 1, :padding_right => 1, |
786 | + :width => nil |
787 | + } |
788 | + |
789 | + attr_accessor :border_x |
790 | + attr_accessor :border_y |
791 | + attr_accessor :border_i |
792 | + |
793 | + attr_accessor :padding_left |
794 | + attr_accessor :padding_right |
795 | + |
796 | + attr_accessor :width |
797 | + |
798 | + |
799 | + def initialize options = {} |
800 | + apply self.class.defaults.merge(options) |
801 | + end |
802 | + |
803 | + def apply options |
804 | + options.each { |m, v| __send__ "#{m}=", v } |
805 | + end |
806 | + |
807 | + class << self |
808 | + def defaults |
809 | + @@defaults |
810 | + end |
811 | + |
812 | + def defaults= options |
813 | + @@defaults = defaults.merge(options) |
814 | + end |
815 | + end |
816 | + end |
817 | + end |
818 | +end |
819 | \ No newline at end of file |
820 | |
821 | === modified file 'lib/terminal-table/table.rb' (properties changed: +x to -x) |
822 | --- lib/terminal-table/table.rb 2011-06-17 13:38:26 +0000 |
823 | +++ lib/terminal-table/table.rb 2013-12-12 07:49:48 +0000 |
824 | @@ -2,114 +2,39 @@ |
825 | module Terminal |
826 | class Table |
827 | |
828 | - #-- |
829 | - # Exceptions |
830 | - #++ |
831 | - |
832 | - Error = Class.new StandardError |
833 | - |
834 | - ## |
835 | - # Table characters, x axis, y axis, and intersection. |
836 | - |
837 | - X, Y, I = '-', '|', '+' |
838 | - |
839 | - ## |
840 | - # Headings array. |
841 | - |
842 | - attr_accessor :headings |
843 | - |
844 | - ## |
845 | - # Rows array. |
846 | - |
847 | - attr_accessor :rows |
848 | + attr_reader :title |
849 | + attr_reader :headings |
850 | |
851 | ## |
852 | # Generates a ASCII table with the given _options_. |
853 | |
854 | def initialize options = {}, &block |
855 | - @headings = options.fetch :headings, [] |
856 | - @rows = options.fetch :rows, [] |
857 | - yield_or_eval &block if block |
858 | - end |
859 | - |
860 | - ## |
861 | - # Render the table. |
862 | - |
863 | - def render |
864 | - buffer = [separator, "\n"] |
865 | - if has_headings? |
866 | - buffer << render_headings |
867 | - buffer << "\n" << separator << "\n" |
868 | - end |
869 | - buffer << @rows.map do |row| |
870 | - render_row(row) |
871 | - end.join("\n") |
872 | - buffer << "\n" << separator << "\n" |
873 | - buffer.join |
874 | - end |
875 | - alias :to_s :render |
876 | - |
877 | - ## |
878 | - # Render headings. |
879 | - |
880 | - def render_headings |
881 | - Y + headings.map_with_index do |heading, i| |
882 | - width = 0 |
883 | - if heading.is_a?(Hash) and !heading[:colspan].nil? |
884 | - i.upto(i + heading[:colspan] - 1) do |col| |
885 | - width += length_of_column(col) |
886 | - end |
887 | - width += (heading[:colspan] - 1) * (Y.length + 2) |
888 | - else |
889 | - width = length_of_column(i) |
890 | - end |
891 | - Heading.new( width, heading).render |
892 | - end.join(Y) + Y |
893 | - end |
894 | - |
895 | - ## |
896 | - # Render the given _row_. |
897 | - |
898 | - def render_row row |
899 | - if row == :separator |
900 | - separator |
901 | - else |
902 | - Y + row.map_with_index do |cell, i| |
903 | - render_cell(cell, row_to_index(row, i)) |
904 | - end.join(Y) + Y |
905 | - end |
906 | - end |
907 | - |
908 | - ## |
909 | - # Render the given _cell_ at index _i_. |
910 | - |
911 | - def render_cell cell, i |
912 | - width = 0 |
913 | - if cell.is_a?(Hash) and !cell[:colspan].nil? |
914 | - i.upto(i + cell[:colspan] - 1) do |col| |
915 | - width += length_of_column(col) |
916 | - end |
917 | - width += (cell[:colspan] - 1) * (Y.length + 2) |
918 | - else |
919 | - width = length_of_column(i) |
920 | - end |
921 | - Cell.new(width, cell).render |
922 | - end |
923 | - |
924 | - ## |
925 | - # Create a separator based on colum lengths. |
926 | - |
927 | - def separator |
928 | - I + columns.collect_with_index do |col, i| |
929 | - X * (length_of_column(i) + 2) |
930 | - end.join(I) + I |
931 | + @column_widths = [] |
932 | + self.style = options.fetch :style, {} |
933 | + self.headings = options.fetch :headings, [] |
934 | + self.rows = options.fetch :rows, [] |
935 | + self.title = options.fetch :title, nil |
936 | + yield_or_eval(&block) if block |
937 | + end |
938 | + |
939 | + ## |
940 | + # Align column _n_ to the given _alignment_ of :center, :left, or :right. |
941 | + |
942 | + def align_column n, alignment |
943 | + r = rows |
944 | + column(n).each_with_index do |col, i| |
945 | + cell = r[i][n] |
946 | + cell.alignment = alignment unless cell.alignment? |
947 | + end |
948 | end |
949 | |
950 | ## |
951 | # Add a row. |
952 | |
953 | - def add_row row |
954 | + def add_row array |
955 | + row = array == :separator ? Separator.new(self) : Row.new(self, array) |
956 | @rows << row |
957 | + recalc_column_widths row |
958 | end |
959 | alias :<< :add_row |
960 | |
961 | @@ -117,175 +42,179 @@ |
962 | # Add a separator. |
963 | |
964 | def add_separator |
965 | - @rows << :separator |
966 | - end |
967 | - |
968 | - ## |
969 | - # Weither or not any headings are present, since they are optional. |
970 | - |
971 | - def has_headings? |
972 | - not headings.empty? |
973 | + self << :separator |
974 | + end |
975 | + |
976 | + def cell_spacing |
977 | + cell_padding + style.border_y.length |
978 | + end |
979 | + |
980 | + def cell_padding |
981 | + style.padding_left + style.padding_right |
982 | end |
983 | |
984 | ## |
985 | # Return column _n_. |
986 | |
987 | - def column n |
988 | - rows.map { |row| row[n] }.compact |
989 | + def column n, method = :value, array = rows |
990 | + array.map { |row| |
991 | + cell = row[n] |
992 | + cell && method ? cell.__send__(method) : cell |
993 | + }.compact |
994 | end |
995 | |
996 | ## |
997 | # Return _n_ column including headings. |
998 | |
999 | - def column_with_headings n |
1000 | - headings_with_rows.map { |row| row_with_hash(row)[n] }.compact |
1001 | - end |
1002 | - |
1003 | - def row_with_hash row |
1004 | - # this method duplicates the multi-column columns in each column they are in |
1005 | - index = 0 |
1006 | - row.inject [] do |columns, column| |
1007 | - if column.is_a?(Hash) && column[:colspan] && column[:colspan] > 1 |
1008 | - column[:start_index] = index |
1009 | - column[:colspan].times do |
1010 | - columns << column |
1011 | - index += 1 |
1012 | - end |
1013 | - else |
1014 | - columns << column |
1015 | - index += 1 |
1016 | - end |
1017 | - columns |
1018 | - end |
1019 | - end |
1020 | - |
1021 | - def row_to_index row, index |
1022 | - new_index = -1 |
1023 | - 0.upto(index) do |i| |
1024 | - column = row[i] |
1025 | - if column.is_a?(Hash) && column[:colspan] && column[:colspan] > 1 && index != i |
1026 | - new_index = new_index + column[:colspan] |
1027 | - else |
1028 | - new_index += 1 |
1029 | - end |
1030 | - end |
1031 | - return new_index |
1032 | + def column_with_headings n, method = :value |
1033 | + column n, method, headings_with_rows |
1034 | end |
1035 | |
1036 | ## |
1037 | # Return columns. |
1038 | |
1039 | - def columns |
1040 | + def columns |
1041 | (0...number_of_columns).map { |n| column n } |
1042 | end |
1043 | |
1044 | ## |
1045 | - # Return the length of the largest cell found within column _n_. |
1046 | - |
1047 | - def length_of_largest_cell_in_column n |
1048 | - column_with_headings(n).map do |cell| |
1049 | - if cell.is_a? Hash |
1050 | - if cell[:colspan] && cell[:colspan] > 1 |
1051 | - if (cell[:value].to_s.length <= length_of_single_columns_where_multicolumn_is(cell[:start_index],cell[:colspan])) |
1052 | - 0 |
1053 | - else |
1054 | - spacing_length = (3 * (cell[:colspan] - 1)) |
1055 | - length_in_columns = (cell[:value].to_s.length - spacing_length) |
1056 | - (length_in_columns.to_f / cell[:colspan]).ceil |
1057 | - end |
1058 | - else |
1059 | - cell[:value].to_s.length |
1060 | - end |
1061 | - else |
1062 | - cell.to_s.length |
1063 | - end |
1064 | - end.sort.last |
1065 | - end |
1066 | - |
1067 | - ## |
1068 | - # Returns the length of the largest single column cell found within column _n_. |
1069 | - |
1070 | - def length_of_largest_single_column_cell_in_column n |
1071 | - column_with_headings(n).map do |cell| |
1072 | - if cell.is_a? Hash |
1073 | - if cell[:colspan] && cell[:colspan] > 1 |
1074 | - 0 |
1075 | - else |
1076 | - cell[:value].to_s.length |
1077 | - end |
1078 | - else |
1079 | - cell.to_s.length |
1080 | - end |
1081 | - end.sort.last |
1082 | - end |
1083 | - |
1084 | - ## |
1085 | - # Returns the length of the single columns starting from _n_ and going through _length_ columns. |
1086 | - |
1087 | - def length_of_single_columns_where_multicolumn_is(n,length) |
1088 | - total_length = 0 |
1089 | - spacing_length = (3 * (length - 1)) |
1090 | - total_length = total_length + spacing_length |
1091 | - n.upto(n + length - 1) do |i| |
1092 | - total_length = total_length + length_of_largest_single_column_cell_in_column(i) |
1093 | - end |
1094 | - return total_length |
1095 | - end |
1096 | - |
1097 | - ## |
1098 | # Return length of column _n_. |
1099 | |
1100 | - def length_of_column n |
1101 | - length_of_largest_cell_in_column n |
1102 | + def column_width n |
1103 | + width = @column_widths[n] || 0 |
1104 | + width + additional_column_widths[n].to_i |
1105 | end |
1106 | + alias length_of_column column_width # for legacy support |
1107 | |
1108 | ## |
1109 | # Return total number of columns available. |
1110 | |
1111 | def number_of_columns |
1112 | - return rows.first.length unless rows.empty? |
1113 | - raise Error, 'your table needs some rows' |
1114 | - end |
1115 | - |
1116 | - ## |
1117 | - # Align column _n_ to the given _alignment_ of :center, :left, or :right. |
1118 | - |
1119 | - def align_column n, alignment |
1120 | - r = rows |
1121 | - column(n).each_with_index do |col, i| |
1122 | - r[i][n] = { :value => col, :alignment => alignment } unless Hash === col |
1123 | - end |
1124 | - end |
1125 | - |
1126 | - ## |
1127 | - # Return headings combined with rows. |
1128 | - |
1129 | - def headings_with_rows |
1130 | - [headings] + rows |
1131 | - end |
1132 | - |
1133 | + headings_with_rows.map { |r| r.cells.size }.max |
1134 | + end |
1135 | + |
1136 | + ## |
1137 | + # Set the headings |
1138 | + |
1139 | + def headings= array |
1140 | + @headings = Row.new(self, array) |
1141 | + recalc_column_widths @headings |
1142 | + end |
1143 | + |
1144 | + ## |
1145 | + # Render the table. |
1146 | + |
1147 | + def render |
1148 | + separator = Separator.new(self) |
1149 | + buffer = [separator] |
1150 | + unless @title.nil? |
1151 | + buffer << Row.new(self, [title_cell_options]) |
1152 | + buffer << separator |
1153 | + end |
1154 | + unless @headings.cells.empty? |
1155 | + buffer << @headings |
1156 | + buffer << separator |
1157 | + end |
1158 | + buffer += @rows |
1159 | + buffer << separator |
1160 | + buffer.map { |r| r.render }.join("\n") |
1161 | + end |
1162 | + alias :to_s :render |
1163 | + |
1164 | ## |
1165 | # Return rows without separator rows. |
1166 | |
1167 | def rows |
1168 | - @rows.reject { |row| row == :separator } |
1169 | - end |
1170 | - |
1171 | - ## |
1172 | - # Return rows including separator rows. |
1173 | - |
1174 | - def all_rows |
1175 | - @rows |
1176 | - end |
1177 | - |
1178 | + @rows.reject { |row| row.is_a? Separator } |
1179 | + end |
1180 | + |
1181 | + def rows= array |
1182 | + @rows = [] |
1183 | + array.each { |arr| self << arr } |
1184 | + end |
1185 | + |
1186 | + def style=(options) |
1187 | + style.apply options |
1188 | + end |
1189 | + |
1190 | + def style |
1191 | + @style ||= Style.new |
1192 | + end |
1193 | + |
1194 | + def title=(title) |
1195 | + @title = title |
1196 | + recalc_column_widths Row.new(self, [title_cell_options]) |
1197 | + end |
1198 | + |
1199 | ## |
1200 | # Check if _other_ is equal to self. _other_ is considered equal |
1201 | # if it contains the same headings and rows. |
1202 | |
1203 | def == other |
1204 | - if other.respond_to? :headings and other.respond_to? :rows |
1205 | - headings == other.headings and rows == other.rows |
1206 | - end |
1207 | + if other.respond_to? :render and other.respond_to? :rows |
1208 | + self.headings == other.headings and self.rows == other.rows |
1209 | + end |
1210 | + end |
1211 | + |
1212 | + private |
1213 | + |
1214 | + def columns_width |
1215 | + @column_widths.inject(0) { |s, i| s + i + cell_spacing } + style.border_y.length |
1216 | + end |
1217 | + |
1218 | + def additional_column_widths |
1219 | + return [] if style.width.nil? |
1220 | + spacing = style.width - columns_width |
1221 | + if spacing < 0 |
1222 | + raise "Table width exceeds wanted width of #{wanted} characters." |
1223 | + else |
1224 | + per_col = spacing / number_of_columns |
1225 | + arr = (1...number_of_columns).to_a.map { |i| per_col } |
1226 | + other_cols = arr.inject(0) { |s, i| s + i } |
1227 | + arr << spacing - other_cols |
1228 | + arr |
1229 | + end |
1230 | + end |
1231 | + |
1232 | + def recalc_column_widths row |
1233 | + return if row.is_a? Separator |
1234 | + i = 0 |
1235 | + row.cells.each do |cell| |
1236 | + colspan = cell.colspan |
1237 | + cell_value = cell.value_for_column_width_recalc |
1238 | + colspan.downto(1) do |j| |
1239 | + cell_length = cell_value.to_s.length |
1240 | + if colspan > 1 |
1241 | + spacing_length = cell_spacing * (colspan - 1) |
1242 | + length_in_columns = (cell_length - spacing_length) |
1243 | + cell_length = (length_in_columns.to_f / colspan).ceil |
1244 | + end |
1245 | + if @column_widths[i].to_i < cell_length |
1246 | + @column_widths[i] = cell_length |
1247 | + end |
1248 | + i = i + 1 |
1249 | + end |
1250 | + end |
1251 | + end |
1252 | + |
1253 | + ## |
1254 | + # Return headings combined with rows. |
1255 | + |
1256 | + def headings_with_rows |
1257 | + [@headings] + rows |
1258 | + end |
1259 | + |
1260 | + def yield_or_eval &block |
1261 | + return unless block |
1262 | + if block.arity > 0 |
1263 | + yield self |
1264 | + else |
1265 | + self.instance_eval(&block) |
1266 | + end |
1267 | + end |
1268 | + |
1269 | + def title_cell_options |
1270 | + {:value => @title, :alignment => :center, :colspan => number_of_columns} |
1271 | end |
1272 | end |
1273 | end |
1274 | |
1275 | === modified file 'lib/terminal-table/version.rb' |
1276 | --- lib/terminal-table/version.rb 2011-06-17 13:38:26 +0000 |
1277 | +++ lib/terminal-table/version.rb 2013-12-12 07:49:48 +0000 |
1278 | @@ -1,6 +1,6 @@ |
1279 | |
1280 | module Terminal |
1281 | class Table |
1282 | - VERSION = '1.4.2' |
1283 | + VERSION = '1.4.5' |
1284 | end |
1285 | -end |
1286 | \ No newline at end of file |
1287 | +end |
1288 | |
1289 | === modified file 'metadata.yml' |
1290 | --- metadata.yml 2011-06-17 13:38:26 +0000 |
1291 | +++ metadata.yml 2013-12-12 07:49:48 +0000 |
1292 | @@ -1,37 +1,34 @@ |
1293 | --- !ruby/object:Gem::Specification |
1294 | +rubygems_version: 0.9.4 |
1295 | +specification_version: 1 |
1296 | name: terminal-table |
1297 | version: !ruby/object:Gem::Version |
1298 | - version: 1.4.2 |
1299 | + version: 1.4.5 |
1300 | +date: 2012-03-15 00:00:00 +00:00 |
1301 | +summary: Simple, feature rich ascii table generation library |
1302 | +require_paths: |
1303 | +- lib |
1304 | +email: tj@vision-media.ca |
1305 | +homepage: http://github.com/visionmedia/terminal-table |
1306 | +rubyforge_project: terminal-table |
1307 | +description: Simple, feature rich ascii table generation library |
1308 | +autorequire: |
1309 | +default_executable: |
1310 | +bindir: bin |
1311 | +has_rdoc: false |
1312 | +required_ruby_version: !ruby/object:Gem::Version::Requirement |
1313 | + requirements: |
1314 | + - - ">" |
1315 | + - !ruby/object:Gem::Version |
1316 | + version: 0.0.0 |
1317 | + version: |
1318 | platform: ruby |
1319 | +signing_key: |
1320 | +cert_chain: |
1321 | +post_install_message: |
1322 | authors: |
1323 | - TJ Holowaychuk |
1324 | -autorequire: |
1325 | -bindir: bin |
1326 | -cert_chain: [] |
1327 | - |
1328 | -date: 2010-01-14 00:00:00 -08:00 |
1329 | -default_executable: |
1330 | -dependencies: [] |
1331 | - |
1332 | -description: Simple, feature rich ascii table generation library |
1333 | -email: tj@vision-media.ca |
1334 | -executables: [] |
1335 | - |
1336 | -extensions: [] |
1337 | - |
1338 | -extra_rdoc_files: |
1339 | -- README.rdoc |
1340 | -- lib/terminal-table.rb |
1341 | -- lib/terminal-table/cell.rb |
1342 | -- lib/terminal-table/core_ext.rb |
1343 | -- lib/terminal-table/heading.rb |
1344 | -- lib/terminal-table/import.rb |
1345 | -- lib/terminal-table/table.rb |
1346 | -- lib/terminal-table/table_helper.rb |
1347 | -- lib/terminal-table/version.rb |
1348 | -- tasks/docs.rake |
1349 | -- tasks/gemspec.rake |
1350 | -- tasks/spec.rake |
1351 | +- Scott J. Goldman |
1352 | files: |
1353 | - History.rdoc |
1354 | - Manifest |
1355 | @@ -42,11 +39,13 @@ |
1356 | - lib/terminal-table.rb |
1357 | - lib/terminal-table/cell.rb |
1358 | - lib/terminal-table/core_ext.rb |
1359 | -- lib/terminal-table/heading.rb |
1360 | - lib/terminal-table/import.rb |
1361 | - lib/terminal-table/table.rb |
1362 | - lib/terminal-table/table_helper.rb |
1363 | - lib/terminal-table/version.rb |
1364 | +- lib/terminal-table/row.rb |
1365 | +- lib/terminal-table/separator.rb |
1366 | +- lib/terminal-table/style.rb |
1367 | - spec/cell_spec.rb |
1368 | - spec/core_ext_spec.rb |
1369 | - spec/import_spec.rb |
1370 | @@ -57,11 +56,8 @@ |
1371 | - tasks/gemspec.rake |
1372 | - tasks/spec.rake |
1373 | - terminal-table.gemspec |
1374 | -has_rdoc: true |
1375 | -homepage: http://github.com/visionmedia/terminal-table |
1376 | -licenses: [] |
1377 | +test_files: [] |
1378 | |
1379 | -post_install_message: |
1380 | rdoc_options: |
1381 | - --line-numbers |
1382 | - --inline-source |
1383 | @@ -69,26 +65,26 @@ |
1384 | - Terminal-table |
1385 | - --main |
1386 | - README.rdoc |
1387 | -require_paths: |
1388 | -- lib |
1389 | -required_ruby_version: !ruby/object:Gem::Requirement |
1390 | - requirements: |
1391 | - - - ">=" |
1392 | - - !ruby/object:Gem::Version |
1393 | - version: "0" |
1394 | - version: |
1395 | -required_rubygems_version: !ruby/object:Gem::Requirement |
1396 | - requirements: |
1397 | - - - ">=" |
1398 | - - !ruby/object:Gem::Version |
1399 | - version: "1.2" |
1400 | - version: |
1401 | +extra_rdoc_files: |
1402 | +- README.rdoc |
1403 | +- lib/terminal-table.rb |
1404 | +- lib/terminal-table/cell.rb |
1405 | +- lib/terminal-table/core_ext.rb |
1406 | +- lib/terminal-table/import.rb |
1407 | +- lib/terminal-table/table.rb |
1408 | +- lib/terminal-table/version.rb |
1409 | +- lib/terminal-table/row.rb |
1410 | +- lib/terminal-table/separator.rb |
1411 | +- lib/terminal-table/style.rb |
1412 | +- lib/terminal-table/table_helper.rb |
1413 | +- tasks/docs.rake |
1414 | +- tasks/gemspec.rake |
1415 | +- tasks/spec.rake |
1416 | +executables: [] |
1417 | + |
1418 | +extensions: [] |
1419 | + |
1420 | requirements: [] |
1421 | |
1422 | -rubyforge_project: terminal-table |
1423 | -rubygems_version: 1.3.5 |
1424 | -signing_key: |
1425 | -specification_version: 3 |
1426 | -summary: Simple, feature rich ascii table generation library |
1427 | -test_files: [] |
1428 | +dependencies: [] |
1429 | |
1430 | |
1431 | === modified file 'spec/cell_spec.rb' |
1432 | --- spec/cell_spec.rb 2011-06-17 13:38:26 +0000 |
1433 | +++ spec/cell_spec.rb 2013-12-12 07:49:48 +0000 |
1434 | @@ -1,3 +1,7 @@ |
1435 | +require 'rubygems' |
1436 | +require 'term/ansicolor' |
1437 | + |
1438 | +class String; include Term::ANSIColor; end |
1439 | |
1440 | require File.dirname(__FILE__) + '/spec_helper' |
1441 | |
1442 | @@ -5,14 +9,46 @@ |
1443 | Cell = Terminal::Table::Cell |
1444 | |
1445 | it "should default alignment to the left" do |
1446 | - cell = Cell.new 0, 'foo' |
1447 | + cell = Cell.new :value => 'foo', :table => Terminal::Table.new, :index => 0 |
1448 | cell.value.should == 'foo' |
1449 | cell.alignment.should == :left |
1450 | end |
1451 | |
1452 | it "should allow overriding of alignment" do |
1453 | - cell = Cell.new 0, :value => 'foo', :alignment => :center |
1454 | + cell = Cell.new :value => 'foo', :alignment => :center, :table => Terminal::Table.new, :index => 0 |
1455 | cell.value.should == 'foo' |
1456 | cell.alignment.should == :center |
1457 | end |
1458 | + |
1459 | + it "should allow :left, :right and :center for alignment" do |
1460 | + @cell = Cell.new :value => 'foo', :table => Terminal::Table.new, :index => 0 |
1461 | + @cell.alignment = :left |
1462 | + @cell.alignment = :right |
1463 | + @cell.alignment = :center |
1464 | + lambda { @cell.alignment = "foo" }.should raise_error |
1465 | + end |
1466 | + |
1467 | + it "should allow multiline content" do |
1468 | + cell = Cell.new :value => "barrissimo\n"+"foo".yellow, :table => Terminal::Table.new, :index => 0 |
1469 | + cell.value.should == "barrissimo\n"+"foo".yellow |
1470 | + cell.lines.should == ['barrissimo','foo'.yellow] |
1471 | + cell.value_for_column_width_recalc.should == 'barrissimo' |
1472 | + cell.render(0).should == " barrissimo " |
1473 | + end |
1474 | + |
1475 | + it "should allow colorized content" do |
1476 | + cell = Cell.new :value => "foo".red, :table => Terminal::Table.new, :index => 0 |
1477 | + cell.value.should == "\e[31mfoo\e[0m" |
1478 | + cell.value_for_column_width_recalc.should == 'foo' |
1479 | + cell.render.should == " \e[31mfoo\e[0m " |
1480 | + end |
1481 | + |
1482 | + it "should render padding properly" do |
1483 | + @table = Terminal::Table.new(:rows => [['foo', '2'], ['3', '4']], :style => {:padding_right => 3}) |
1484 | + cell = @table.rows.first.cells.first |
1485 | + cell.value.should == 'foo' |
1486 | + cell.alignment.should == :left |
1487 | + cell.render.should == " foo " |
1488 | + end |
1489 | + |
1490 | end |
1491 | |
1492 | === modified file 'spec/spec_helper.rb' |
1493 | --- spec/spec_helper.rb 2011-06-17 13:38:26 +0000 |
1494 | +++ spec/spec_helper.rb 2013-12-12 07:49:48 +0000 |
1495 | @@ -3,6 +3,6 @@ |
1496 | |
1497 | class String |
1498 | def deindent |
1499 | - gsub /^ */, '' |
1500 | + strip.gsub(/^ */, '') |
1501 | end |
1502 | end |
1503 | |
1504 | === modified file 'spec/table_spec.rb' (properties changed: +x to -x) |
1505 | --- spec/table_spec.rb 2011-06-17 13:38:26 +0000 |
1506 | +++ spec/table_spec.rb 2013-12-12 07:49:48 +0000 |
1507 | @@ -19,16 +19,16 @@ |
1508 | @table.column_with_headings(2).should == [3,6] |
1509 | end |
1510 | |
1511 | - it "should select the columns with colspans > 1 in the index" do |
1512 | - @table << [1,{:value => 2, :colspan => 2}] |
1513 | - @table << [{:value => 3, :colspan => 2}, 4] |
1514 | - end |
1515 | + #it "should select the columns with colspans > 1 in the index" do |
1516 | + # @table << [1,{:value => 2, :colspan => 2}] |
1517 | + # @table << [{:value => 3, :colspan => 2}, 4] |
1518 | + #end |
1519 | |
1520 | it "should account for the colspan when selecting columns" do |
1521 | @table << [1,2,3] |
1522 | @table << [{:value => "4,5", :colspan => 2}, 6] |
1523 | - @table.column_with_headings(0).should == [1,{:start_index => 0, :value => "4,5", :colspan => 2}] |
1524 | - @table.column_with_headings(1).should == [2,{:start_index => 0, :value => "4,5", :colspan => 2}] |
1525 | + @table.column_with_headings(0).should == [1,"4,5"] |
1526 | + @table.column_with_headings(1).should == [2,"4,5"] |
1527 | @table.column_with_headings(2).should == [3,6] |
1528 | end |
1529 | |
1530 | @@ -45,11 +45,6 @@ |
1531 | EOF |
1532 | end |
1533 | |
1534 | - it "should convert rows to indexes" do |
1535 | - @table << [{:value => '7', :colspan => 2}, 88] |
1536 | - @table.row_to_index(@table.rows[0], 1).should == 2 |
1537 | - end |
1538 | - |
1539 | it "should count columns" do |
1540 | @table << [1, 2, 3] |
1541 | @table.number_of_columns.should == 3 |
1542 | @@ -71,64 +66,27 @@ |
1543 | it "should select columns when using hashes" do |
1544 | @table.headings = ['one', 'two'] |
1545 | @table.rows = [[{ :value => 'a', :align => :left }, 1], ['b', 2], ['c', 3]] |
1546 | - @table.column(0).should == [{ :value => 'a', :align => :left }, 'b', 'c'] |
1547 | - end |
1548 | - |
1549 | - it "should determine length of largest cell in a column" do |
1550 | - @table << ['foo', 'bar'] |
1551 | - @table << ['big foo', 'big foo bar'] |
1552 | - @table.length_of_largest_cell_in_column(1).should == 11 |
1553 | - end |
1554 | - |
1555 | - it "should determine length of largest cell in a column with multi-column rows" do |
1556 | - @table << [1,2] |
1557 | - @table << [{:value => '123456789', :colspan => 2}] |
1558 | - # +-----+-----+ |
1559 | - # | 1 | 2 | |
1560 | - # | 123456789 | |
1561 | - # |
1562 | - @table.length_of_largest_cell_in_column(0).should == 3 |
1563 | - @table.length_of_largest_cell_in_column(1).should == 3 |
1564 | - |
1565 | - @table.render.should == <<-EOF.deindent |
1566 | - +-----+-----+ |
1567 | - | 1 | 2 | |
1568 | - | 123456789 | |
1569 | - +-----+-----+ |
1570 | - EOF |
1571 | - end |
1572 | - |
1573 | - it "should determine length of largest cell in a column with multi-column rows, rounding up" do |
1574 | - @table << [1,2] |
1575 | - @table << [{:value => '1234567890', :colspan => 2}] |
1576 | - @table.length_of_largest_cell_in_column(0).should == 4 |
1577 | - @table.length_of_largest_cell_in_column(1).should == 4 |
1578 | - |
1579 | - @table.render.should == <<-EOF.deindent |
1580 | - +------+------+ |
1581 | - | 1 | 2 | |
1582 | - | 1234567890 | |
1583 | - +------+------+ |
1584 | - EOF |
1585 | + @table.column(0).should == ['a', 'b', 'c'] |
1586 | end |
1587 | |
1588 | it "should find column length" do |
1589 | @table << ['foo', 'bar', 'a'] |
1590 | @table << ['big foo', 'big foo bar'] |
1591 | - @table.length_of_column(1).should == 11 |
1592 | + @table.column_width(1).should == 11 |
1593 | end |
1594 | |
1595 | it "should find column length with headings" do |
1596 | @table.headings = ['one', 'super long heading'] |
1597 | @table << ['foo', 'bar', 'a'] |
1598 | @table << ['big foo', 'big foo bar'] |
1599 | - @table.length_of_column(1).should == 18 |
1600 | + @table.column_width(1).should == 18 |
1601 | end |
1602 | |
1603 | it "should render separators" do |
1604 | @table.headings = ['Char', 'Num'] |
1605 | @table << ['a', 1] |
1606 | - @table.separator.should == '+------+-----+' |
1607 | + separator = Terminal::Table::Separator.new(@table) |
1608 | + separator.render.should == '+------+-----+' |
1609 | end |
1610 | |
1611 | it "should add separator" do |
1612 | @@ -136,11 +94,13 @@ |
1613 | @table.add_separator |
1614 | @table << ['b', 2] |
1615 | @table.rows.size.should == 2 |
1616 | - @table.all_rows.size.should == 3 |
1617 | end |
1618 | |
1619 | - it "should bitch and complain when you have no rows" do |
1620 | - lambda { @table.render }.should raise_error(Terminal::Table::Error) |
1621 | + it "should render an empty table properly" do |
1622 | + @table.render.should == <<-EOF.deindent |
1623 | + ++ |
1624 | + ++ |
1625 | + EOF |
1626 | end |
1627 | |
1628 | it "should render properly" do |
1629 | @@ -159,6 +119,60 @@ |
1630 | EOF |
1631 | end |
1632 | |
1633 | + it "should render styles properly" do |
1634 | + @table.headings = ['Char', 'Num'] |
1635 | + @table.style = {:border_x => "=", :border_y => ":", :border_i => "x", :padding_left => 0, :padding_right => 2} |
1636 | + @table << ['a', 1] |
1637 | + @table << ['b', 2] |
1638 | + @table << ['c', 3] |
1639 | + @table.style.padding_right.should == 2 |
1640 | + @table.render.should == <<-EOF.deindent |
1641 | + x======x=====x |
1642 | + :Char :Num : |
1643 | + x======x=====x |
1644 | + :a :1 : |
1645 | + :b :2 : |
1646 | + :c :3 : |
1647 | + x======x=====x |
1648 | + EOF |
1649 | + end |
1650 | + |
1651 | + it "should render width properly" do |
1652 | + @table.headings = ['Char', 'Num'] |
1653 | + @table << ['a', 1] |
1654 | + @table << ['b', 2] |
1655 | + @table << ['c', 3] |
1656 | + @table.style.width = 21 |
1657 | + @table.render.should == <<-EOF.deindent |
1658 | + +---------+---------+ |
1659 | + | Char | Num | |
1660 | + +---------+---------+ |
1661 | + | a | 1 | |
1662 | + | b | 2 | |
1663 | + | c | 3 | |
1664 | + +---------+---------+ |
1665 | + EOF |
1666 | + end |
1667 | + |
1668 | + it "should render title properly" do |
1669 | + @table.title = "Title" |
1670 | + @table.headings = ['Char', 'Num'] |
1671 | + @table << ['a', 1] |
1672 | + @table << ['b', 2] |
1673 | + @table << ['c', 3] |
1674 | + @table.render.should == <<-EOF.deindent |
1675 | + +------+-----+ |
1676 | + | Title | |
1677 | + +------+-----+ |
1678 | + | Char | Num | |
1679 | + +------+-----+ |
1680 | + | a | 1 | |
1681 | + | b | 2 | |
1682 | + | c | 3 | |
1683 | + +------+-----+ |
1684 | + EOF |
1685 | + end |
1686 | + |
1687 | it "should render properly without headings" do |
1688 | @table << ['a', 1] |
1689 | @table << ['b', 2] |
1690 | @@ -307,13 +321,13 @@ |
1691 | t.should == t |
1692 | end |
1693 | |
1694 | - it "should be equal with two empty tables" do |
1695 | - table_one = Table.new |
1696 | - table_two = Table.new |
1697 | - |
1698 | - table_one.should == table_two |
1699 | - table_two.should == table_one |
1700 | - end |
1701 | + # it "should be equal with two empty tables" do |
1702 | + # table_one = Table.new |
1703 | + # table_two = Table.new |
1704 | + # |
1705 | + # table_one.should == table_two |
1706 | + # table_two.should == table_one |
1707 | + # end |
1708 | |
1709 | it "should not be equal with different headings" do |
1710 | table_one = Table.new |
1711 | @@ -329,8 +343,6 @@ |
1712 | table_one = Table.new |
1713 | table_two = Table.new |
1714 | |
1715 | - table_one.add_row "a" |
1716 | - |
1717 | table_one.should_not == table_two |
1718 | table_two.should_not == table_one |
1719 | end |
1720 | @@ -447,5 +459,67 @@ |
1721 | +------+---+---+---+ |
1722 | EOF |
1723 | end |
1724 | + |
1725 | + it "should handle multiple colspan" do |
1726 | + @table.headings = [ |
1727 | + 'name', |
1728 | + { :value => 'Values', :alignment => :right, :colspan => 2}, |
1729 | + { :value => 'Other values', :alignment => :right, :colspan => 2}, |
1730 | + { :value => 'Column 3', :alignment => :right, :colspan => 2} |
1731 | + ] |
1732 | + |
1733 | + 3.times do |row_index| |
1734 | + row = ["row ##{row_index+1}"] |
1735 | + 6.times do |i| |
1736 | + row << row_index*6 + i |
1737 | + end |
1738 | + @table.add_row(row) |
1739 | + end |
1740 | + |
1741 | + @table.render.should == <<-EOF.deindent |
1742 | + +--------+----+----+-------+-------+-----+-----+ |
1743 | + | name | Values | Other values | Column 3 | |
1744 | + +--------+----+----+-------+-------+-----+-----+ |
1745 | + | row #1 | 0 | 1 | 2 | 3 | 4 | 5 | |
1746 | + | row #2 | 6 | 7 | 8 | 9 | 10 | 11 | |
1747 | + | row #3 | 12 | 13 | 14 | 15 | 16 | 17 | |
1748 | + +--------+----+----+-------+-------+-----+-----+ |
1749 | + EOF |
1750 | + end |
1751 | + |
1752 | + it "should render a table with only X cell borders" do |
1753 | + @table.style = {:border_x => "-", :border_y => "", :border_i => ""} |
1754 | + |
1755 | + @table.headings = ['name', { :value => 'values', :alignment => :right, :colspan => 3}] |
1756 | + @table.headings = ['name', { :value => 'values', :colspan => 3}] |
1757 | + @table.rows = [['a', 1, 2, 3], ['b', 4, 5, 6], ['c', 7, 8, 9]] |
1758 | + |
1759 | + @table.render.should == <<-EOF.strip |
1760 | +--------------- |
1761 | + name values |
1762 | +--------------- |
1763 | + a 1 2 3 |
1764 | + b 4 5 6 |
1765 | + c 7 8 9 |
1766 | +--------------- |
1767 | + EOF |
1768 | + end |
1769 | + |
1770 | + it "should render a table without cell borders" do |
1771 | + @table.style = {:border_x => "", :border_y => "", :border_i => ""} |
1772 | + |
1773 | + @table.headings = ['name', { :value => 'values', :alignment => :right, :colspan => 3}] |
1774 | + @table.headings = ['name', { :value => 'values', :colspan => 3}] |
1775 | + @table.rows = [['a', 1, 2, 3], ['b', 4, 5, 6], ['c', 7, 8, 9]] |
1776 | + |
1777 | + @table.render.should == <<-EOF |
1778 | + |
1779 | + name values |
1780 | + |
1781 | + a 1 2 3 |
1782 | + b 4 5 6 |
1783 | + c 7 8 9 |
1784 | + EOF |
1785 | + end |
1786 | end |
1787 | end |
1788 | |
1789 | === modified file 'terminal-table.gemspec' |
1790 | --- terminal-table.gemspec 2011-06-17 13:38:26 +0000 |
1791 | +++ terminal-table.gemspec 2013-12-12 07:49:48 +0000 |
1792 | @@ -2,15 +2,15 @@ |
1793 | |
1794 | Gem::Specification.new do |s| |
1795 | s.name = %q{terminal-table} |
1796 | - s.version = "1.4.2" |
1797 | + s.version = "1.4.5" |
1798 | |
1799 | s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= |
1800 | - s.authors = ["TJ Holowaychuk"] |
1801 | - s.date = %q{2010-01-14} |
1802 | + s.authors = ["TJ Holowaychuk", "Scott J. Goldman"] |
1803 | + s.date = %q{2012-3-15} |
1804 | s.description = %q{Simple, feature rich ascii table generation library} |
1805 | s.email = %q{tj@vision-media.ca} |
1806 | - 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"] |
1807 | - 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"] |
1808 | + s.extra_rdoc_files = ["README.rdoc", "lib/terminal-table.rb", "lib/terminal-table/cell.rb", "lib/terminal-table/core_ext.rb", "lib/terminal-table/import.rb", "lib/terminal-table/table.rb", "lib/terminal-table/version.rb", "lib/terminal-table/row.rb", "lib/terminal-table/separator.rb", "lib/terminal-table/style.rb", "lib/terminal-table/table_helper.rb", "lib/terminal-table/version.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"] |
1809 | + 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/import.rb", "lib/terminal-table/table.rb", "lib/terminal-table/table_helper.rb", "lib/terminal-table/version.rb", "lib/terminal-table/row.rb", "lib/terminal-table/separator.rb", "lib/terminal-table/style.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"] |
1810 | s.homepage = %q{http://github.com/visionmedia/terminal-table} |
1811 | s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Terminal-table", "--main", "README.rdoc"] |
1812 | s.require_paths = ["lib"] |
1813 | @@ -18,7 +18,7 @@ |
1814 | s.rubygems_version = %q{1.3.5} |
1815 | s.summary = %q{Simple, feature rich ascii table generation library} |
1816 | |
1817 | - if s.respond_to? :specification_version then |
1818 | + if s.respond_to? :specification_version= then |
1819 | current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION |
1820 | s.specification_version = 3 |
1821 |
Thanks. Uploaded.