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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/parallel +55 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfba0dfc150be77a2e94518e0fd646854c99a63e7cc827d09ee7b0fb7b4cc184
4
- data.tar.gz: 81097441dc78243c09aa0d3e409673cb9a98503162cac668aa850d378d225d2d
3
+ metadata.gz: 4d1026eb608608275afad69ed61552b3a613eee94528c6fbb64326b428e15306
4
+ data.tar.gz: 170227b6cd9852bd7f658a9b6b43bb907b4c22373e3104726056e68793ba8b8d
5
5
  SHA512:
6
- metadata.gz: b97aae3db16d4e7bf7f8e06f708775ae45dcb5917d7b2d14c359df22104bfd94adc5655023679b6c38dfac98c17b26b8af4e90d1839845c0856c16186ef65c6e
7
- data.tar.gz: e6c1f41262ca9a458ac06a78fd423da13578280c3ef932284d7b6180fd3f663c4781803670481af626b5a22c6a6c6f8206f237bbe3771e4484b3bf3467b268db
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 = Dorian::Arguments.parse(version: { alias: :v }, help: { alias: :h })
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
- Parallel.each(input.lines.map(&:strip)) do |it|
18
- eval(parsed.arguments.join(" "))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié