paraduct 1.0.0.beta3 → 1.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paraduct/colored_label_logger.rb +20 -15
- data/lib/paraduct/runner.rb +10 -4
- data/lib/paraduct/version.rb +1 -1
- data/paraduct.gemspec +0 -1
- data/spec/paraduct/cli_spec.rb +1 -3
- data/spec/paraduct/runner_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -8
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07807e35ce22e33ca717c280bb70742acd00949b
|
4
|
+
data.tar.gz: 302097b3be4e8c2d9aee9eab2e1ecda5b0bebc18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d9a6f52dbad0e290f4880d23e0de5666ab21d65a94bcf8df6c0b1f6faf90f23b0c40a3e82c702d21f7cb59e0ced5e1688975d57d32ba56049c1b13c9288656
|
7
|
+
data.tar.gz: c71d31485ae44b9adcd4fabf260b3af876ed7ebd71382ba458ea488b05a2fcd15eab08a86986ef170e1f7c1c1b4a67846e47d134d7b7658996ea4dc11a2e9c30
|
@@ -3,18 +3,7 @@ module Paraduct
|
|
3
3
|
def initialize(label_name, logdev = STDOUT)
|
4
4
|
super(logdev)
|
5
5
|
color = Paraduct::ColoredLabelLogger.next_color
|
6
|
-
@
|
7
|
-
@formatter = ActiveSupport::Logger::SimpleFormatter.new
|
8
|
-
end
|
9
|
-
|
10
|
-
SEVERITIES = [:debug, :info, :warn, :error, :fatal]
|
11
|
-
SEVERITIES.each do |severity|
|
12
|
-
define_method "#{severity}_with_label" do |message|
|
13
|
-
message.each_line do |line|
|
14
|
-
send "#{severity}_without_label", "#{@label} #{line.strip}" unless line.blank?
|
15
|
-
end
|
16
|
-
end
|
17
|
-
alias_method_chain severity, :label
|
6
|
+
@formatter = Formatter.new(label_name, color)
|
18
7
|
end
|
19
8
|
|
20
9
|
COLORS = [
|
@@ -33,9 +22,25 @@ module Paraduct
|
|
33
22
|
:light_blue,
|
34
23
|
]
|
35
24
|
def self.next_color
|
36
|
-
|
37
|
-
|
38
|
-
COLORS[
|
25
|
+
@color_index ||= -1
|
26
|
+
@color_index = (@color_index + 1) % COLORS.length
|
27
|
+
COLORS[@color_index]
|
28
|
+
end
|
29
|
+
|
30
|
+
class Formatter
|
31
|
+
def initialize(label_name, color)
|
32
|
+
@label = "[#{label_name.to_s.colorize(color)}]"
|
33
|
+
end
|
34
|
+
|
35
|
+
def call(severity, datetime, progname, message)
|
36
|
+
return "" if message.blank?
|
37
|
+
|
38
|
+
content = ""
|
39
|
+
message.each_line do |line|
|
40
|
+
content << "#{datetime} #{@label} #{line.strip}\n"
|
41
|
+
end
|
42
|
+
content
|
43
|
+
end
|
39
44
|
end
|
40
45
|
end
|
41
46
|
end
|
data/lib/paraduct/runner.rb
CHANGED
@@ -48,7 +48,7 @@ module Paraduct
|
|
48
48
|
|
49
49
|
def logger
|
50
50
|
unless @logger
|
51
|
-
stdout_logger = Paraduct::ColoredLabelLogger.new(
|
51
|
+
stdout_logger = Paraduct::ColoredLabelLogger.new(formatted_params)
|
52
52
|
file_logger = Logger.new(Pathname(@base_job_dir).join("#{job_name}.log"))
|
53
53
|
@logger = stdout_logger.extend(ActiveSupport::Logger.broadcast(file_logger))
|
54
54
|
end
|
@@ -60,8 +60,12 @@ module Paraduct
|
|
60
60
|
|
61
61
|
def run_command(command)
|
62
62
|
full_stdout = ""
|
63
|
+
exit_status = nil
|
64
|
+
|
65
|
+
PTY.spawn(command) do |stdin, stdout, pid|
|
66
|
+
stdout.close_write
|
67
|
+
stdin.sync = true
|
63
68
|
|
64
|
-
PTY.spawn(command) do |stdin, _stdout, pid|
|
65
69
|
begin
|
66
70
|
stdin.each do |line|
|
67
71
|
line.strip!
|
@@ -69,11 +73,13 @@ module Paraduct
|
|
69
73
|
full_stdout << "#{line}\n"
|
70
74
|
end
|
71
75
|
rescue Errno::EIO
|
76
|
+
ensure
|
77
|
+
_, exit_status = Process.waitpid2(pid)
|
72
78
|
end
|
73
|
-
exit_status = PTY.check(pid)
|
74
|
-
raise Paraduct::Errors::ProcessError.new(full_stdout, exit_status) if exit_status && !exit_status.success?
|
75
79
|
end
|
76
80
|
|
81
|
+
raise Paraduct::Errors::ProcessError.new(full_stdout, exit_status) unless exit_status.success?
|
82
|
+
|
77
83
|
full_stdout
|
78
84
|
end
|
79
85
|
end
|
data/lib/paraduct/version.rb
CHANGED
data/paraduct.gemspec
CHANGED
@@ -33,7 +33,6 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "rspec", "~> 3.4"
|
34
34
|
spec.add_development_dependency "rspec-collection_matchers"
|
35
35
|
spec.add_development_dependency "rspec-its"
|
36
|
-
spec.add_development_dependency "rspec-retry"
|
37
36
|
spec.add_development_dependency "rspec-temp_dir"
|
38
37
|
spec.add_development_dependency "yard"
|
39
38
|
|
data/spec/paraduct/cli_spec.rb
CHANGED
@@ -65,9 +65,7 @@ describe Paraduct::CLI do
|
|
65
65
|
}
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
69
|
-
expect { subject }.to raise_error Paraduct::Errors::TestFailureError
|
70
|
-
end
|
68
|
+
it { expect { subject }.to raise_error Paraduct::Errors::TestFailureError }
|
71
69
|
end
|
72
70
|
end
|
73
71
|
|
data/spec/spec_helper.rb
CHANGED
@@ -21,7 +21,6 @@ require 'paraduct/cli'
|
|
21
21
|
require 'rspec/collection_matchers'
|
22
22
|
require 'rspec/temp_dir'
|
23
23
|
require 'rspec/its'
|
24
|
-
require 'rspec/retry'
|
25
24
|
require 'pry'
|
26
25
|
|
27
26
|
is_verbose = ENV["VERBOSE"].present?
|
@@ -32,11 +31,6 @@ end
|
|
32
31
|
|
33
32
|
Dir["#{spec_dir}/support/**/*.rb"].sort.each { |f| require f }
|
34
33
|
|
35
|
-
# rspec-retry option
|
36
|
-
def with_retry
|
37
|
-
{retry: 3, retry_wait: 10}
|
38
|
-
end
|
39
|
-
|
40
34
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
41
35
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
42
36
|
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
@@ -128,8 +122,6 @@ RSpec.configure do |config|
|
|
128
122
|
|
129
123
|
config.order = :random
|
130
124
|
|
131
|
-
config.verbose_retry = true
|
132
|
-
|
133
125
|
config.before do
|
134
126
|
unless is_verbose
|
135
127
|
# quiet all logs
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paraduct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
@@ -206,20 +206,6 @@ dependencies:
|
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
|
-
- !ruby/object:Gem::Dependency
|
210
|
-
name: rspec-retry
|
211
|
-
requirement: !ruby/object:Gem::Requirement
|
212
|
-
requirements:
|
213
|
-
- - ">="
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
version: '0'
|
216
|
-
type: :development
|
217
|
-
prerelease: false
|
218
|
-
version_requirements: !ruby/object:Gem::Requirement
|
219
|
-
requirements:
|
220
|
-
- - ">="
|
221
|
-
- !ruby/object:Gem::Version
|
222
|
-
version: '0'
|
223
209
|
- !ruby/object:Gem::Dependency
|
224
210
|
name: rspec-temp_dir
|
225
211
|
requirement: !ruby/object:Gem::Requirement
|