formatador 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'formatador'
16
- s.version = '0.0.14'
17
- s.date = '2010-04-26'
16
+ s.version = '0.0.15'
17
+ s.date = '2010-07-19'
18
18
  s.rubyforge_project = 'formatador'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'formatador', 'progressbar')
3
3
 
4
4
  class Formatador
5
5
 
6
- VERSION = '0.0.14'
6
+ VERSION = '0.0.15'
7
7
 
8
8
  STYLES = {
9
9
  :"\/" => "0",
@@ -120,5 +120,6 @@ if __FILE__ == $0
120
120
  'one',
121
121
  'two'
122
122
  ])
123
+ Formatador.display_table([], [:foo])
123
124
 
124
125
  end
@@ -3,14 +3,20 @@ class Formatador
3
3
  def display_table(hashes, keys = nil, &block)
4
4
  headers = keys || []
5
5
  widths = {}
6
- for hash in hashes
7
- for key in hash.keys
8
- unless keys
9
- headers << key
6
+ if hashes.empty? && keys
7
+ for key in keys
8
+ widths[key] = key.to_s.length
9
+ end
10
+ else
11
+ for hash in hashes
12
+ for key in hash.keys
13
+ unless keys
14
+ headers << key
15
+ end
16
+ widths[key] = [key.to_s.length, widths[key] || 0, hash[key] && hash[key].to_s.length || 0].max
10
17
  end
11
- widths[key] = [key.to_s.length, widths[key] || 0, hash[key] && hash[key].to_s.length || 0].max
18
+ headers = headers.uniq
12
19
  end
13
- headers = headers.uniq
14
20
  end
15
21
 
16
22
  if block_given?
@@ -31,7 +37,7 @@ class Formatador
31
37
  display_line(split)
32
38
  columns = []
33
39
  for header in headers
34
- columns << "#{header}#{' ' * (widths[header] - header.to_s.length)}"
40
+ columns << "[bold]#{header}[/]#{' ' * (widths[header] - header.to_s.length)}"
35
41
  end
36
42
  display_line("| #{columns.join(' | ')} |")
37
43
  display_line(split)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 14
9
- version: 0.0.14
8
+ - 15
9
+ version: 0.0.15
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-26 00:00:00 -07:00
17
+ date: 2010-07-19 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20