net-ssh-stream 0.1.0 → 0.2.0
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/net/ssh/stream.rb +6 -0
- data/lib/net/ssh/stream/version.rb +1 -1
- data/spec/stream_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14ea68c43d50a202c45e0b549d15a66386c99d40
|
4
|
+
data.tar.gz: c72701ecea23a56c38bb649c3862d7369d6810f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0fd0825a61814d39df106e3368db4a8f4d0d7333eea3ca19aa4aa45bef1c024be498a6c10a436af6d5b5f3adf589a97063ee23f8cbea06379d0b72035a39bc8
|
7
|
+
data.tar.gz: a938f4d1f2d20ed920135fef1cb5f87b45c062eabdbdbc8ff018ff4af2970da2e554cbbe2c5fde0023df924cfe8c672312cc7eea8a759c2ebbda166b93a11dc6
|
data/lib/net/ssh/stream.rb
CHANGED
@@ -45,9 +45,15 @@ module Net
|
|
45
45
|
exit_code
|
46
46
|
end
|
47
47
|
|
48
|
+
def exec!(command, stdout: STDOUT, stderr: STDERR)
|
49
|
+
exit_code = self.exec command, stdout: stdout, stderr: stderr
|
50
|
+
raise "Command fail - Exit code #{exit_code} - #{command}" if exit_code != 0
|
51
|
+
end
|
52
|
+
|
48
53
|
def self.start(*args)
|
49
54
|
stream = self.new *args
|
50
55
|
yield stream
|
56
|
+
ensure
|
51
57
|
stream.close
|
52
58
|
nil
|
53
59
|
end
|
data/spec/stream_spec.rb
CHANGED
@@ -30,4 +30,11 @@ describe Net::SSH::Stream do
|
|
30
30
|
assert_equal "bash: invalid-command: command not found", stderr.read.strip
|
31
31
|
end
|
32
32
|
|
33
|
+
it 'Raise exception' do
|
34
|
+
Net::SSH::Stream.start 'localhost', username do |stram|
|
35
|
+
stram.exec! 'pwd', stdout: StringIO.new
|
36
|
+
Proc.new { stram.exec! 'invalid-command', stderr: StringIO.new }.must_raise RuntimeError
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
33
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ssh-stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|