fasten 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile.lock +11 -9
- data/exe/fasten +5 -0
- data/fasten.gemspec +4 -2
- data/lib/fasten.rb +86 -31
- data/lib/fasten/{executor.rb → runner.rb} +102 -28
- data/lib/fasten/std_thread_proxy.rb +56 -0
- data/lib/fasten/support/dag.rb +130 -0
- data/lib/fasten/support/fork_worker.rb +107 -0
- data/lib/fasten/support/logger.rb +57 -0
- data/lib/fasten/support/state.rb +32 -0
- data/lib/fasten/support/stats.rb +137 -0
- data/lib/fasten/support/thread_worker.rb +61 -0
- data/lib/fasten/support/ui.rb +22 -0
- data/lib/fasten/support/yaml.rb +54 -0
- data/lib/fasten/task.rb +16 -7
- data/lib/fasten/timeout_queue.rb +36 -0
- data/lib/fasten/ui/console.rb +7 -7
- data/lib/fasten/ui/curses.rb +26 -22
- data/lib/fasten/version.rb +1 -1
- data/lib/fasten/worker.rb +48 -81
- metadata +34 -14
- data/lib/fasten/dag.rb +0 -137
- data/lib/fasten/logger.rb +0 -62
- data/lib/fasten/state.rb +0 -30
- data/lib/fasten/stats.rb +0 -137
- data/lib/fasten/ui.rb +0 -18
- data/lib/fasten/yaml.rb +0 -48
data/lib/fasten/ui.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'fasten/ui/console'
|
2
|
-
require 'fasten/ui/curses'
|
3
|
-
|
4
|
-
module Fasten
|
5
|
-
module UI
|
6
|
-
def ui
|
7
|
-
@ui ||= STDIN.tty? && STDOUT.tty? ? Fasten::UI::Curses.new(executor: self) : Fasten::UI::Console.new(executor: self)
|
8
|
-
end
|
9
|
-
|
10
|
-
def run_ui
|
11
|
-
ui.update
|
12
|
-
|
13
|
-
yield
|
14
|
-
ensure
|
15
|
-
ui.cleanup
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/fasten/yaml.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
module Fasten
|
2
|
-
module Yaml
|
3
|
-
def transform_params(params)
|
4
|
-
params.keys.each do |k|
|
5
|
-
val = params[k]
|
6
|
-
|
7
|
-
if val.is_a?(String) && (match = %r{^/(.+)/$}.match(val))
|
8
|
-
val = Regexp.new(match[1])
|
9
|
-
end
|
10
|
-
|
11
|
-
params[k.to_sym] = val
|
12
|
-
params.delete(k)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def load_yaml(path)
|
17
|
-
items = YAML.safe_load(File.read(path)).each do |name, params|
|
18
|
-
if params.is_a? String
|
19
|
-
params = { after: params }
|
20
|
-
elsif params.is_a? Hash
|
21
|
-
transform_params(params)
|
22
|
-
else
|
23
|
-
params = {}
|
24
|
-
end
|
25
|
-
|
26
|
-
add Fasten::Task.new({ name: name }.merge(params))
|
27
|
-
end
|
28
|
-
|
29
|
-
log_info "Loaded #{items.count} tasks from #{path}"
|
30
|
-
end
|
31
|
-
|
32
|
-
def save_yaml(path)
|
33
|
-
keys = %i[after shell]
|
34
|
-
|
35
|
-
items = task_list.map do |task|
|
36
|
-
data = task.to_h.select do |key, _val|
|
37
|
-
keys.include? key
|
38
|
-
end
|
39
|
-
|
40
|
-
[task.name, data]
|
41
|
-
end.to_h
|
42
|
-
|
43
|
-
File.write path, items.to_yaml
|
44
|
-
|
45
|
-
log_info "Loaded #{items.count} tasks into #{path}"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|