net-scp 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ === 1.0.2 / 4 Feb 2009
2
+
3
+ * Escape spaces in file names on remote server [Jamis Buck]
4
+
5
+
1
6
  === 1.0.1 / 29 May 2008
2
7
 
3
8
  * Make sure downloads open the file in binary mode to appease Windows [Jamis Buck]
@@ -337,7 +337,7 @@ module Net
337
337
  # (See Net::SCP::Upload and Net::SCP::Download).
338
338
  def start_command(mode, local, remote, options={}, &callback)
339
339
  session.open_channel do |channel|
340
- command = "#{scp_command(mode, options)} #{remote}"
340
+ command = "#{scp_command(mode, options)} #{sanitize_file_name(remote)}"
341
341
  channel.exec(command) do |ch, success|
342
342
  if success
343
343
  channel[:local ] = local
@@ -398,6 +398,10 @@ module Net
398
398
  def progress_callback(channel, name, sent, total)
399
399
  channel[:callback].call(channel, name, sent, total) if channel[:callback]
400
400
  end
401
+
402
+ def sanitize_file_name(file_name)
403
+ file_name.gsub(/[ ]/) { |m| "\\#{m}" }
404
+ end
401
405
  end
402
406
  end
403
407
 
@@ -407,4 +411,4 @@ class Net::SSH::Connection::Session
407
411
  def scp
408
412
  @scp ||= Net::SCP.new(self)
409
413
  end
410
- end
414
+ end
@@ -10,7 +10,7 @@ module Net; class SCP
10
10
 
11
11
  # The default read chunk size, if an explicit chunk-size is not specified
12
12
  # by the client.
13
- DEFAULT_CHUNK_SIZE = 2048
13
+ DEFAULT_CHUNK_SIZE = 16384
14
14
 
15
15
  # The start state for uploads. Simply sets up the upload scaffolding,
16
16
  # sets the current item to upload, and jumps to #upload_current_state.
@@ -6,7 +6,7 @@ module Net; class SCP
6
6
  class Version < Net::SSH::Version
7
7
  MAJOR = 1
8
8
  MINOR = 0
9
- TINY = 1
9
+ TINY = 2
10
10
 
11
11
  # The current version, as a Version instance
12
12
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -1,62 +1,34 @@
1
-
2
- # Gem::Specification for Net-scp-1.0.1
3
- # Originally generated by Echoe
1
+ # -*- encoding: utf-8 -*-
4
2
 
5
3
  Gem::Specification.new do |s|
6
4
  s.name = %q{net-scp}
7
- s.version = "1.0.1"
8
-
9
- s.specification_version = 2 if s.respond_to? :specification_version=
5
+ s.version = "1.0.2"
10
6
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
12
8
  s.authors = ["Jamis Buck"]
13
- s.date = %q{2008-05-29}
9
+ s.date = %q{2009-11-23}
14
10
  s.description = %q{A pure Ruby implementation of the SCP client protocol}
15
11
  s.email = %q{jamis@jamisbuck.org}
16
12
  s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/scp/download.rb", "lib/net/scp/errors.rb", "lib/net/scp/upload.rb", "lib/net/scp/version.rb", "lib/net/scp.rb", "lib/uri/open-scp.rb", "lib/uri/scp.rb", "README.rdoc"]
17
13
  s.files = ["CHANGELOG.rdoc", "lib/net/scp/download.rb", "lib/net/scp/errors.rb", "lib/net/scp/upload.rb", "lib/net/scp/version.rb", "lib/net/scp.rb", "lib/uri/open-scp.rb", "lib/uri/scp.rb", "Rakefile", "README.rdoc", "setup.rb", "test/common.rb", "test/test_all.rb", "test/test_download.rb", "test/test_scp.rb", "test/test_upload.rb", "Manifest", "net-scp.gemspec"]
18
- s.has_rdoc = true
19
14
  s.homepage = %q{http://net-ssh.rubyforge.org/scp}
20
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Net-scp", "--main", "README.rdoc"]
21
16
  s.require_paths = ["lib"]
22
17
  s.rubyforge_project = %q{net-ssh}
23
- s.rubygems_version = %q{1.1.1}
18
+ s.rubygems_version = %q{1.3.5}
24
19
  s.summary = %q{A pure Ruby implementation of the SCP client protocol}
25
20
  s.test_files = ["test/test_all.rb"]
26
21
 
27
- s.add_dependency(%q<net-ssh>, [">= 1.99.1"])
28
- end
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
29
25
 
30
-
31
- # # Original Rakefile source (requires the Echoe gem):
32
- #
33
- # $LOAD_PATH.unshift "../net-ssh/lib"
34
- # require './lib/net/scp/version'
35
- #
36
- # begin
37
- # require 'echoe'
38
- # rescue LoadError
39
- # abort "You'll need to have `echoe' installed to use Net::SCP's Rakefile"
40
- # end
41
- #
42
- # version = Net::SCP::Version::STRING.dup
43
- # if ENV['SNAPSHOT'].to_i == 1
44
- # version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
45
- # end
46
- #
47
- # Echoe.new('net-scp', version) do |p|
48
- # p.project = "net-ssh"
49
- # p.changelog = "CHANGELOG.rdoc"
50
- #
51
- # p.author = "Jamis Buck"
52
- # p.email = "jamis@jamisbuck.org"
53
- # p.summary = "A pure Ruby implementation of the SCP client protocol"
54
- # p.url = "http://net-ssh.rubyforge.org/scp"
55
- #
56
- # p.dependencies = ["net-ssh >=1.99.1"]
57
- #
58
- # p.need_zip = true
59
- # p.include_rakefile = true
60
- #
61
- # p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/
62
- # end
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<net-ssh>, [">= 1.99.1"])
28
+ else
29
+ s.add_dependency(%q<net-ssh>, [">= 1.99.1"])
30
+ end
31
+ else
32
+ s.add_dependency(%q<net-ssh>, [">= 1.99.1"])
33
+ end
34
+ end
@@ -12,6 +12,20 @@ class TestDownload < Net::SCP::TestCase
12
12
  assert_equal "a" * 1234, file.io.string
13
13
  end
14
14
 
15
+ def test_download_file_with_spaces_in_name_should_escape_remote_file_name
16
+ file = prepare_file("/path/to/local file.txt", "")
17
+
18
+ expect_scp_session "-f /path/to/remote\\ file.txt" do |channel|
19
+ channel.sends_ok
20
+ channel.gets_data "C0666 0 local file.txt\n"
21
+ channel.sends_ok
22
+ channel.gets_ok
23
+ channel.sends_ok
24
+ end
25
+
26
+ assert_scripted { scp.download!("/path/to/remote file.txt", "/path/to/local file.txt") }
27
+ end
28
+
15
29
  def test_download_with_preserve_should_send_times
16
30
  file = prepare_file("/path/to/local.txt", "a" * 1234, 0644, Time.at(1234567890, 123456), Time.at(12121212, 232323))
17
31
 
@@ -16,6 +16,20 @@ class TestUpload < Net::SCP::TestCase
16
16
  assert_scripted { scp.upload!("/path/to/local.txt", "/path/to/remote.txt") }
17
17
  end
18
18
 
19
+ def test_upload_file_with_spaces_in_name_should_escape_remote_file_name
20
+ prepare_file("/path/to/local file.txt", "")
21
+
22
+ expect_scp_session "-t /path/to/remote\\ file.txt" do |channel|
23
+ channel.gets_ok
24
+ channel.sends_data "C0666 0 local file.txt\n"
25
+ channel.gets_ok
26
+ channel.sends_ok
27
+ channel.gets_ok
28
+ end
29
+
30
+ assert_scripted { scp.upload!("/path/to/local file.txt", "/path/to/remote file.txt") }
31
+ end
32
+
19
33
  def test_upload_file_with_preserve_should_send_times
20
34
  prepare_file("/path/to/local.txt", "a" * 1234, 0666, Time.at(1234567890, 123456), Time.at(1234543210, 345678))
21
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-scp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
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-29 00:00:00 -06:00
12
+ date: 2009-11-23 00:00:00 -05: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:
@@ -58,6 +59,8 @@ files:
58
59
  - net-scp.gemspec
59
60
  has_rdoc: true
60
61
  homepage: http://net-ssh.rubyforge.org/scp
62
+ licenses: []
63
+
61
64
  post_install_message:
62
65
  rdoc_options:
63
66
  - --line-numbers
@@ -78,14 +81,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
81
  requirements:
79
82
  - - ">="
80
83
  - !ruby/object:Gem::Version
81
- version: "0"
84
+ version: "1.2"
82
85
  version:
83
86
  requirements: []
84
87
 
85
88
  rubyforge_project: net-ssh
86
- rubygems_version: 1.1.1
89
+ rubygems_version: 1.3.5
87
90
  signing_key:
88
- specification_version: 2
91
+ specification_version: 3
89
92
  summary: A pure Ruby implementation of the SCP client protocol
90
93
  test_files:
91
94
  - test/test_all.rb