maestro_shell 0.0.7 → 0.0.8
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 +4 -4
- data/lib/util/shell.rb +20 -20
- data/lib/util/version.rb +1 -1
- data/maestro_shell.gemspec +1 -0
- data/spec/shell_spec.rb +2 -3
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73beca833565d0135c019fb22c69b23ad6c3cbf0
|
4
|
+
data.tar.gz: b33923670ef19d8189a09ec3742f273f17d08fe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4d173a49cf9d44a615b7b170eda5b3e5873ff4ec31db8a0335193fec2d32c220699b85645e6398970fc03182a99ae2d4b968ee47d2bc3f266d9e8b8e5088332
|
7
|
+
data.tar.gz: ccb83f5bc3ffe78f91546cbf5fa3c9843fd4213909eb1be830fec90b3f776720958d046beb2559e8955fdf88e00a99702cce8f2cfa1a24e97dd438f40296c909
|
data/lib/util/shell.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright 2011 (c) MaestroDev. All rights reserved.
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'childprocess'
|
4
4
|
require 'tempfile'
|
5
5
|
require 'rbconfig'
|
6
6
|
|
@@ -17,7 +17,7 @@ module Maestro
|
|
17
17
|
attr_reader :exit_code
|
18
18
|
|
19
19
|
def initialize(status)
|
20
|
-
@exit_code = status
|
20
|
+
@exit_code = status
|
21
21
|
end
|
22
22
|
|
23
23
|
def success?
|
@@ -32,7 +32,7 @@ module Maestro
|
|
32
32
|
ENV_EXPORT_COMMAND = IS_WINDOWS ? 'set' : 'export'
|
33
33
|
COMMAND_SEPARATOR = '&&' # IS_WINDOWS ? '&&' : '&&'
|
34
34
|
SCRIPT_EXTENSION = IS_WINDOWS ? '.bat' : '.shell'
|
35
|
-
|
35
|
+
BASH_EXECUTABLE = 'bash'
|
36
36
|
|
37
37
|
def Shell.unset_env_variable(var)
|
38
38
|
IS_WINDOWS ? "set #{var}=" : "unset #{var}"
|
@@ -76,25 +76,25 @@ module Maestro
|
|
76
76
|
# +err+ Boolean True if line is from stderr
|
77
77
|
def run_script_with_delegate(delegate, on_output)
|
78
78
|
File.open(@output_file.path, 'a') do |out_file|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
79
|
+
r, w = IO.pipe
|
80
|
+
ChildProcess.posix_spawn = true
|
81
|
+
process = IS_WINDOWS ? ChildProcess.build(@command_line) : ChildProcess.build(BASH_EXECUTABLE, @command_line)
|
82
|
+
process.io.stdout = process.io.stderr = w
|
83
|
+
process.start
|
84
|
+
w.close
|
85
|
+
|
86
|
+
while !r.eof? do
|
87
|
+
text = r.readpartial(1024)
|
88
|
+
out_file.write(text)
|
89
|
+
|
90
|
+
if delegate && on_output
|
91
|
+
delegate.send(on_output, text)
|
92
92
|
end
|
93
|
-
|
94
|
-
Process.wait(pid)
|
95
93
|
end
|
96
94
|
|
97
|
-
|
95
|
+
r.close
|
96
|
+
process.wait
|
97
|
+
@exit_code = ExitCode.new(process.exit_code)
|
98
98
|
end
|
99
99
|
|
100
100
|
return @exit_code
|
@@ -112,7 +112,7 @@ module Maestro
|
|
112
112
|
private
|
113
113
|
|
114
114
|
def get_command(path)
|
115
|
-
@command_line =
|
115
|
+
@command_line = path
|
116
116
|
@command_line
|
117
117
|
end
|
118
118
|
|
data/lib/util/version.rb
CHANGED
data/maestro_shell.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'logging', '1.8.0'
|
22
22
|
spec.add_dependency 'rubyzip', '0.9.8'
|
23
23
|
spec.add_dependency 'json', '>= 1.4.6'
|
24
|
+
spec.add_dependency 'childprocess', '>= 0.3.9'
|
24
25
|
|
25
26
|
spec.add_development_dependency "mocha", '>=0.10.0'
|
26
27
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
data/spec/shell_spec.rb
CHANGED
@@ -36,7 +36,6 @@ describe Maestro::Util::Shell do
|
|
36
36
|
# File.exists?(path).should be_true
|
37
37
|
|
38
38
|
subject.run_script.success?.should be_true
|
39
|
-
|
40
39
|
subject.to_s.chomp.should eql('willy')
|
41
40
|
end
|
42
41
|
|
@@ -93,7 +92,7 @@ CMD
|
|
93
92
|
|
94
93
|
subject.run_script.success?.should be_true
|
95
94
|
# Strips \r
|
96
|
-
subject.to_s.should eql("hello\ngoodbye\n")
|
95
|
+
subject.to_s.should eql("hello\r\ngoodbye\n")
|
97
96
|
end
|
98
97
|
|
99
98
|
it 'should create run and return result in on call' do
|
@@ -109,7 +108,7 @@ CMD
|
|
109
108
|
File.chmod(0777, temp.path)
|
110
109
|
command =<<-CMD
|
111
110
|
#{Maestro::Util::Shell::ENV_EXPORT_COMMAND} BLAH=blah; echo $BLAH
|
112
|
-
#{
|
111
|
+
#{temp.path}
|
113
112
|
CMD
|
114
113
|
|
115
114
|
path = subject.create_script command
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maestro_shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Henderson
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
version: 1.4.6
|
53
53
|
prerelease: false
|
54
54
|
type: :runtime
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: childprocess
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.9
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.3.9
|
67
|
+
prerelease: false
|
68
|
+
type: :runtime
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: mocha
|
57
71
|
version_requirements: !ruby/object:Gem::Requirement
|