enparallel-bin 1.0.7 → 1.0.11

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: 8081d1e4fe2054ccd7f26ff9241d43a77361c8bc635f8d28cfb1ab171978ad44
4
- data.tar.gz: a4f66a8a980602ae080878f07bf702086a607ceb64bf9a9adc0bd27a91fedb2b
3
+ metadata.gz: dc0fa02d388e6a1c42c1dfeac34be7deab2644db290e57ed24104015df598e76
4
+ data.tar.gz: 188617934c9522e84bd46a7d12d968c1df88c9440d5eed4acb40ef112fb9ff0d
5
5
  SHA512:
6
- metadata.gz: a474109ce87481792143ce537b074e06b1d0056c98daf1253425b2938c57df45d7f370ad2f6786afde0e2c9e4ed0381b6e9dcd077beb2add4458a12be346f2ca
7
- data.tar.gz: 66d84b2998e91022f2a385da33798d3f89f683e526e29459d9919054d4caf2d53b6484104422c4ecf61e3cd2582dd85455c402ff2b2dbb8e6256bcc7d9b9e464
6
+ metadata.gz: 2a70d53f12e64406cfa7e819d26b265bfa5029bb75a6caa30c15ef3dcaca80f15e0dd30ef5041e6110cb74dc1a82789bc7f244e1ee4a1b3784642a91dcf25190
7
+ data.tar.gz: 4fa9c460d93cae10b379e7f2c5276af73c20902a0425b65fc045b7735348093448d4f9529d4cb70024d97f7146a383c61bd38ac66e1761592374a2d1b44a39d4
data/bin/enparallel CHANGED
@@ -4,7 +4,7 @@ include Enparallel
4
4
 
5
5
  class Main
6
6
  def self.run
7
- cli = CLI.parse(ARGV, STDIN)
7
+ cli = CLI.parse(ARGV, $stdin)
8
8
  tasks = cli.inputs.map { |input| Task.new(cli.command, input) }
9
9
  pool = ThreadPool.new(tasks, cli.workers, cli.pick)
10
10
  new(pool).run
@@ -35,7 +35,7 @@ class Main
35
35
 
36
36
  def finish
37
37
  puts
38
- puts "Tasks complete"
38
+ puts 'Tasks complete'
39
39
  puts
40
40
  puts "#{@pool.succeeded_tasks.length.to_s.green.bold} tasks succeeded"
41
41
  puts "#{@pool.failed_tasks.length.to_s.red.bold} tasks failed"
@@ -52,7 +52,7 @@ class Main
52
52
 
53
53
  def render
54
54
  print "\r" + @pool.render
55
- sleep 0.1
55
+ sleep(0.1)
56
56
  end
57
57
 
58
58
  def all_paths_available(paths)
@@ -83,14 +83,14 @@ class Main
83
83
  log_groups.each do |log_group|
84
84
  type = log_group.type
85
85
  path = paths[type]
86
- puts 'Written %s log: %s (%s)' % [type, *log_group.write(path)]
86
+ puts 'Written %s log: %s (%s)' % [type, path, log_group.write(path)]
87
87
  end
88
88
  end
89
89
  end
90
90
 
91
91
  begin
92
92
  Main.run
93
- rescue Docopt::Exit => e
94
- puts e.message
95
- exit 1
93
+ rescue Docopt::Exit
94
+ puts CLI.usage
95
+ exit 2
96
96
  end
@@ -14,7 +14,14 @@ module Enparallel
14
14
  end
15
15
 
16
16
  def self.parse(argv, stdin)
17
- new(Docopt::docopt(usage, argv: argv, version: VERSION), stdin)
17
+ opts = Docopt.docopt(usage, argv: argv)
18
+
19
+ if opts['--version']
20
+ puts VERSION
21
+ exit
22
+ end
23
+
24
+ new(opts, stdin)
18
25
  end
19
26
 
20
27
  def self.basename
@@ -23,10 +30,11 @@ module Enparallel
23
30
 
24
31
  def self.usage
25
32
  <<~EOF
26
- #{'Usage:'.bold}
33
+ Usage:
27
34
  #{basename} [options] [--] <command>...
35
+ #{basename} ( --version | --help )
28
36
 
29
- #{'Description:'.bold}
37
+ Description:
30
38
  #{basename} operates by reading lines from standard input, and executing
31
39
  <command> once per entry, in parallel.
32
40
 
@@ -41,13 +49,13 @@ module Enparallel
41
49
 
42
50
  seq 1 10 | enparallel -- bash -c "sleep {} && echo Slept for {}"
43
51
 
44
- #{'Options:'.bold}
52
+ Options:
45
53
  -w, --workers <n> Batch into a pool of <n> workers [default: #{workers_default}].
46
54
  -p, --pick <type> Task-picking rule (see "Types") [default: #{pick_default}].
47
55
  -v, --version Version.
48
56
  -h, --help Help.
49
57
 
50
- #{'Types:'.bold}
58
+ Types:
51
59
  sequential The order in which the tasks were queued.
52
60
  random Random order.
53
61
  EOF
@@ -1,6 +1,7 @@
1
1
  module Enparallel
2
2
  class LogGroup
3
- attr_reader :type, :tasks
3
+ attr_reader :type
4
+ attr_reader :tasks
4
5
 
5
6
  def initialize(type, tasks)
6
7
  @type = type
@@ -11,13 +12,13 @@ module Enparallel
11
12
  tasks.join("\n\n") + "\n"
12
13
  end
13
14
 
14
- def has_tasks?
15
+ def tasks?
15
16
  tasks.length > 0
16
17
  end
17
18
 
18
19
  def write(path)
19
20
  size = File.write(path, to_soml)
20
- [path, Util.bytes_to_human(size)]
21
+ Util.bytes_to_human(size)
21
22
  end
22
23
 
23
24
  def self.of(type, pool)
@@ -13,7 +13,7 @@ module Enparallel
13
13
  end
14
14
 
15
15
  def get_log_groups
16
- get_all_log_groups.select(&:has_tasks?)
16
+ get_all_log_groups.select(&:tasks?)
17
17
  end
18
18
  end
19
19
  end
@@ -30,7 +30,7 @@ module Enparallel
30
30
  'R'
31
31
  elsif @exit_status.nil?
32
32
  'S'
33
- elsif has_succeeded?
33
+ elsif succeeded?
34
34
  'D'.green
35
35
  else
36
36
  'F'.red
@@ -41,7 +41,7 @@ module Enparallel
41
41
  @running = true
42
42
  @ran_at = Time.now
43
43
 
44
- Open3.popen3(command_line_safe) do |stdin, stdout, stderr, thread|
44
+ Open3.popen3(command_line_safe) do |_stdin, stdout, stderr, thread|
45
45
  @stdout = stdout.read.chomp
46
46
  @stderr = stderr.read.chomp
47
47
  @exit_status = thread.value.exitstatus
@@ -53,8 +53,9 @@ module Enparallel
53
53
  @running = false
54
54
  end
55
55
 
56
- def has_succeeded?
56
+ def succeeded?
57
57
  raise 'Task not resolved' if @ran_at.nil?
58
+
58
59
  @exit_status == 0
59
60
  end
60
61
 
@@ -16,7 +16,7 @@ module Enparallel
16
16
  def drain
17
17
  @workers = @worker_count.times.map do
18
18
  Thread.new do
19
- while task = @picker.next
19
+ while (task = @picker.next)
20
20
  task.run
21
21
  end
22
22
  end
@@ -32,17 +32,18 @@ module Enparallel
32
32
  end
33
33
 
34
34
  def succeeded_tasks
35
- @tasks.select(&:has_succeeded?)
35
+ @tasks.select(&:succeeded?)
36
36
  end
37
37
 
38
38
  def failed_tasks
39
- @tasks.reject(&:has_succeeded?)
39
+ @tasks.reject(&:succeeded?)
40
40
  end
41
41
 
42
42
  def tasks_of(type)
43
- if type == :success
43
+ case type
44
+ when :success
44
45
  succeeded_tasks
45
- elsif type == :failure
46
+ when :failure
46
47
  failed_tasks
47
48
  end
48
49
  end
@@ -1,3 +1,3 @@
1
1
  module Enparallel
2
- VERSION = "1.0.7"
2
+ VERSION = '1.0.11'
3
3
  end
data/lib/enparallel.rb CHANGED
@@ -11,7 +11,7 @@ require 'etc'
11
11
 
12
12
  module Enparallel
13
13
  def self.root_dir
14
- File.expand_path('../..', __FILE__)
14
+ File.expand_path('..', __dir__)
15
15
  end
16
16
  end
17
17
 
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enparallel-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - crdx
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-20 00:00:00.000000000 Z
11
+ date: 2021-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: require_all
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: 0.8.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: 0.8.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: colorize
28
+ name: docopt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.1
33
+ version: 0.6.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.1
40
+ version: 0.6.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: docopt
42
+ name: require_all
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.6.1
47
+ version: '3.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.6.1
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: soml
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.0.1
69
69
  - !ruby/object:Gem::Dependency
70
- name: simplecov
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.21.0
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.21.0
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -95,19 +95,19 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.8'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rake
98
+ name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '13.0'
103
+ version: 0.21.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '13.0'
110
+ version: 0.21.0
111
111
  description:
112
112
  email:
113
113
  executables:
@@ -129,7 +129,8 @@ files:
129
129
  homepage: https://github.com/crdx/enparallel
130
130
  licenses:
131
131
  - MIT
132
- metadata: {}
132
+ metadata:
133
+ rubygems_mfa_required: 'true'
133
134
  post_install_message:
134
135
  rdoc_options: []
135
136
  require_paths:
@@ -138,14 +139,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
139
  requirements:
139
140
  - - ">="
140
141
  - !ruby/object:Gem::Version
141
- version: '0'
142
+ version: '3.0'
142
143
  required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  requirements:
144
145
  - - ">="
145
146
  - !ruby/object:Gem::Version
146
147
  version: '0'
147
148
  requirements: []
148
- rubygems_version: 3.2.21
149
+ rubygems_version: 3.2.29
149
150
  signing_key:
150
151
  specification_version: 4
151
152
  summary: Parallel command runner with a colourful overview