enparallel-bin 1.0.6 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f562c7ba4e17d34abebcd1812747eae69d0effa6d3e96b5b5d3eee036be0021
4
- data.tar.gz: e7467eb70cf31214277c759694633b356c825bd34b0f81ad7615f0319f070c5e
3
+ metadata.gz: 41b497f7ab752ec2100b78f0966c191277afa65f1d645482697d38eb4d13e28d
4
+ data.tar.gz: ce25b5ec3b39bc60ff067e235eacb192f31666ce8f3d49943be0c8647868ffdc
5
5
  SHA512:
6
- metadata.gz: 00330b626b14acb8016d7d80d5208c3730c86943d94d1cca7cda885f76cd3e61d2f601b292ee329b1b165e610170161be02e09e0e4fafd2b89e851bdfa60c780
7
- data.tar.gz: 81c9795b5a50b6493f850893e6ee0eca75b287d9e1cea07e82762c0d07826bd236c3cc06240139b7dd0b6b0482d20dee85b20cb4b185675405b9fff0988d1717
6
+ metadata.gz: 760618db0069de59d547f04c08aafd8564ae6a9b20f767d635b888ec798e8685e966dd1122e04cc895bb65863b8179c458b97c18b6850cad29c2c55acbdc3407
7
+ data.tar.gz: 597fae7122f8bf27884df72b8c57c8464fb05cab168be927b2859e40d48c8092d66a8488e3bf90e6e5dd533bd76ece5a8102e5599bfea18881dba6948c396e94
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.6"
2
+ VERSION = '1.0.10'
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.6
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - crdx
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-20 00:00:00.000000000 Z
11
+ date: 2021-10-12 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: '2.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: '2.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.17.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.17.0
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -95,21 +95,21 @@ 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: '12.3'
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: '12.3'
111
- description:
112
- email:
110
+ version: 0.21.0
111
+ description:
112
+ email:
113
113
  executables:
114
114
  - enparallel
115
115
  extensions: []
@@ -130,7 +130,7 @@ homepage: https://github.com/crdx/enparallel
130
130
  licenses:
131
131
  - MIT
132
132
  metadata: {}
133
- post_install_message:
133
+ post_install_message:
134
134
  rdoc_options: []
135
135
  require_paths:
136
136
  - lib
@@ -138,15 +138,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
139
  - - ">="
140
140
  - !ruby/object:Gem::Version
141
- version: '0'
141
+ version: '3.0'
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ">="
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.0.6
149
- signing_key:
148
+ rubygems_version: 3.2.21
149
+ signing_key:
150
150
  specification_version: 4
151
- summary: Run many commands enparallel with a colourful overview
151
+ summary: Parallel command runner with a colourful overview
152
152
  test_files: []