em-ssh 0.0.2 → 0.0.3
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.
- data/lib/em-ssh/connection.rb +1 -0
- data/lib/em-ssh/session.rb +3 -4
- data/lib/em-ssh/shell.rb +10 -1
- data/lib/em-ssh/version.rb +1 -1
- data/lib/em-ssh.rb +2 -0
- metadata +13 -12
data/lib/em-ssh/connection.rb
CHANGED
data/lib/em-ssh/session.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module EventMachine
|
3
2
|
class Ssh
|
4
3
|
class Session < Net::SSH::Connection::Session
|
@@ -39,11 +38,11 @@ module EventMachine
|
|
39
38
|
send(MAP[packet.type], packet)
|
40
39
|
end # |packet|
|
41
40
|
|
42
|
-
|
41
|
+
chan_timer = EM.add_periodic_timer(0.01) do
|
42
|
+
# we need to check the channel for any data to send and tell it to process any input
|
43
|
+
# at some point we should override Channel#enqueue_pending_output, etc.,.
|
43
44
|
channels.each { |id, channel| channel.process unless channel.closing? }
|
44
|
-
EM.next_tick(&chann_proc)
|
45
45
|
end
|
46
|
-
EM.next_tick(&chann_proc)
|
47
46
|
end # register_callbacks
|
48
47
|
|
49
48
|
end # class::Session
|
data/lib/em-ssh/shell.rb
CHANGED
@@ -63,7 +63,8 @@ module EventMachine
|
|
63
63
|
# @param [Hash] opts
|
64
64
|
# @option opts [Hash] :net_ssh options to pass to Net::SSH; see Net::SSH.start
|
65
65
|
# @option opts [Boolean] :halt_on_timeout (false)
|
66
|
-
# @option opts [Fixnum] :timeout (TIMEOUT) default timeout for all #wait_for and #send_wait calls
|
66
|
+
# @option opts [Fixnum] :timeout (TIMEOUT) default timeout for all #wait_for and #send_wait calls
|
67
|
+
# @option opts [Boolean] :reconnect when disconnected reconnect
|
67
68
|
def initialize(address, user, pass, opts = {}, &blk)
|
68
69
|
@halt_on_timeout = opts[:halt_on_timeout] || false
|
69
70
|
@timeout = opts[:timeout].is_a?(Fixnum) ? opts[:timeout] : TIMEOUT
|
@@ -75,10 +76,16 @@ module EventMachine
|
|
75
76
|
@connection = opts[:connection]
|
76
77
|
@parent = opts[:parent]
|
77
78
|
@children = []
|
79
|
+
@reconnect = opts[:reconnect]
|
78
80
|
|
79
81
|
block_given? ? Fiber.new { open(&blk) }.resume : open
|
80
82
|
end
|
81
83
|
|
84
|
+
# @return [Boolean] true if the connection should be automatically re-established; default: false
|
85
|
+
def reconnect?
|
86
|
+
@reconnect == true
|
87
|
+
end # auto_connect?
|
88
|
+
|
82
89
|
# Close the connection to the server and all child shells.
|
83
90
|
# Disconnected shells cannot be split.
|
84
91
|
def disconnect
|
@@ -111,6 +118,7 @@ module EventMachine
|
|
111
118
|
# @param [String] send_str
|
112
119
|
# @return [String] all data in the buffer including the wait_str if it was found
|
113
120
|
def send_and_wait(send_str, wait_str = nil, opts = {})
|
121
|
+
reconnect? ? connect : raise(Disconnected) unless connected?
|
114
122
|
raise ClosedChannel if closed?
|
115
123
|
debug("send_and_wait(#{send_str.inspect}, #{wait_str.inspect}, #{opts})")
|
116
124
|
send_data(send_str)
|
@@ -124,6 +132,7 @@ module EventMachine
|
|
124
132
|
# @option opts [Boolean] (false) :halt_on_timeout
|
125
133
|
# @return [String] the contents of the buffer
|
126
134
|
def wait_for(strregex, opts = { })
|
135
|
+
reconnect? ? connect : raise(Disconnected) unless connected?
|
127
136
|
raise ClosedChannel if closed?
|
128
137
|
debug("wait_for(#{strregex.inspect}, #{opts})")
|
129
138
|
opts = { :timeout => @timeout, :halt_on_timeout => @halt_on_timeout }.merge(opts)
|
data/lib/em-ssh/version.rb
CHANGED
data/lib/em-ssh.rb
CHANGED
@@ -22,6 +22,8 @@ module EventMachine
|
|
22
22
|
class SshError < Net::SSH::Exception; include Error; end
|
23
23
|
class TimeoutError < Timeout::Error; include Error; end
|
24
24
|
class ClosedChannel < SshError; end
|
25
|
+
class DisconnectedChannel < SshError; end
|
26
|
+
|
25
27
|
|
26
28
|
class << self
|
27
29
|
attr_writer :logger
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-24 00:00:00.000000000 +09:00
|
13
|
+
default_executable:
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: eventmachine
|
16
|
-
requirement: &
|
17
|
+
requirement: &2160452560 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
@@ -21,10 +22,10 @@ dependencies:
|
|
21
22
|
version: '0'
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
+
version_requirements: *2160452560
|
25
26
|
- !ruby/object:Gem::Dependency
|
26
27
|
name: net-ssh
|
27
|
-
requirement: &
|
28
|
+
requirement: &2160424600 !ruby/object:Gem::Requirement
|
28
29
|
none: false
|
29
30
|
requirements:
|
30
31
|
- - ! '>='
|
@@ -32,10 +33,10 @@ dependencies:
|
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
+
version_requirements: *2160424600
|
36
37
|
- !ruby/object:Gem::Dependency
|
37
38
|
name: ruby-termios
|
38
|
-
requirement: &
|
39
|
+
requirement: &2160412880 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
42
|
- - ! '>='
|
@@ -43,10 +44,10 @@ dependencies:
|
|
43
44
|
version: '0'
|
44
45
|
type: :development
|
45
46
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
+
version_requirements: *2160412880
|
47
48
|
- !ruby/object:Gem::Dependency
|
48
49
|
name: highline
|
49
|
-
requirement: &
|
50
|
+
requirement: &2160402840 !ruby/object:Gem::Requirement
|
50
51
|
none: false
|
51
52
|
requirements:
|
52
53
|
- - ! '>='
|
@@ -54,7 +55,7 @@ dependencies:
|
|
54
55
|
version: '0'
|
55
56
|
type: :development
|
56
57
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
+
version_requirements: *2160402840
|
58
59
|
description: ''
|
59
60
|
email:
|
60
61
|
- em-ssh@simulacre.org
|
@@ -77,6 +78,7 @@ files:
|
|
77
78
|
- bin/em-ssh
|
78
79
|
- bin/em-ssh-shell
|
79
80
|
- README.md
|
81
|
+
has_rdoc: true
|
80
82
|
homepage: http://github.com/simulacre/em-ssh
|
81
83
|
licenses:
|
82
84
|
- MIT
|
@@ -98,9 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
100
|
version: 1.3.6
|
99
101
|
requirements: []
|
100
102
|
rubyforge_project:
|
101
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.6.2
|
102
104
|
signing_key:
|
103
105
|
specification_version: 3
|
104
106
|
summary: An EventMachine compatible net-ssh
|
105
107
|
test_files: []
|
106
|
-
has_rdoc:
|