fasten 0.12.4 → 0.12.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3529d50d7d2bc28cb85f1c41828504cf602b8b04b066e7a3ab11ec2102c6aee0
4
- data.tar.gz: f68633c37fc30cded6460bf7093ca010d6d214f4d04ed592bc938e078eb8a1b0
3
+ metadata.gz: ccba14b261264ae79b9144b3de97610d2499763baab8e03eb5b0cf049c179925
4
+ data.tar.gz: 2b611452336f62c2de1f48625870ab5dd53589867e609300eedcc4638114ea15
5
5
  SHA512:
6
- metadata.gz: 7d7afa32077b61a6c4d2f14966eee04925bab79b63e4fb297ab64426aabf74def1e7e67ce48c35d58e6d5e883ca112e73d7b37d616c338a4b7d11d618df30919
7
- data.tar.gz: 2b662abc55dc8f6a3248e4b67959c52240b6f27635719295b87dfb794e7d40f8c4573716137ea22a01f7b9076dcdc79c515d9b326692a72bd4696026278f3c18
6
+ metadata.gz: c139aad75f9abb28ea50a34fe78b166819cf4ae7c125fe9ee6b9f1beec410a2ebbbbad6fdc1a1ff3a52f1cc6f3c85aa239e0274ee4caef66db58741fb846f0ad
7
+ data.tar.gz: 216a6776f631a1d8d1d9526ae6408978c722fc36a13982151ba6ac7c3050344a892a6f5844b784402add158b33592c0b6fba555cfabd60273a03d8dd7aa9e37f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fasten (0.12.4)
4
+ fasten (0.12.6)
5
5
  binding_of_caller
6
6
  hirb
7
7
  os
@@ -1,7 +1,7 @@
1
1
  module Fasten
2
2
  module Support
3
3
  module State
4
- attr_accessor :error, :ini, :fin, :dif, :last
4
+ attr_accessor :error, :ini, :fin, :dif, :runner
5
5
  attr_writer :state
6
6
 
7
7
  def state
@@ -27,6 +27,22 @@ module Fasten
27
27
  def quitting?
28
28
  state == :QUITTING
29
29
  end
30
+
31
+ def last
32
+ return @last if defined? @last
33
+
34
+ return {} unless @runner
35
+
36
+ @last = runner.stats_last(self)
37
+ end
38
+
39
+ def last_avg
40
+ @last_avg ||= last['avg']&.to_f
41
+ end
42
+
43
+ def last_err
44
+ @last_err ||= last['err']&.to_f
45
+ end
30
46
  end
31
47
  end
32
48
  end
@@ -26,8 +26,11 @@ module Fasten
26
26
  end
27
27
 
28
28
  @tasks.each do |task|
29
- stats_last(task)
29
+ task.runner = self
30
+ task.last
30
31
  end
32
+ self.runner = self
33
+ last
31
34
 
32
35
  @tasks.waiting = nil
33
36
  rescue StandardError
@@ -125,9 +128,7 @@ module Fasten
125
128
  end
126
129
 
127
130
  def stats_last(item)
128
- return item.last if item.last
129
-
130
- item.last = stats_data.select { |e| e['kind'] == item.kind && e['name'] == item.name }.last || {}
131
+ stats_data.select { |e| e['kind'] == item.kind && e['name'] == item.name }.last || {}
131
132
  end
132
133
 
133
134
  def update_stats(history, entry)
@@ -159,7 +159,7 @@ module Fasten
159
159
  when :dependants_avg
160
160
  @waiting.sort_by!.with_index do |task, index|
161
161
  task.state = :WAIT
162
- last_avg = task.last && task.last['avg'] || 0
162
+ last_avg = task.last_avg || 0
163
163
  [-task.run_score, -last_avg.to_f, index]
164
164
  end
165
165
  else
@@ -16,6 +16,8 @@ module Fasten
16
16
 
17
17
  SPINNER_STR = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
18
18
  SPINNER_LEN = SPINNER_STR.length
19
+ MOON_STR = '🌑🌒🌓🌔🌕'
20
+ MOON_LEN = MOON_STR.length
19
21
  PROGRESSBAR_STR = ' ▏▎▍▌▋▊▉'
20
22
  PROGRESSBAR_LEN = PROGRESSBAR_STR.length
21
23
 
@@ -194,6 +196,22 @@ module Fasten
194
196
  end
195
197
  end
196
198
 
199
+ def ui_task_clock(task, cur, avg)
200
+ return unless task.ini
201
+
202
+ dif = cur - task.ini
203
+ avg = avg.to_f
204
+ if task.ini && avg.positive?
205
+ percent = dif / avg
206
+ index = (percent * MOON_LEN).to_i
207
+ index = MOON_LEN - 1 if index > MOON_LEN - 1
208
+
209
+ format ' %.2f s %s ', dif, MOON_STR[index]
210
+ else
211
+ format ' %.2f s ', dif
212
+ end
213
+ end
214
+
197
215
  def ui_task_color(task)
198
216
  rev = task == selected ? A_REVERSE : 0
199
217
 
@@ -219,6 +237,9 @@ module Fasten
219
237
 
220
238
  str ||= icon ? "#{icon} #{task}" : task.to_s
221
239
 
240
+ delta = x + str.length - n_cols
241
+ str = str[0...-delta] if delta.positive?
242
+
222
243
  attrset attrs if attrs
223
244
  addstr str
224
245
  attroff attrs if attrs
@@ -231,14 +252,38 @@ module Fasten
231
252
  worker.spinner = (worker.spinner + 1) % SPINNER_LEN if worker.running?
232
253
  end
233
254
 
255
+ cur = Time.new
256
+
234
257
  count_done = tasks.done.count
235
258
  count_total = tasks.count
236
259
  tl = count_total.to_s.length
237
- col_ini = ui_text_aligned(2, :left, format("Tasks %#{tl}d/%d", count_done, count_total)) + 1
238
- col_fin = n_cols - 5
239
- ui_text_aligned(2, :right, "#{(count_done * 100 / count_total).to_i}%") if count_total.positive?
260
+ percentstr = count_total.positive? && " #{(count_done * 100 / count_total).to_i}%"
261
+ elapsed_str = format ' %.2f s', (dif = cur - runner.ini) if runner.ini
262
+
263
+ @stat_str ||= begin
264
+ @runner_last_avg = runner.last_avg
265
+ if runner.last_avg && runner.last_err
266
+ format '≈ %.2f s ± %.2f', runner.last_avg, runner.last_err
267
+ elsif runner.last_avg
268
+ format '≈ %.2f s', runner.last_avg
269
+ end
270
+ end
271
+
272
+ end_str = [elapsed_str, @stat_str].compact.join(' ')
273
+
274
+ if @runner_last_avg
275
+ a = dif
276
+ b = @runner_last_avg
277
+ else
278
+ a = count_done
279
+ b = count_total
280
+ end
281
+
282
+ col_ini = ui_text_aligned(2, :left, format("Tasks %#{tl}d/%d%s", count_done, count_total, percentstr)) + 1
283
+ col_fin = n_cols - 1 - end_str.length
284
+ ui_text_aligned(2, :right, end_str)
240
285
 
241
- ui_progressbar(2, col_ini, col_fin, count_done, count_total)
286
+ ui_progressbar(2, col_ini, col_fin, a, b)
242
287
 
243
288
  max = 2
244
289
  list = tasks.sort_by.with_index { |x, index| [x.run_score, index] }
@@ -260,13 +305,16 @@ module Fasten
260
305
  end
261
306
  else
262
307
  x = max + 1
263
- last = runner.stats_last(task)
308
+ last_avg = task.last_avg
309
+ last_err = task.last_err
264
310
  if task.dif
265
311
  str = format ' %.2f s', task.dif
266
- elsif last['avg'] && last['err']
267
- str = format '≈ %.2f s ± %.2f %s', last['avg'], last['err'], task.worker&.name
268
- elsif last['avg']
269
- str = format '≈ %.2f s %s', last['avg'], task.worker&.name
312
+ elsif last_avg && last_err
313
+ str = format '%s ≈ %.2f s ± %.2f %s', ui_task_clock(task, cur, last_avg), last_avg, last_err, task.worker&.name
314
+ elsif last_avg
315
+ str = format '%s ≈ %.2f s %s', ui_task_clock(task, cur, last_avg), last_avg, task.worker&.name
316
+ else
317
+ str = ui_task_clock(task, cur, 0)
270
318
  end
271
319
  ui_task_string(task, 3 + index, x, str: str) if str
272
320
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fasten
4
- VERSION = '0.12.4'
4
+ VERSION = '0.12.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fasten
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldrin Martoq
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-06 00:00:00.000000000 Z
11
+ date: 2019-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler