vx-common-spawn 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/.travis.yml +1 -0
- data/lib/vx/common/spawn/ssh.rb +16 -9
- data/lib/vx/common/spawn/version.rb +1 -1
- data/spec/lib/spawn/ssh_spec.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af97f3867871c4ce475fd4c9909f72a400383e3f
|
4
|
+
data.tar.gz: 9378b4d7f43169a707b0c75b0cdda7b26f651065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb94bc142f7f28b0d6608d5d6d532c67a5f2295fa0df3c0582a04382477d58f665107d5df63fde32c805ec96b951db7d011c2a3d12e31ab0207d1aced9048ba
|
7
|
+
data.tar.gz: 2ac7be70dc894ac5bd7a508ad19eb41a6fa07e85faf66585283eb79b357192d0318a2f65e5ec27e9769c8e8cce7a1584cebd673cafdb554c2ba6f3aaf1716fa1
|
data/.travis.yml
CHANGED
data/lib/vx/common/spawn/ssh.rb
CHANGED
@@ -32,7 +32,7 @@ module Vx
|
|
32
32
|
read_timeout = Spawn::ReadTimeout.new options.delete(:read_timeout)
|
33
33
|
|
34
34
|
command = build_command(env, command, options)
|
35
|
-
channel = spawn_channel command, read_timeout, &block
|
35
|
+
channel = spawn_channel command, read_timeout, options, &block
|
36
36
|
|
37
37
|
channel.on_request("exit-status") do |_,data|
|
38
38
|
exit_code = data.read_long
|
@@ -45,8 +45,15 @@ module Vx
|
|
45
45
|
|
46
46
|
private
|
47
47
|
|
48
|
-
def
|
49
|
-
|
48
|
+
def request_pty(channel, options)
|
49
|
+
if options[:pty]
|
50
|
+
channel.request_pty do |_, pty_status|
|
51
|
+
raise StandardError, "could not obtain pty" unless pty_status
|
52
|
+
yield if block_given?
|
53
|
+
end
|
54
|
+
else
|
55
|
+
yield if block_given?
|
56
|
+
end
|
50
57
|
end
|
51
58
|
|
52
59
|
def build_command(env, command, options)
|
@@ -83,11 +90,10 @@ module Vx
|
|
83
90
|
end
|
84
91
|
end
|
85
92
|
|
86
|
-
def spawn_channel(command, read_timeout, &block)
|
93
|
+
def spawn_channel(command, read_timeout, options, &block)
|
87
94
|
@connection.open_channel do |channel|
|
88
95
|
|
89
|
-
|
90
|
-
# raise StandardError, "could not obtain pty" unless pty_status
|
96
|
+
request_pty channel, options do
|
91
97
|
|
92
98
|
read_timeout.reset
|
93
99
|
|
@@ -98,16 +104,17 @@ module Vx
|
|
98
104
|
end
|
99
105
|
|
100
106
|
channel.on_data do |_, data|
|
101
|
-
yield
|
107
|
+
yield data if block_given?
|
102
108
|
read_timeout.reset
|
103
109
|
end
|
104
110
|
|
105
111
|
channel.on_extended_data do |_, _, data|
|
106
|
-
yield
|
112
|
+
yield data if block_given?
|
107
113
|
read_timeout.reset
|
108
114
|
end
|
109
115
|
end
|
110
|
-
|
116
|
+
|
117
|
+
end
|
111
118
|
end
|
112
119
|
|
113
120
|
end
|
data/spec/lib/spawn/ssh_spec.rb
CHANGED
@@ -15,6 +15,12 @@ describe Vx::Common::Spawn::SSH, ssh: true do
|
|
15
15
|
expect(code).to eq 0
|
16
16
|
end
|
17
17
|
|
18
|
+
it "run command successfuly with pty" do
|
19
|
+
code = run_ssh 'env', pty: true
|
20
|
+
expect(collected).to match(/SSH_TTY=/)
|
21
|
+
expect(code).to eq 0
|
22
|
+
end
|
23
|
+
|
18
24
|
it "run command with error" do
|
19
25
|
code = run_ssh 'false'
|
20
26
|
expect(collected).to eq ""
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-common-spawn
|
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
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.0.14
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: This gem helps to spawn processes in a shell capturing output in realtime.
|