winr 1.0.1 → 1.0.3
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.
- checksums.yaml +4 -4
- data/bin/winr +37 -24
- data/winr.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b02cb3ee3438dce04a4e679a3185cefa7fb186ec55ba5420cf7360af5bd48ca3
|
4
|
+
data.tar.gz: c167107fd079c1fef8a2f1a9e2cb83a45c22bb45f49b52bc37fec84f6a286094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f00715da9e686d79aa799000d14646af8fdc0586b86ed733a6e4dbac8e6ae9b649315829d3115f3cb1a048457802b3f0e8c25ad965fa6507449d93b84d9cc785
|
7
|
+
data.tar.gz: 28f1d9e66cc0eaebb5890b39b2c1a40d9b19123a910ba821c6fff139817d92730cf1ab868dd9be6b60666d9562f5bf0319c51a54cb35fb15f72a8a3e1bd97a1c
|
data/bin/winr
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# 1. Enable YAML config files
|
16
16
|
# ============================================================================
|
17
17
|
|
18
|
-
trap("INT"
|
18
|
+
trap("INT") { abort "\n" }
|
19
19
|
|
20
20
|
require "erb"
|
21
21
|
require "optparse"
|
@@ -150,6 +150,29 @@ def compile(task, path)
|
|
150
150
|
|
|
151
151
|
end
|
152
152
|
|
153
|
+
def template
|
154
|
+
<<~"end"
|
155
|
+
# ============================================================================
|
156
|
+
# Environment <%= ei + 1 %>: <%= e.name %>
|
157
|
+
# Context <%= ci + 1 %>: <%= c.name %>
|
158
|
+
# Task <%= ti + 1 %>: <%= t.name %>
|
159
|
+
# ============================================================================
|
160
|
+
|
161
|
+
trap("INT") { exit }
|
162
|
+
|
163
|
+
# def __winr_timer; Process.clock_gettime(Process::CLOCK_MONOTONIC); end
|
164
|
+
def __winr_timer; Time.now.to_f; end
|
165
|
+
|
166
|
+
<%= e.begin %>
|
167
|
+
<%= c.begin %>
|
168
|
+
|
169
|
+
<%= compile(t, file.path) %>
|
170
|
+
|
171
|
+
<%= c.end %>
|
172
|
+
<%= e.end %>
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
153
176
|
# ==[ Helpers ]==
|
154
177
|
|
155
178
|
def boxlines(main, cols, runs=1)
|
@@ -204,28 +227,7 @@ end
|
|
204
227
|
|
205
228
|
# read the winr script
|
206
229
|
winr = ARGV.first or abort "missing winr script"
|
207
|
-
|
208
|
-
# generate the code template
|
209
|
-
tmpl = ERB.new(<<~"end")
|
210
|
-
# ============================================================================
|
211
|
-
# Environment <%= ei + 1 %>: <%= e.name %>
|
212
|
-
# Context <%= ci + 1 %>: <%= c.name %>
|
213
|
-
# Task <%= ti + 1 %>: <%= t.name %>
|
214
|
-
# ============================================================================
|
215
|
-
|
216
|
-
trap("INT") { exit }
|
217
|
-
|
218
|
-
# def __winr_timer; Process.clock_gettime(Process::CLOCK_MONOTONIC); end
|
219
|
-
def __winr_timer; Time.now.to_f; end
|
220
|
-
|
221
|
-
<%= e.begin %>
|
222
|
-
<%= c.begin %>
|
223
|
-
|
224
|
-
<%= compile(t, file.path) %>
|
225
|
-
|
226
|
-
<%= c.end %>
|
227
|
-
<%= e.end %>
|
228
|
-
end
|
230
|
+
tmpl = ERB.new(template)
|
229
231
|
|
230
232
|
# grok the config
|
231
233
|
$config = eval(File.read(winr))
|
@@ -233,6 +235,16 @@ es = $config.environments || [{}]
|
|
233
235
|
cs = $config.contexts || [{}]
|
234
236
|
ts = $config.tasks || [{}]
|
235
237
|
|
238
|
+
# adjust script fields, if needed
|
239
|
+
[*es, *cs].each do |item|
|
240
|
+
if item.script
|
241
|
+
if item.begin || item.end
|
242
|
+
abort "scripts for environments and contexts should go into begin or end"
|
243
|
+
end
|
244
|
+
item.begin = item.script
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
236
248
|
# box drawing
|
237
249
|
cols = stats(show)
|
238
250
|
full = cols.map(&:size).sum + cols.size * 11 - 3
|
@@ -250,6 +262,7 @@ es.each_with_index do |e, ei|
|
|
250
262
|
puts IO.popen(["ruby", "-v"].join(" "), &:read) unless hush
|
251
263
|
puts rt
|
252
264
|
|
265
|
+
# TODO: read this from e.command
|
253
266
|
command = ["/usr/bin/env ruby"]
|
254
267
|
|
255
268
|
# loop over context(s) and task(s)
|
@@ -295,8 +308,8 @@ full = cols.sum + (cols.size - 1) * 3
|
|
295
308
|
rt, rm, rb = boxlines(wide, cols)
|
296
309
|
rh = "│ %-*.*s │" % [wide, wide, "Rank"]
|
297
310
|
rh << " %-*.*s │" % [full, full, "Performance".center(full)]
|
298
|
-
|
299
311
|
puts rt, rh, rm
|
312
|
+
|
300
313
|
flip = cs.size > 1 && ts.size == 1
|
301
314
|
rank.each do |ips, ei, ci, ti|
|
302
315
|
name = (flip ? cs[ci] : ts[ti]).name
|
data/winr.gemspec
CHANGED