kommando 0.0.5 → 0.0.6

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: e48c9ee88deb15984338770bcb3f88df16233c55
4
- data.tar.gz: 1734e1fbce11cb305053d2a75c193a92ce71889d
3
+ metadata.gz: a4b7759e3a3f6c9980f7dc19353cdece83fafdca
4
+ data.tar.gz: 5c4ac9619d762838a4146a03fee7c5b314b7c920
5
5
  SHA512:
6
- metadata.gz: 1fdc4301a64924c7bd60e2555a40c27a83849c47b674deb717017cb9c873aa2693cc790332545cf39a3e818af913190b59a4de903ee2869902ea1a6470bede89
7
- data.tar.gz: b05437941a9ec740fe09a8aac78fa8b67ee3ed05f150b88e1ddb941e0308662c96fec308195146f33bac1f85fade218faad6ad3ac702eb21be9645fdc8061123
6
+ metadata.gz: 378367b00a5cf6febd212d611eb35622fe37a1b530d233757e25b54d11af818778145a1f0cab1c5722049dc26cd3e8f765d72a0a1d19e52013247edf9081b8dd
7
+ data.tar.gz: 1e2c26f31ade6e75cc68dd7a965566769f54cf46346c915d2863614d9185d52ff8c36f6cdfa944344e6ba7a33bc7dd5c3f31b007d38d190972179363adf6e193
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.6
4
+ Fix Linux harder.
5
+
6
+ - FIX: Changed strategy.
7
+
3
8
  ## 0.0.5
4
9
  Fixes.
5
10
 
@@ -7,23 +7,6 @@ require_relative "kommando/buffer"
7
7
 
8
8
  class Kommando
9
9
 
10
- # http://stackoverflow.com/a/7263243
11
- module SafePTY
12
- def self.spawn command, *args, &block
13
-
14
- PTY.spawn(command, *args) do |r,w,p|
15
- begin
16
- yield r,w,p
17
- rescue Errno::EIO
18
- ensure
19
- Process.wait p
20
- end
21
- end
22
-
23
- $?.exitstatus
24
- end
25
- end
26
-
27
10
  def initialize(cmd, opts={})
28
11
  @cmd = cmd
29
12
  @stdout = Buffer.new
@@ -38,7 +21,7 @@ class Kommando
38
21
  elsif opts[:timeout].class == Fixnum
39
22
  opts[:timeout].to_f
40
23
  end
41
- @thread_did_timeout = nil
24
+ @timeout_happened = false
42
25
 
43
26
  @code = nil
44
27
  @executed = false
@@ -52,7 +35,7 @@ class Kommando
52
35
 
53
36
  command, *args = @cmd.split " "
54
37
  begin
55
- exitstatus = SafePTY.spawn(command, *args) do |stdout, stdin, pid|
38
+ PTY.spawn(command, *args) do |stdout, stdin, pid|
56
39
  if @retry && stdout.eof?
57
40
  @executed = false
58
41
  return run
@@ -66,7 +49,12 @@ class Kommando
66
49
  Thread.abort_on_exception = true
67
50
  thread_stdout = Thread.new do
68
51
  while true do
69
- break if stdout.eof?
52
+ begin
53
+ break if stdout.eof?
54
+ rescue Errno::EIO
55
+ # Linux http://stackoverflow.com/a/7263243
56
+ break
57
+ end
70
58
 
71
59
  c = nil
72
60
  begin
@@ -90,7 +78,7 @@ class Kommando
90
78
  end
91
79
  rescue Timeout::Error
92
80
  Process.kill('KILL', pid)
93
- @thread_did_timeout = true
81
+ @timeout_happened = true
94
82
  end
95
83
  else
96
84
  thread_stdout.join
@@ -99,10 +87,10 @@ class Kommando
99
87
  stdout_file.close if @output_file
100
88
  end
101
89
 
102
- @code = if @thread_did_timeout
90
+ @code = if @timeout_happened
103
91
  1
104
92
  else
105
- exitstatus
93
+ $?.exitstatus
106
94
  end
107
95
  rescue RuntimeError => ex
108
96
  if ex.message == "can't get Master/Slave device"
@@ -1,3 +1,3 @@
1
1
  class Kommando
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kommando
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matti Paksula