net-ssh-simple 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/net/ssh/simple/core.rb +5 -4
- data/lib/net/ssh/simple/version.rb +1 -1
- data/spec/net-ssh-simple.rb +16 -10
- metadata +16 -16
data/lib/net/ssh/simple/core.rb
CHANGED
@@ -524,7 +524,7 @@ module Net
|
|
524
524
|
|
525
525
|
def initialize(opts={})
|
526
526
|
@opts = opts
|
527
|
-
|
527
|
+
Thread.current[:ssh_simple_sessions] = {}
|
528
528
|
@result = Result.new
|
529
529
|
end
|
530
530
|
|
@@ -560,7 +560,7 @@ module Net
|
|
560
560
|
# @return [Net::SSH::Simple::Result] Result
|
561
561
|
#
|
562
562
|
def close
|
563
|
-
|
563
|
+
Thread.current[:ssh_simple_sessions].values.each do |session|
|
564
564
|
session.close
|
565
565
|
end
|
566
566
|
@result
|
@@ -570,8 +570,9 @@ module Net
|
|
570
570
|
def with_session(host, opts={:timeout => 60}, &block)
|
571
571
|
begin
|
572
572
|
Timeout.timeout(opts[:timeout]) do
|
573
|
-
session =
|
574
|
-
|
573
|
+
session = Thread.current[:ssh_simple_sessions][host.hash] \
|
574
|
+
= Thread.current[:ssh_simple_sessions][host.hash] \
|
575
|
+
|| Net::SSH.start(*[host, opts[:user], opts])
|
575
576
|
block.call(session)
|
576
577
|
end
|
577
578
|
rescue => e
|
data/spec/net-ssh-simple.rb
CHANGED
@@ -253,18 +253,24 @@ describe Net::SSH::Simple do
|
|
253
253
|
t[i] = Net::SSH::Simple.async do
|
254
254
|
mockback = mock(:progress_callback)
|
255
255
|
mockback.should_receive(:ping).at_least(:once)
|
256
|
-
|
257
|
-
|
258
|
-
r =
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
256
|
+
mockback.should_not_receive(:exception)
|
257
|
+
begin
|
258
|
+
r = nil
|
259
|
+
if 0 == i % 2
|
260
|
+
r = scp_dl('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
|
261
|
+
mockback.ping
|
262
|
+
end
|
263
|
+
else
|
264
|
+
r = scp_ul('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
|
265
|
+
mockback.ping
|
266
|
+
end
|
264
267
|
end
|
268
|
+
r.success.should == true
|
269
|
+
ssh('localhost', "echo hello #{i}")
|
270
|
+
rescue => e
|
271
|
+
p e
|
272
|
+
mockback.exception()
|
265
273
|
end
|
266
|
-
r.success.should == true
|
267
|
-
ssh('localhost', "echo hello #{i}")
|
268
274
|
end
|
269
275
|
end
|
270
276
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ssh-simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-26 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
16
|
-
requirement: &
|
16
|
+
requirement: &17944420 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.1.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17944420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: net-scp
|
27
|
-
requirement: &
|
27
|
+
requirement: &17940960 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17940960
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: blockenspiel
|
38
|
-
requirement: &
|
38
|
+
requirement: &17940320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.4.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *17940320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: hashie
|
49
|
-
requirement: &
|
49
|
+
requirement: &17939620 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.1.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *17939620
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &17939000 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.9.2.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *17939000
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &17938520 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *17938520
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: cover_me
|
82
|
-
requirement: &
|
82
|
+
requirement: &17937760 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *17937760
|
91
91
|
description: Net::SSH::Simple is a simple wrapper around Net::SSH and Net::SCP.
|
92
92
|
email:
|
93
93
|
- moe@busyloop.net
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
segments:
|
126
126
|
- 0
|
127
|
-
hash:
|
127
|
+
hash: -2990715889701617495
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
130
|
rubygems_version: 1.8.10
|