enparallel-bin 1.0.9 → 1.0.10

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: aa11fab5b6771b73408f872db594cdd1db8a7df8758cd22e6e7611819225ad55
4
- data.tar.gz: 3f4bc0eaf3b46d3cb0427dda7e1136c3e6cc2863a181fa396fbb7c69ca3ca194
3
+ metadata.gz: 41b497f7ab752ec2100b78f0966c191277afa65f1d645482697d38eb4d13e28d
4
+ data.tar.gz: ce25b5ec3b39bc60ff067e235eacb192f31666ce8f3d49943be0c8647868ffdc
5
5
  SHA512:
6
- metadata.gz: df2f7bdb08f490f9c694a5885fa8b4e1c86c674407b1133b26a541442c6368e034058bebf41dda9f8073c6874dc5ca676881ad1c35fd6294e2b2665e9ab891b3
7
- data.tar.gz: b4944ff7abd1b54f734958dba5a5686061de55d0b427dae22d48351dedb8b883beca1e341d45e774158fbfd09505f7bcfcea522a0cc0fd04cba611aad64eb692
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
93
+ rescue Docopt::Exit
94
94
  puts CLI.usage
95
95
  exit 2
96
96
  end
@@ -14,7 +14,7 @@ module Enparallel
14
14
  end
15
15
 
16
16
  def self.parse(argv, stdin)
17
- opts = Docopt::docopt(usage, argv: argv)
17
+ opts = Docopt.docopt(usage, argv: argv)
18
18
 
19
19
  if opts['--version']
20
20
  puts VERSION
@@ -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.9"
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.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - crdx
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-05 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: '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:
@@ -138,7 +138,7 @@ 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
  - - ">="