ztk 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/ztk/report.rb +28 -12
- data/lib/ztk/version.rb +1 -1
- data/spec/spec_helper.rb +2 -4
- metadata +101 -145
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/ztk.png)](http://badge.fury.io/rb/ztk)
|
2
|
+
[![Dependency Status](https://gemnasium.com/zpatten/ztk.png)](https://gemnasium.com/zpatten/ztk)
|
1
3
|
[![Build Status](https://secure.travis-ci.org/zpatten/ztk.png)](http://travis-ci.org/zpatten/ztk)
|
2
4
|
[![Code Climate](https://codeclimate.com/github/zpatten/ztk.png)](https://codeclimate.com/github/zpatten/ztk)
|
3
|
-
[![Dependency Status](https://gemnasium.com/zpatten/ztk.png)](https://gemnasium.com/zpatten/ztk)
|
4
5
|
|
5
6
|
# ZTK
|
6
7
|
|
data/lib/ztk/report.rb
CHANGED
@@ -74,14 +74,8 @@ module ZTK
|
|
74
74
|
rows << block.call(data)
|
75
75
|
end
|
76
76
|
|
77
|
-
headers
|
78
|
-
|
79
|
-
max_lengths.send("#{header}=", maximum)
|
80
|
-
end
|
81
|
-
|
82
|
-
header_line = headers.collect do |header|
|
83
|
-
"%-#{max_lengths.send(header)}s" % header.to_s.upcase
|
84
|
-
end
|
77
|
+
max_lengths = max_spreadsheet_lengths(headers, rows)
|
78
|
+
header_line = headers.collect { |header| "%-#{max_lengths.send(header)}s" % header.to_s.upcase }
|
85
79
|
header_line = format_row(header_line)
|
86
80
|
|
87
81
|
config.ui.stdout.puts(format_header(headers, max_lengths))
|
@@ -90,17 +84,23 @@ module ZTK
|
|
90
84
|
|
91
85
|
rows.each do |row|
|
92
86
|
row_line = headers.collect do |header|
|
93
|
-
|
87
|
+
header_length = max_lengths.send(header)
|
88
|
+
content = row.send(header)
|
89
|
+
|
90
|
+
"%-#{header_length}s" % content
|
94
91
|
end
|
92
|
+
|
95
93
|
row_line = format_row(row_line)
|
96
94
|
config.ui.stdout.puts(row_line)
|
97
95
|
end
|
98
96
|
|
99
97
|
config.ui.stdout.puts(format_header(headers, max_lengths))
|
100
98
|
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
OpenStruct.new(
|
100
|
+
:rows => rows,
|
101
|
+
:max_lengths => max_lengths,
|
102
|
+
:width => calculate_spreadsheet_width(headers, max_lengths)
|
103
|
+
)
|
104
104
|
end
|
105
105
|
|
106
106
|
# Displays data in a key-value list style.
|
@@ -155,6 +155,22 @@ module ZTK
|
|
155
155
|
|
156
156
|
private
|
157
157
|
|
158
|
+
def max_spreadsheet_lengths(headers, rows)
|
159
|
+
max_lengths = OpenStruct.new
|
160
|
+
headers.each do |header|
|
161
|
+
collection = [header, rows.map(&header)].flatten
|
162
|
+
maximum = collection.map(&:to_s).map(&:length).max
|
163
|
+
max_lengths.send("#{header}=", maximum)
|
164
|
+
end
|
165
|
+
max_lengths
|
166
|
+
end
|
167
|
+
|
168
|
+
def calculate_spreadsheet_width(headers, max_lengths)
|
169
|
+
header_lengths = ((headers.count * 3) - 3)
|
170
|
+
max_length = max_lengths.send(:table).values.reduce(:+)
|
171
|
+
(2 + max_length + header_lengths + 2)
|
172
|
+
end
|
173
|
+
|
158
174
|
def format_header(headers, lengths)
|
159
175
|
line = headers.collect do |header|
|
160
176
|
"-" * lengths.send(header)
|
data/lib/ztk/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -17,17 +17,15 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
################################################################################
|
20
|
-
|
21
|
-
require 'ztk'
|
22
20
|
require 'tempfile'
|
23
21
|
|
24
|
-
################################################################################
|
25
|
-
|
26
22
|
require 'simplecov'
|
27
23
|
SimpleCov.start do
|
28
24
|
add_filter '/spec/'
|
29
25
|
end if ENV["COVERAGE"]
|
30
26
|
|
27
|
+
require 'ztk'
|
28
|
+
|
31
29
|
ENV['LOG_LEVEL'] = "DEBUG"
|
32
30
|
|
33
31
|
WAIT_SMALL = 3
|
metadata
CHANGED
@@ -1,184 +1,137 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.10
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 1.0.11
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Zachary Patten
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2013-04-14 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: erubis
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
31
27
|
name: net-ssh
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
33
29
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version:
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
47
38
|
name: net-sftp
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
40
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version:
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
54
45
|
type: :runtime
|
55
46
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
63
49
|
name: activesupport
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
65
51
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version:
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
70
56
|
type: :runtime
|
71
57
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
79
60
|
name: pry
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
62
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version:
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
86
67
|
type: :development
|
87
68
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
95
71
|
name: rake
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
97
73
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version:
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
102
78
|
type: :development
|
103
79
|
prerelease: false
|
104
|
-
version_requirements:
|
105
|
-
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
80
|
+
version_requirements: *id006
|
81
|
+
- !ruby/object:Gem::Dependency
|
111
82
|
name: rspec
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
113
84
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version:
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
118
89
|
type: :development
|
119
90
|
prerelease: false
|
120
|
-
version_requirements:
|
121
|
-
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
91
|
+
version_requirements: *id007
|
92
|
+
- !ruby/object:Gem::Dependency
|
127
93
|
name: simplecov
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
129
95
|
none: false
|
130
|
-
requirements:
|
131
|
-
- -
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version:
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: "0"
|
134
100
|
type: :development
|
135
101
|
prerelease: false
|
136
|
-
version_requirements:
|
137
|
-
|
138
|
-
requirements:
|
139
|
-
- - ! '>='
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
102
|
+
version_requirements: *id008
|
103
|
+
- !ruby/object:Gem::Dependency
|
143
104
|
name: yard
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
105
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
145
106
|
none: false
|
146
|
-
requirements:
|
147
|
-
- -
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version:
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: "0"
|
150
111
|
type: :development
|
151
112
|
prerelease: false
|
152
|
-
version_requirements:
|
153
|
-
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
- !ruby/object:Gem::Dependency
|
113
|
+
version_requirements: *id009
|
114
|
+
- !ruby/object:Gem::Dependency
|
159
115
|
name: redcarpet
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
161
117
|
none: false
|
162
|
-
requirements:
|
163
|
-
- -
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version:
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: "0"
|
166
122
|
type: :development
|
167
123
|
prerelease: false
|
168
|
-
version_requirements:
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - ! '>='
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
124
|
+
version_requirements: *id010
|
174
125
|
description: Zachary's (DevOp) Tool Kit
|
175
|
-
email:
|
126
|
+
email:
|
176
127
|
- zachary@jovelabs.com
|
177
|
-
executables:
|
128
|
+
executables:
|
178
129
|
- ztk
|
179
130
|
extensions: []
|
131
|
+
|
180
132
|
extra_rdoc_files: []
|
181
|
-
|
133
|
+
|
134
|
+
files:
|
182
135
|
- .gitignore
|
183
136
|
- .rspec
|
184
137
|
- .rvmrc.template
|
@@ -240,35 +193,38 @@ files:
|
|
240
193
|
- ztk.gemspec
|
241
194
|
homepage: https://github.com/zpatten/ztk
|
242
195
|
licenses: []
|
196
|
+
|
243
197
|
post_install_message:
|
244
198
|
rdoc_options: []
|
245
|
-
|
199
|
+
|
200
|
+
require_paths:
|
246
201
|
- lib
|
247
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
248
203
|
none: false
|
249
|
-
requirements:
|
250
|
-
- -
|
251
|
-
- !ruby/object:Gem::Version
|
252
|
-
|
253
|
-
segments:
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
hash: -3896273515373899790
|
208
|
+
segments:
|
254
209
|
- 0
|
255
|
-
|
256
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
|
+
version: "0"
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
212
|
none: false
|
258
|
-
requirements:
|
259
|
-
- -
|
260
|
-
- !ruby/object:Gem::Version
|
261
|
-
|
262
|
-
segments:
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
hash: -3896273515373899790
|
217
|
+
segments:
|
263
218
|
- 0
|
264
|
-
|
219
|
+
version: "0"
|
265
220
|
requirements: []
|
221
|
+
|
266
222
|
rubyforge_project:
|
267
223
|
rubygems_version: 1.8.25
|
268
224
|
signing_key:
|
269
225
|
specification_version: 3
|
270
226
|
summary: Contains various classes and utilities I find I regularly need.
|
271
|
-
test_files:
|
227
|
+
test_files:
|
272
228
|
- spec/spec_helper.rb
|
273
229
|
- spec/support/test-config.rb
|
274
230
|
- spec/support/test-template.txt.erb
|