net-ssh-gateway 1.0.0 → 1.0.1

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.
@@ -1,3 +1,7 @@
1
+ === 1.0.1 / 1 Feb 2009
2
+
3
+ * Allow local port to be specified [Will Klancnik]
4
+
1
5
  === 1.0.0 / 1 May 2008
2
6
 
3
7
  * (no changes since the preview release)
@@ -43,7 +43,7 @@ class Net::SSH::Gateway
43
43
  MINOR = 0
44
44
 
45
45
  # The tiny component of the library's version
46
- TINY = 0
46
+ TINY = 1
47
47
 
48
48
  # The library's version as a Version instance
49
49
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -111,25 +111,28 @@ class Net::SSH::Gateway
111
111
  # port = gateway.open('host', 80)
112
112
  # # ...
113
113
  # gateway.close(port)
114
- def open(host, port)
114
+ #
115
+ # If +local_port+ is not specified, the next available port will be used.
116
+ def open(host, port, local_port=nil)
115
117
  ensure_open!
116
118
 
117
- local_port = next_port
119
+ actual_local_port = local_port || next_port
118
120
 
119
121
  @session_mutex.synchronize do
120
- @session.forward.local(local_port, host, port)
122
+ @session.forward.local(actual_local_port, host, port)
121
123
  end
122
124
 
123
125
  if block_given?
124
126
  begin
125
- yield local_port
127
+ yield actual_local_port
126
128
  ensure
127
- close(local_port)
129
+ close(actual_local_port)
128
130
  end
129
131
  else
130
- return local_port
132
+ return actual_local_port
131
133
  end
132
134
  rescue Errno::EADDRINUSE
135
+ raise if local_port # if a local port was explicitly requested, bubble the error up
133
136
  retry
134
137
  end
135
138
 
@@ -186,7 +189,9 @@ class Net::SSH::Gateway
186
189
 
187
190
  @thread = Thread.new do
188
191
  while @active
189
- @session_mutex.synchronize { @session.process(0.1) }
192
+ @session_mutex.synchronize do
193
+ @session.process(0.1)
194
+ end
190
195
  end
191
196
  end
192
197
  end
@@ -200,4 +205,4 @@ class Net::SSH::Gateway
200
205
  port
201
206
  end
202
207
  end
203
- end
208
+ end
@@ -1,58 +1,36 @@
1
-
2
- # Gem::Specification for Net-ssh-gateway-1.0.0
3
- # Originally generated by Echoe
4
-
5
1
  Gem::Specification.new do |s|
6
2
  s.name = %q{net-ssh-gateway}
7
- s.version = "1.0.0"
8
-
9
- s.specification_version = 2 if s.respond_to? :specification_version=
3
+ s.version = "1.0.1"
10
4
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
12
6
  s.authors = ["Jamis Buck"]
13
- s.date = %q{2008-05-01}
7
+ s.date = %q{2009-02-01}
14
8
  s.description = %q{A simple library to assist in establishing tunneled Net::SSH connections}
15
9
  s.email = %q{jamis@jamisbuck.org}
10
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/ssh/gateway.rb", "README.rdoc"]
16
11
  s.files = ["CHANGELOG.rdoc", "lib/net/ssh/gateway.rb", "Manifest", "Rakefile", "README.rdoc", "setup.rb", "test/gateway_test.rb", "net-ssh-gateway.gemspec"]
17
12
  s.has_rdoc = true
18
13
  s.homepage = %q{http://net-ssh.rubyforge.org/gateway}
14
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Net-ssh-gateway", "--main", "README.rdoc"]
19
15
  s.require_paths = ["lib"]
20
16
  s.rubyforge_project = %q{net-ssh-gateway}
21
- s.rubygems_version = %q{1.1.1}
17
+ s.rubygems_version = %q{1.2.0}
22
18
  s.summary = %q{A simple library to assist in establishing tunneled Net::SSH connections}
23
19
  s.test_files = ["test/gateway_test.rb"]
24
20
 
25
- s.add_dependency(%q<net-ssh>, [">= 1.99.1"])
26
- end
27
-
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 2
28
24
 
29
- # # Original Rakefile source (requires the Echoe gem):
30
- #
31
- # require './lib/net/ssh/gateway'
32
- #
33
- # begin
34
- # require 'echoe'
35
- # rescue LoadError
36
- # abort "You'll need to have `echoe' installed to use Net::SSH::Gateway's Rakefile"
37
- # end
38
- #
39
- # version = Net::SSH::Gateway::Version::STRING.dup
40
- # if ENV['SNAPSHOT'].to_i == 1
41
- # version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
42
- # end
43
- #
44
- # Echoe.new('net-ssh-gateway', version) do |p|
45
- # p.changelog = "CHANGELOG.rdoc"
46
- #
47
- # p.author = "Jamis Buck"
48
- # p.email = "jamis@jamisbuck.org"
49
- # p.summary = "A simple library to assist in establishing tunneled Net::SSH connections"
50
- # p.url = "http://net-ssh.rubyforge.org/gateway"
51
- #
52
- # p.dependencies = ["net-ssh >=1.99.1"]
53
- #
54
- # p.need_zip = true
55
- # p.include_rakefile = true
56
- #
57
- # p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/
58
- # end
25
+ if current_version >= 3 then
26
+ s.add_runtime_dependency(%q<net-ssh>, [">= 1.99.1"])
27
+ s.add_development_dependency(%q<echoe>, [">= 0"])
28
+ else
29
+ s.add_dependency(%q<net-ssh>, [">= 1.99.1"])
30
+ s.add_dependency(%q<echoe>, [">= 0"])
31
+ end
32
+ else
33
+ s.add_dependency(%q<net-ssh>, [">= 1.99.1"])
34
+ s.add_dependency(%q<echoe>, [">= 0"])
35
+ end
36
+ end
@@ -27,6 +27,12 @@ class GatewayTest < Test::Unit::TestCase
27
27
  assert_equal [65000, "app1", 22], gateway_session.forward.active_locals[65000]
28
28
  end
29
29
 
30
+ def test_open_with_explicit_local_port_should_use_that_port
31
+ gateway_session, gateway = new_gateway
32
+ assert_equal 8181, gateway.open("app1", 22, 8181)
33
+ assert_equal [8181, "app1", 22], gateway_session.forward.active_locals[8181]
34
+ end
35
+
30
36
  def test_ssh_should_return_connection_when_no_block_is_given
31
37
  gateway_session, gateway = new_gateway
32
38
  expect_connect_to("127.0.0.1", "user", :port => 65535).returns(result = mock("session"))
@@ -113,4 +119,4 @@ class GatewayTest < Test::Unit::TestCase
113
119
  @looping = false
114
120
  end
115
121
  end
116
- end
122
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ssh-gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-01 00:00:00 -06:00
12
+ date: 2009-02-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: net-ssh
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -21,14 +22,26 @@ dependencies:
21
22
  - !ruby/object:Gem::Version
22
23
  version: 1.99.1
23
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: echoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
24
35
  description: A simple library to assist in establishing tunneled Net::SSH connections
25
36
  email: jamis@jamisbuck.org
26
37
  executables: []
27
38
 
28
39
  extensions: []
29
40
 
30
- extra_rdoc_files: []
31
-
41
+ extra_rdoc_files:
42
+ - CHANGELOG.rdoc
43
+ - lib/net/ssh/gateway.rb
44
+ - README.rdoc
32
45
  files:
33
46
  - CHANGELOG.rdoc
34
47
  - lib/net/ssh/gateway.rb
@@ -41,8 +54,13 @@ files:
41
54
  has_rdoc: true
42
55
  homepage: http://net-ssh.rubyforge.org/gateway
43
56
  post_install_message:
44
- rdoc_options: []
45
-
57
+ rdoc_options:
58
+ - --line-numbers
59
+ - --inline-source
60
+ - --title
61
+ - Net-ssh-gateway
62
+ - --main
63
+ - README.rdoc
46
64
  require_paths:
47
65
  - lib
48
66
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -55,12 +73,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
73
  requirements:
56
74
  - - ">="
57
75
  - !ruby/object:Gem::Version
58
- version: "0"
76
+ version: "1.2"
59
77
  version:
60
78
  requirements: []
61
79
 
62
80
  rubyforge_project: net-ssh-gateway
63
- rubygems_version: 1.1.1
81
+ rubygems_version: 1.2.0
64
82
  signing_key:
65
83
  specification_version: 2
66
84
  summary: A simple library to assist in establishing tunneled Net::SSH connections