dorian-parallel 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/parallel +55 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d1026eb608608275afad69ed61552b3a613eee94528c6fbb64326b428e15306
|
4
|
+
data.tar.gz: 170227b6cd9852bd7f658a9b6b43bb907b4c22373e3104726056e68793ba8b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4de31b833bd11afbc6cc06422e345029c4510d1c93cbdcc78a4b22714843ab336ac1c26346a36191245d78961b79a3025377f2b7fa55cf873913a9752c7b818
|
7
|
+
data.tar.gz: 83d715df1dba961a765240f00d734a13384989d8e62bae2af4f2475dd919ff1f230fc9998af6e7fb02b2a00f894bf788cc365e0c0bd24d5f26ef2beac4a9fd11
|
data/bin/parallel
CHANGED
@@ -2,9 +2,45 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "dorian/arguments"
|
5
|
+
require "dorian/eval"
|
6
|
+
require "dorian/progress"
|
5
7
|
require "parallel"
|
6
8
|
|
7
|
-
parsed =
|
9
|
+
parsed =
|
10
|
+
Dorian::Arguments.parse(
|
11
|
+
debug: {
|
12
|
+
alias: :d
|
13
|
+
},
|
14
|
+
stdout: {
|
15
|
+
aliases: %i[out o],
|
16
|
+
default: true
|
17
|
+
},
|
18
|
+
stderr: {
|
19
|
+
aliases: %i[err e],
|
20
|
+
default: true
|
21
|
+
},
|
22
|
+
colorize: {
|
23
|
+
aliases: %i[color c],
|
24
|
+
default: true
|
25
|
+
},
|
26
|
+
progress: {
|
27
|
+
alias: :p
|
28
|
+
},
|
29
|
+
progress_format: {
|
30
|
+
type: :string,
|
31
|
+
alias: :pf,
|
32
|
+
default: "full"
|
33
|
+
},
|
34
|
+
rails: {
|
35
|
+
alias: :r
|
36
|
+
},
|
37
|
+
version: {
|
38
|
+
alias: :v
|
39
|
+
},
|
40
|
+
help: {
|
41
|
+
alias: :h
|
42
|
+
}
|
43
|
+
)
|
8
44
|
|
9
45
|
abort parsed.help if parsed.options.help
|
10
46
|
|
@@ -14,6 +50,22 @@ end
|
|
14
50
|
|
15
51
|
input = parsed.files.map { |file| File.read(file) }.join("\n")
|
16
52
|
input = $stdin.each_line.to_a.map(&:strip).join("\n") if input.empty?
|
17
|
-
|
18
|
-
|
53
|
+
inputs = input.lines.map(&:strip)
|
54
|
+
ruby = parsed.arguments.join(" ")
|
55
|
+
debug = parsed.options.debug
|
56
|
+
stdout = parsed.options.stdout && !parsed.options.progress
|
57
|
+
stderr = parsed.options.stderr && !parsed.options.progress
|
58
|
+
colorize = parsed.options.colorize
|
59
|
+
total = inputs.size
|
60
|
+
format = parsed.options.progress_format
|
61
|
+
|
62
|
+
if parsed.options.progress
|
63
|
+
progress = Dorian::Progress.create(total:, format:)
|
64
|
+
else
|
65
|
+
progress = nil
|
66
|
+
end
|
67
|
+
|
68
|
+
Parallel.each(inputs) do |it|
|
69
|
+
Dorian::Eval.eval(it:, ruby:, debug:, stdout:, stderr:, colorize:)
|
70
|
+
progress&.increment
|
19
71
|
end
|