winr 1.0.1 → 1.0.3

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: 2f21441bb531e1d38f35a8f66a06cde6ab1082b2ea9713d4f25f78dc6ca2f870
4
- data.tar.gz: 2d0149171faeb84c7942f6d0546591c3d8ac9789771a682271a9a1d650820f09
3
+ metadata.gz: b02cb3ee3438dce04a4e679a3185cefa7fb186ec55ba5420cf7360af5bd48ca3
4
+ data.tar.gz: c167107fd079c1fef8a2f1a9e2cb83a45c22bb45f49b52bc37fec84f6a286094
5
5
  SHA512:
6
- metadata.gz: 67f0e74a0135c3927d4826d1160302ce30c2091193b762ae56b48db0eaf2c77cbe14e26ce212ff022feafebf38938ded4ddf3429a956240f3c0742be8dc0c1a5
7
- data.tar.gz: 34d00a66c0d6bb5d100d551543d5c69e61f873bca05db421c830dce67df8b00a028369b04ee6f1e8d8b042a11e14d3ed6d50b1d6fc4a05a0409d91442b4d5905
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" ) { 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,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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "winr"
5
- s.version = "1.0.1"
5
+ s.version = "1.0.3"
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.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve