winr 1.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/winr +37 -24
  3. data/winr.gemspec +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5b9f7f96814ddc74f0cf997f96355ca43be031355fa06c58de54421ec395ee9
4
- data.tar.gz: 073a1747bac59f25a0eaa161fdff7ef491eca92eb917ef36094bd6cf12077f35
3
+ metadata.gz: 92cf6d6550696708f56fbdaf257a4dc03c45f492d29da6e48c6402475e5b6071
4
+ data.tar.gz: a5453c06028778540c0c46d1822917a634dd295f2689cc96eed153ed436c7e7e
5
5
  SHA512:
6
- metadata.gz: 99584b189c83cc9bac6558a6e379b70f074c59f9e73f95425096d0ad557ef5b239eb2feaad9ad55c90e60b99ae03c9f23d523fb73edc0d0d37a2af2286ae6176
7
- data.tar.gz: 4ee9ad210345e670ed3bcae76a5d08ced2dd47a1c1a61fb417d457960c73fc17e89b68a63d6f02ed71a5949b03339b6d62ac812801024b4f7290baa8fcf6528c
6
+ metadata.gz: d2b10ae402f1d2852fb383d8ac37edaa62bd745934f69b7365cf4ffd11030fe1e7ec33e663a8b375ea35dc81ee7f89d5c31332735117ee24e23c307ee6f6ef9c
7
+ data.tar.gz: ef2bddad89692a60e7f0eb3f06d7644c029918bd2bfbe10916ae4fe307b58fd32470ee6c203cfa3bc655c09d506878149da969739bdc655e78cbcfdf831cba58
data/bin/winr CHANGED
@@ -15,7 +15,7 @@
15
15
  # 1. Enable YAML config files
16
16
  # ============================================================================
17
17
 
18
- trap("INT" ) { abort "\n" }
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,7 +227,7 @@ end
204
227
 
205
228
  # read the winr script
206
229
  winr = ARGV.first or abort "missing winr script"
207
- tmpl = ERB.new(DATA.read)
230
+ tmpl = ERB.new(template)
208
231
 
209
232
  # grok the config
210
233
  $config = eval(File.read(winr))
@@ -212,6 +235,16 @@ es = $config.environments || [{}]
212
235
  cs = $config.contexts || [{}]
213
236
  ts = $config.tasks || [{}]
214
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
+
215
248
  # box drawing
216
249
  cols = stats(show)
217
250
  full = cols.map(&:size).sum + cols.size * 11 - 3
@@ -229,6 +262,7 @@ es.each_with_index do |e, ei|
229
262
  puts IO.popen(["ruby", "-v"].join(" "), &:read) unless hush
230
263
  puts rt
231
264
 
265
+ # TODO: read this from e.command
232
266
  command = ["/usr/bin/env ruby"]
233
267
 
234
268
  # loop over context(s) and task(s)
@@ -274,8 +308,8 @@ full = cols.sum + (cols.size - 1) * 3
274
308
  rt, rm, rb = boxlines(wide, cols)
275
309
  rh = "│ %-*.*s │" % [wide, wide, "Rank"]
276
310
  rh << " %-*.*s │" % [full, full, "Performance".center(full)]
277
-
278
311
  puts rt, rh, rm
312
+
279
313
  flip = cs.size > 1 && ts.size == 1
280
314
  rank.each do |ips, ei, ci, ti|
281
315
  name = (flip ? cs[ci] : ts[ti]).name
@@ -291,24 +325,3 @@ rank.each do |ips, ei, ci, ti|
291
325
  end
292
326
  puts rb
293
327
  puts "```" unless hush
294
-
295
- __END__
296
-
297
- # ============================================================================
298
- # Environment <%= ei + 1 %>: <%= e.name %>
299
- # Context <%= ci + 1 %>: <%= c.name %>
300
- # Task <%= ti + 1 %>: <%= t.name %>
301
- # ============================================================================
302
-
303
- trap("INT") { exit }
304
-
305
- # def __winr_timer; Process.clock_gettime(Process::CLOCK_MONOTONIC); end
306
- def __winr_timer; Time.now.to_f; end
307
-
308
- <%= e.begin %>
309
- <%= c.begin %>
310
-
311
- <%= compile(t, file.path) %>
312
-
313
- <%= c.end %>
314
- <%= e.end %>
data/winr.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "winr"
5
- s.version = "1.0"
5
+ s.version = "1.0.2"
6
6
  s.author = "Steve Shreeve"
7
7
  s.email = "steve.shreeve@gmail.com"
8
8
  s.summary =
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winr
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve