evrone-common-spawn 0.0.4 → 0.0.5

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: 0ba5ac5008b3ed08ab6ab11244721aa25b5cf1de
4
- data.tar.gz: fa1a01ee4855ba9a26c2384eef00fa5e7a5e2645
3
+ metadata.gz: 72883bae873f531ba9e9ce5ee18c03f28807b12b
4
+ data.tar.gz: 32639657615dd8156849cdd1a53b0c8c9007bb6b
5
5
  SHA512:
6
- metadata.gz: 2bf4150280e499ca33df726d41d13a0d992d6067fb3530ec32756319c27a3123d93fd180af85430a15afb1ac15fe5c1cac5a562c8cadae72811ad201f2467ea7
7
- data.tar.gz: c803c1f155e42c91d92fe1dce23ea1a7da6cc755a418197a2573a5eb2b5111af0837ba2fe61085ba02ddb45b68a8db60baa98b305b069eb7141f3c3bccdb300d
6
+ metadata.gz: c1a7f84c8110e41e836a365d4b39dc692fa1bde96a903c2394be257f111d62ba48d000e5a8d2209bfa977e6324c11b9eb44b42e1b3228e8a1a7ff419ebd02c82
7
+ data.tar.gz: dc18782286c1295e04902be3ad1888bfcfecd762bc8ae1d7f7c1557d69aad2710d8011cf5f24364bc6c646bce3ccc99cc932c05e035983aa9c898ff4e0bd42f8
@@ -45,6 +45,10 @@ module Evrone
45
45
 
46
46
  private
47
47
 
48
+ def normalize_nl(str)
49
+ str.gsub(/\r\n?/, "\n")
50
+ end
51
+
48
52
  def build_command(env, command, options)
49
53
  cmd = command
50
54
  unless env.empty?
@@ -80,30 +84,28 @@ module Evrone
80
84
  end
81
85
 
82
86
  def spawn_channel(command, read_timeout, &block)
83
-
84
87
  @connection.open_channel do |channel|
85
- read_timeout.reset
86
88
 
87
- #env.each do |k, v|
88
- # channel.env k, v do |_, success|
89
- # yield "FAILED: couldn't execute command (ssh.channel.env)\n" if block_given?
90
- # end
91
- #end
89
+ channel.request_pty do |_, pty_status|
90
+ raise StandardError, "could not obtain pty" unless pty_status
92
91
 
93
- channel.exec command do |_, success|
92
+ read_timeout.reset
94
93
 
95
- unless success
96
- yield "FAILED: couldn't execute command (ssh.channel.exec)\n" if block_given?
97
- end
94
+ channel.exec command do |_, success|
98
95
 
99
- channel.on_data do |_, data|
100
- yield data if block_given?
101
- read_timeout.reset
102
- end
96
+ unless success
97
+ yield "FAILED: couldn't execute command (ssh.channel.exec)\n" if block_given?
98
+ end
99
+
100
+ channel.on_data do |_, data|
101
+ yield normalize_nl(data) if block_given?
102
+ read_timeout.reset
103
+ end
103
104
 
104
- channel.on_extended_data do |_, _, data|
105
- yield data if block_given?
106
- read_timeout.reset
105
+ channel.on_extended_data do |_, _, data|
106
+ yield normalize_nl(data) if block_given?
107
+ read_timeout.reset
108
+ end
107
109
  end
108
110
  end
109
111
  end
@@ -1,7 +1,7 @@
1
1
  module Evrone
2
2
  module Common
3
3
  module Spawn
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
6
6
  end
7
7
  end
@@ -51,7 +51,7 @@ describe Evrone::Common::Spawn::SSH, ssh: true do
51
51
  end
52
52
 
53
53
  it 'run command with timeout successfuly' do
54
- code = run_ssh('echo $USER; sleep 0.2', timeout: 0.5)
54
+ code = run_ssh('echo $USER; sleep 0.2', timeout: 1)
55
55
  expect(collected).to eq "#{user}\n"
56
56
  expect(code).to eq 0
57
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evrone-common-spawn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-09-27 00:00:00.000000000 Z
11
+ date: 2013-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh