ztk 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ztk/report.rb +16 -8
- data/lib/ztk/version.rb +1 -1
- metadata +4 -4
data/lib/ztk/report.rb
CHANGED
@@ -57,8 +57,8 @@ module ZTK
|
|
57
57
|
# | users | false | amd64 | ubuntu | 192.168.7.78 | 00:00:5e:89:f9:50 | N/A | true |
|
58
58
|
# +-------------+-------+-------+--------+----------------+-------------------+--------------+---------+
|
59
59
|
#
|
60
|
-
# @param [Array] dataset
|
61
|
-
# report
|
60
|
+
# @param [Array<Object>,Object] dataset A single object or an array of
|
61
|
+
# objects for which we want to generate a report
|
62
62
|
# @param [Array] headers An array of headers used for ordering the output.
|
63
63
|
# @return [OpenStruct]
|
64
64
|
def spreadsheet(dataset, headers, &block)
|
@@ -70,8 +70,12 @@ module ZTK
|
|
70
70
|
max_lengths = OpenStruct.new
|
71
71
|
headers = headers.map(&:downcase).map(&:to_sym)
|
72
72
|
|
73
|
-
dataset.
|
74
|
-
|
73
|
+
if dataset.is_a?(Array)
|
74
|
+
dataset.each do |data|
|
75
|
+
rows << block.call(data)
|
76
|
+
end
|
77
|
+
else
|
78
|
+
rows << block.call(dataset)
|
75
79
|
end
|
76
80
|
|
77
81
|
max_lengths = max_spreadsheet_lengths(headers, rows)
|
@@ -118,8 +122,8 @@ module ZTK
|
|
118
122
|
# | CHEF-SERVER DEFAULT PASSWORD: p@ssw0rd1 |
|
119
123
|
# +-------------------------------------------------------------------+
|
120
124
|
#
|
121
|
-
# @param [Array] dataset
|
122
|
-
# report
|
125
|
+
# @param [Array<Object>,Object] dataset A single object or an array of
|
126
|
+
# objects for which we want to generate a report
|
123
127
|
# @param [Array] headers An array of headers used for ordering the output.
|
124
128
|
# @return [OpenStruct]
|
125
129
|
def list(dataset, headers, &block)
|
@@ -131,8 +135,12 @@ module ZTK
|
|
131
135
|
max_lengths = OpenStruct.new
|
132
136
|
headers = headers.map(&:downcase).map(&:to_sym)
|
133
137
|
|
134
|
-
dataset.
|
135
|
-
|
138
|
+
if dataset.is_a?(Array)
|
139
|
+
dataset.each do |data|
|
140
|
+
rows << block.call(data)
|
141
|
+
end
|
142
|
+
else
|
143
|
+
rows << block.call(dataset)
|
136
144
|
end
|
137
145
|
|
138
146
|
max_key_length = headers.collect{ |header| header.length }.max
|
data/lib/ztk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: erubis
|
@@ -263,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
263
|
version: '0'
|
264
264
|
segments:
|
265
265
|
- 0
|
266
|
-
hash: -
|
266
|
+
hash: -2630435571996586272
|
267
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
268
|
none: false
|
269
269
|
requirements:
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
segments:
|
274
274
|
- 0
|
275
|
-
hash: -
|
275
|
+
hash: -2630435571996586272
|
276
276
|
requirements: []
|
277
277
|
rubyforge_project:
|
278
278
|
rubygems_version: 1.8.25
|