fasten 0.12.2 → 0.12.4

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: 98294547cda428694c3da8c745f163bb4d860e419cee64320d28b5b1178f1682
4
- data.tar.gz: 23a8699f322f4cdf27beb1c0410a5443b12f294af6477ad6c45626d89b820aa9
3
+ metadata.gz: 3529d50d7d2bc28cb85f1c41828504cf602b8b04b066e7a3ab11ec2102c6aee0
4
+ data.tar.gz: f68633c37fc30cded6460bf7093ca010d6d214f4d04ed592bc938e078eb8a1b0
5
5
  SHA512:
6
- metadata.gz: ee1b5d66b598ac66fe9a1c545ceeecec027ec5dd658f58443213006ef5599a4189f51a8e8d622585578de412a5be320e36cefd9f49921d55a5cdb9725922c902
7
- data.tar.gz: 28b0d3e51510ae91e43666480852c7811832b30aaefebd911a170f4281b2fa233f0891ac7cfc1fda6234d531806c30ca6d4f01913f5d994b86ec094e9890a8cd
6
+ metadata.gz: 7d7afa32077b61a6c4d2f14966eee04925bab79b63e4fb297ab64426aabf74def1e7e67ce48c35d58e6d5e883ca112e73d7b37d616c338a4b7d11d618df30919
7
+ data.tar.gz: 2b662abc55dc8f6a3248e4b67959c52240b6f27635719295b87dfb794e7d40f8c4573716137ea22a01f7b9076dcdc79c515d9b326692a72bd4696026278f3c18
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fasten (0.12.2)
4
+ fasten (0.12.4)
5
5
  binding_of_caller
6
6
  hirb
7
7
  os
@@ -43,5 +43,9 @@ module Fasten
43
43
  def default_developer
44
44
  STDIN.tty? && STDOUT.tty?
45
45
  end
46
+
47
+ def default_priority
48
+ :dependants
49
+ end
46
50
  end
47
51
  end
data/lib/fasten/runner.rb CHANGED
@@ -18,21 +18,21 @@ module Fasten
18
18
  include Fasten::Support::UI
19
19
  include Fasten::Support::Yaml
20
20
 
21
- attr_accessor :name, :stats, :summary, :jobs, :worker_class, :fasten_dir, :use_threads, :ui_mode, :developer, :workers, :queue, :tasks
21
+ attr_accessor :name, :stats, :summary, :jobs, :worker_class, :fasten_dir, :use_threads, :ui_mode, :developer, :workers, :queue, :tasks, :priority
22
22
 
23
23
  def initialize(**options)
24
- %i[name stats summary jobs worker_class fasten_dir use_threads ui_mode developer].each do |key|
24
+ %i[name stats summary jobs worker_class fasten_dir use_threads ui_mode developer priority].each do |key|
25
25
  options[key] = Fasten.send "default_#{key}" unless options.key? key
26
26
  end
27
27
 
28
- @tasks = TaskManager.new(targets: options[:targets] || [])
28
+ @tasks = TaskManager.new(targets: options[:targets] || [], runner: self)
29
29
  @workers = []
30
30
 
31
31
  reconfigure(options)
32
32
  end
33
33
 
34
34
  def reconfigure(**options)
35
- %i[name stats summary jobs worker_class fasten_dir use_threads ui_mode developer].each do |key|
35
+ %i[name stats summary jobs worker_class fasten_dir use_threads ui_mode developer priority].each do |key|
36
36
  send "#{key}=", options[key] if options.key? key
37
37
  end
38
38
 
@@ -1,8 +1,8 @@
1
1
  module Fasten
2
2
  class TaskManager < Array # rubocop:disable Metrics/ClassLength
3
- attr_reader :done, :failed, :pending, :running, :targets
3
+ attr_reader :done, :failed, :pending, :running, :targets, :runner
4
4
 
5
- def initialize(targets: [])
5
+ def initialize(targets: [], runner:)
6
6
  super()
7
7
 
8
8
  @map = {}
@@ -12,6 +12,7 @@ module Fasten
12
12
  @running = []
13
13
  @targets = targets
14
14
  @waiting = nil
15
+ @runner = runner
15
16
  end
16
17
 
17
18
  def push(*items)
@@ -149,10 +150,20 @@ module Fasten
149
150
 
150
151
  @pending -= to_move
151
152
  @waiting += to_move
152
- @waiting.sort_by!.with_index do |task, index|
153
- task.state = :WAIT
154
- last_avg = task.last && task.last['avg'] || 0
155
- [-task.run_score, -last_avg.to_f, index]
153
+ case @runner.priority
154
+ when :dependants
155
+ @waiting.sort_by!.with_index do |task, index|
156
+ task.state = :WAIT
157
+ [-task.run_score, index]
158
+ end
159
+ when :dependants_avg
160
+ @waiting.sort_by!.with_index do |task, index|
161
+ task.state = :WAIT
162
+ last_avg = task.last && task.last['avg'] || 0
163
+ [-task.run_score, -last_avg.to_f, index]
164
+ end
165
+ else
166
+ raise "Unknown priority #{@runner.priority}"
156
167
  end
157
168
  end
158
169
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fasten
4
- VERSION = '0.12.2'
4
+ VERSION = '0.12.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fasten
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldrin Martoq