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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc3c43c91ae1ad728a326390268aa61924c77521
4
- data.tar.gz: bcc3c16f0f7d1309e0b51dabeccf1698bd9f9d92
3
+ metadata.gz: 73beca833565d0135c019fb22c69b23ad6c3cbf0
4
+ data.tar.gz: b33923670ef19d8189a09ec3742f273f17d08fe2
5
5
  SHA512:
6
- metadata.gz: 15b0438163743d7540034ffc2375da502e7e0f31d573ae3e89896a2d5ff5efea96726c16bfd0a7de4779082db4b3b7e78520cb1ba9ba674163250c1e8f673013
7
- data.tar.gz: 5ff0317c41ceca677029b8dbcd70669efa64e8394b64419244c2514fabf1998ef43307d882285500180b46fd7a13de482b520f969525463bd2d91d2dfa003987
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 'pty'
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.exitstatus
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
- SHELL_EXECUTABLE = IS_WINDOWS ? '' : 'bash '
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
- sleep 0.1
80
- status = PTY.spawn(@command_line) do |master, slave, pid|
81
- begin
82
- while !slave.eof?
83
- text = slave.readpartial(1024).gsub(/\r/, '')
84
- out_file.write(text)
85
-
86
- if delegate && on_output
87
- delegate.send(on_output, text)
88
- end
89
- end
90
- rescue Exception => e
91
- Maestro.log.warn "Got Exception in spawn #{e} #{e.class}"
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
- @exit_code = ExitCode.new($?)
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 = "#{SHELL_EXECUTABLE}#{path}"
115
+ @command_line = path
116
116
  @command_line
117
117
  end
118
118
 
data/lib/util/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Maestro
2
2
  module Util
3
3
  class Shell
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.8'
5
5
  end
6
6
  end
7
7
  end
@@ -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
- #{Maestro::Util::Shell::SHELL_EXECUTABLE} #{temp.path}
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.7
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