formatador 0.0.7 → 0.0.9
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.
- data/VERSION +1 -1
- data/formatador.gemspec +1 -1
- data/lib/formatador.rb +11 -3
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|
data/formatador.gemspec
CHANGED
data/lib/formatador.rb
CHANGED
@@ -58,11 +58,13 @@ class Formatador
|
|
58
58
|
def display(string = '')
|
59
59
|
print(format("[indent]#{string}"))
|
60
60
|
STDOUT.flush
|
61
|
+
nil
|
61
62
|
end
|
62
63
|
|
63
64
|
def display_line(string = '')
|
64
65
|
display(string)
|
65
66
|
print("\n")
|
67
|
+
nil
|
66
68
|
end
|
67
69
|
|
68
70
|
def display_table(hashes, keys = nil)
|
@@ -73,7 +75,7 @@ class Formatador
|
|
73
75
|
unless keys
|
74
76
|
headers << key
|
75
77
|
end
|
76
|
-
widths[key] = [key.to_s.length, widths[key] || 0, hash[key] && hash[key].length || 0].max
|
78
|
+
widths[key] = [key.to_s.length, widths[key] || 0, hash[key] && hash[key].to_s.length || 0].max
|
77
79
|
end
|
78
80
|
headers = headers.uniq
|
79
81
|
end
|
@@ -84,18 +86,23 @@ class Formatador
|
|
84
86
|
end
|
85
87
|
|
86
88
|
display_line(split)
|
87
|
-
|
89
|
+
columns = []
|
90
|
+
for header in headers
|
91
|
+
columns << "#{header}#{' ' * (widths[header] - header.to_s.length)}"
|
92
|
+
end
|
93
|
+
display_line("| #{columns.join(' | ')} |")
|
88
94
|
display_line(split)
|
89
95
|
|
90
96
|
for hash in hashes
|
91
97
|
columns = []
|
92
98
|
for header in headers
|
93
99
|
datum = hash[header] || ''
|
94
|
-
columns << "#{datum}#{' ' * (widths[header] - datum.length)}"
|
100
|
+
columns << "#{datum}#{' ' * (widths[header] - datum.to_s.length)}"
|
95
101
|
end
|
96
102
|
display_line("| #{columns.join(' | ')} |")
|
97
103
|
display_line(split)
|
98
104
|
end
|
105
|
+
nil
|
99
106
|
end
|
100
107
|
|
101
108
|
def format(string)
|
@@ -119,6 +126,7 @@ class Formatador
|
|
119
126
|
def redisplay(string = '')
|
120
127
|
print("\r")
|
121
128
|
display("#{string}")
|
129
|
+
nil
|
122
130
|
end
|
123
131
|
|
124
132
|
%w{display display_line display_table format redisplay}.each do |method|
|