vx-common-spawn 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7482ed7e3691e29c5345ff6ae38a1934a5f3a2a
4
- data.tar.gz: 37fb27fd0928e5d2751ea6d94b2648607fe0096d
3
+ metadata.gz: af97f3867871c4ce475fd4c9909f72a400383e3f
4
+ data.tar.gz: 9378b4d7f43169a707b0c75b0cdda7b26f651065
5
5
  SHA512:
6
- metadata.gz: 5be3b914e33d60f4fd228ddcb95cfea572517fcb70e9becca55906e12a5f801793977bce1fb6835c28108765d0a84a38485499d33591307a98354e94647124cf
7
- data.tar.gz: 8dbdfee09a0b4c137831ca296ec5984402c612fedd14e3b90d48c6068f3b48d1f5779b81187f0559aacf0f017a6c8df836c0a3dd1a5a8f4784dcd818db784a84
6
+ metadata.gz: 3cb94bc142f7f28b0d6608d5d6d532c67a5f2295fa0df3c0582a04382477d58f665107d5df63fde32c805ec96b951db7d011c2a3d12e31ab0207d1aced9048ba
7
+ data.tar.gz: 2ac7be70dc894ac5bd7a508ad19eb41a6fa07e85faf66585283eb79b357192d0318a2f65e5ec27e9769c8e8cce7a1584cebd673cafdb554c2ba6f3aaf1716fa1
@@ -1,6 +1,7 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.0
4
5
  before_install:
5
6
  - echo 'travis:travis' | sudo chpasswd
6
7
  - echo 'PasswordAuthentication yes' | sudo tee -a /etc/ssh/sshd_config
@@ -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 normalize_nl(str)
49
- str.gsub(/\r\n?/, "\n")
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
- #channel.request_pty do |_, pty_status|
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 normalize_nl(data) if block_given?
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 normalize_nl(data) if block_given?
112
+ yield data if block_given?
107
113
  read_timeout.reset
108
114
  end
109
115
  end
110
- #end
116
+
117
+ end
111
118
  end
112
119
 
113
120
  end
@@ -1,7 +1,7 @@
1
1
  module Vx
2
2
  module Common
3
3
  module Spawn
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
6
6
  end
7
7
  end
@@ -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.7
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: 2013-12-16 00:00:00.000000000 Z
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.1.11
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.