execute 0.1.34 → 0.1.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cmd.rb +11 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dc9e112dda449d4c41273aac546cfe9f5c932aa
4
- data.tar.gz: 50d02e8e0973f379d0feee24ffcd1fbc28637957
3
+ metadata.gz: 6d65d79f1bc16f9472cc48aa7f5d346800f6c359
4
+ data.tar.gz: b8f2bc998ec198049ebb11740681bde43e4257d4
5
5
  SHA512:
6
- metadata.gz: f8415eb6715e358ef4e6799470d011a02e99b385c62c18766dbbb71e8418b826e717532f17511b954c79947d7ad360af7bd6da1ab5e86b3af0b74f0e3a5f54d5
7
- data.tar.gz: b1ba5cbd4e9eedd57e5fd25a5ab9c3e15b7a77051ae3f43ea3a1f22d72736373c3847feb569b72c9bdb9612ab38d54fdf1399262cc6f55449be40d1e4546c2ce
6
+ metadata.gz: 49cbc3ceb5ab3b33597bfea0a281403d83c8a80d264ec588fce56bd0ad251cc23b9732f25a0545005a50777ef9be2c663353896f506aaad997ea993fe80317a7
7
+ data.tar.gz: 84cd40d6473bbbcda35c14e4a2e182288b145159ce078a9254c16bc3c9a4e23c5ef7adddfdbc5ecc13ce45c9d8787d32ff28762fcc758292f920a582e28da8b6
data/lib/cmd.rb CHANGED
@@ -48,14 +48,19 @@ class CMD < Hash
48
48
  def system
49
49
  begin
50
50
  output = {output: [], error: [] }
51
+
52
+ Thread.abort_on_exception = true
53
+ mutex = Mutex.new
51
54
  Open3.popen3(self[:command]) do |stdin, stdout, stderr, wait_thr|
52
55
  self[:pid] = wait_thr.pid
53
56
  {:output => stdout,:error => stderr}.each do |key, stream|
54
57
  Thread.new do
55
58
  while wait_thr.alive? do
56
59
  if(!(char = stream.getc).nil?)
57
- output[key] << char
58
- putc char if(self[:echo_output])
60
+ mutex.synchronize do
61
+ output[key] << char
62
+ putc char if(self[:echo_output])
63
+ end
59
64
  else
60
65
  sleep(0.1)
61
66
  end
@@ -69,6 +74,10 @@ class CMD < Hash
69
74
  self[:error] = output[:error].join unless(output[:error].empty?)
70
75
  self[:exit_code] = wait_thr.value.to_i
71
76
  end
77
+ rescue Exception => e
78
+ self[:error] = "#{self[:error]}\nException: #{e.to_s}"
79
+ self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
80
+ raise e
72
81
  rescue => e
73
82
  self[:error] = "#{self[:error]}\nException: #{e.to_s}"
74
83
  self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: execute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.34
4
+ version: 0.1.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Marshall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler