net-scp 1.0.2 → 1.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/CHANGELOG.rdoc +7 -0
- data/README.rdoc +1 -1
- data/Rakefile +71 -19
- data/lib/net/scp.rb +2 -5
- data/lib/net/scp/version.rb +1 -1
- data/net-scp.gemspec +4 -4
- data/test/common.rb +15 -0
- data/test/test_download.rb +15 -1
- data/test/test_upload.rb +15 -1
- metadata +29 -9
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 1.0.3 / 17 Aug 2010
|
2
|
+
|
3
|
+
* replace :sanitize_file_name with a call to String#shellescape [Sung Pae]
|
4
|
+
* Added gemspec file and removed echoe dependency [Miron Cuperman, Delano Mandelbaum]
|
5
|
+
* Removed Hanna dependency in Rakefile [Delano Mandelbaum]
|
6
|
+
|
7
|
+
|
1
8
|
=== 1.0.2 / 4 Feb 2009
|
2
9
|
|
3
10
|
* Escape spaces in file names on remote server [Jamis Buck]
|
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -1,30 +1,82 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'fileutils'
|
5
|
+
include FileUtils
|
3
6
|
|
4
7
|
begin
|
5
|
-
require '
|
8
|
+
require 'hanna/rdoctask'
|
6
9
|
rescue LoadError
|
7
|
-
|
10
|
+
require 'rake/rdoctask'
|
8
11
|
end
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
task :default => :package
|
14
|
+
|
15
|
+
# CONFIG =============================================================
|
16
|
+
|
17
|
+
# Change the following according to your needs
|
18
|
+
README = "README.rdoc"
|
19
|
+
CHANGES = "CHANGELOG.rdoc"
|
20
|
+
|
21
|
+
# Files and directories to be deleted when you run "rake clean"
|
22
|
+
CLEAN.include [ 'pkg', '*.gem', '.config', 'doc']
|
23
|
+
|
24
|
+
name = 'net-scp'
|
25
|
+
|
26
|
+
load "#{name}.gemspec"
|
27
|
+
version = @spec.version
|
28
|
+
|
29
|
+
# That's it! The following defaults should allow you to get started
|
30
|
+
# on other things.
|
31
|
+
|
32
|
+
|
33
|
+
# TESTS/SPECS =========================================================
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# INSTALL =============================================================
|
38
|
+
|
39
|
+
Rake::GemPackageTask.new(@spec) do |p|
|
40
|
+
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
41
|
+
end
|
42
|
+
|
43
|
+
task :release => [ :rdoc, :package ]
|
44
|
+
task :install => [ :rdoc, :package ] do
|
45
|
+
sh %{sudo gem install pkg/#{name}-#{version}.gem}
|
46
|
+
end
|
47
|
+
task :uninstall => [ :clean ] do
|
48
|
+
sh %{sudo gem uninstall #{name}}
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# RUBYFORGE RELEASE / PUBLISH TASKS ==================================
|
53
|
+
|
54
|
+
if @spec.rubyforge_project
|
55
|
+
desc 'Publish website to rubyforge'
|
56
|
+
task 'publish:rdoc' => 'doc/index.html' do
|
57
|
+
sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/ssh/v2/api/"
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'Public release to rubyforge'
|
61
|
+
task 'publish:gem' => [:package] do |t|
|
62
|
+
sh <<-end
|
63
|
+
rubyforge add_release -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
|
64
|
+
rubyforge add_file -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
|
65
|
+
end
|
66
|
+
end
|
13
67
|
end
|
14
68
|
|
15
|
-
Echoe.new('net-scp', version) do |p|
|
16
|
-
p.project = "net-ssh"
|
17
|
-
p.changelog = "CHANGELOG.rdoc"
|
18
69
|
|
19
|
-
p.author = "Jamis Buck"
|
20
|
-
p.email = "jamis@jamisbuck.org"
|
21
|
-
p.summary = "A pure Ruby implementation of the SCP client protocol"
|
22
|
-
p.url = "http://net-ssh.rubyforge.org/scp"
|
23
70
|
|
24
|
-
|
71
|
+
# RUBY DOCS TASK ==================================
|
25
72
|
|
26
|
-
|
27
|
-
|
73
|
+
Rake::RDocTask.new do |t|
|
74
|
+
t.rdoc_dir = 'doc'
|
75
|
+
t.title = @spec.summary
|
76
|
+
t.options << '--line-numbers' << '-A cattr_accessor=object'
|
77
|
+
t.options << '--charset' << 'utf-8'
|
78
|
+
t.rdoc_files.include(README)
|
79
|
+
t.rdoc_files.include(CHANGES)
|
80
|
+
t.rdoc_files.include('lib/**/*.rb')
|
81
|
+
end
|
28
82
|
|
29
|
-
p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/
|
30
|
-
end
|
data/lib/net/scp.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'stringio'
|
2
|
+
require 'shellwords'
|
2
3
|
|
3
4
|
require 'net/ssh'
|
4
5
|
require 'net/scp/errors'
|
@@ -337,7 +338,7 @@ module Net
|
|
337
338
|
# (See Net::SCP::Upload and Net::SCP::Download).
|
338
339
|
def start_command(mode, local, remote, options={}, &callback)
|
339
340
|
session.open_channel do |channel|
|
340
|
-
command = "#{scp_command(mode, options)} #{
|
341
|
+
command = "#{scp_command(mode, options)} #{remote.shellescape}"
|
341
342
|
channel.exec(command) do |ch, success|
|
342
343
|
if success
|
343
344
|
channel[:local ] = local
|
@@ -398,10 +399,6 @@ module Net
|
|
398
399
|
def progress_callback(channel, name, sent, total)
|
399
400
|
channel[:callback].call(channel, name, sent, total) if channel[:callback]
|
400
401
|
end
|
401
|
-
|
402
|
-
def sanitize_file_name(file_name)
|
403
|
-
file_name.gsub(/[ ]/) { |m| "\\#{m}" }
|
404
|
-
end
|
405
402
|
end
|
406
403
|
end
|
407
404
|
|
data/lib/net/scp/version.rb
CHANGED
data/net-scp.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
Gem::Specification.new do |s|
|
3
|
+
@spec = Gem::Specification.new do |s|
|
4
4
|
s.name = %q{net-scp}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Jamis Buck"]
|
9
|
-
s.date = %q{
|
8
|
+
s.authors = ["Jamis Buck", "Delano Mandelbaum"]
|
9
|
+
s.date = %q{2010-08-17}
|
10
10
|
s.description = %q{A pure Ruby implementation of the SCP client protocol}
|
11
11
|
s.email = %q{jamis@jamisbuck.org}
|
12
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"]
|
data/test/common.rb
CHANGED
@@ -54,6 +54,21 @@ class Net::SCP::TestCase < Test::Unit::TestCase
|
|
54
54
|
directory.stub!
|
55
55
|
end
|
56
56
|
|
57
|
+
# The POSIX spec unfortunately allows all characters in file names except
|
58
|
+
# ASCII 0x00(NUL) and 0x2F(/)
|
59
|
+
#
|
60
|
+
# Ideally, we should be testing filenames with newlines, but Mocha doesn't
|
61
|
+
# like this at all, so we leave them out. However, the Shellwords module
|
62
|
+
# handles newlines just fine, so we can be reasonably confident that they
|
63
|
+
# will work in practice
|
64
|
+
def awful_file_name
|
65
|
+
(((0x00..0x7f).to_a - [0x00, 0x0a, 0x2f]).map { |n| n.chr }).join + '.txt'
|
66
|
+
end
|
67
|
+
|
68
|
+
def escaped_file_name
|
69
|
+
"\\\001\\\002\\\003\\\004\\\005\\\006\\\a\\\b\\\t\\\v\\\f\\\r\\\016\\\017\\\020\\\021\\\022\\\023\\\024\\\025\\\026\\\027\\\030\\\031\\\032\\\e\\\034\\\035\\\036\\\037\\ \\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+,-.0123456789:\\;\\<\\=\\>\\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[\\\\\\]\\^_\\`abcdefghijklmnopqrstuvwxyz\\{\\|\\}\\~\\\177.txt"
|
70
|
+
end
|
71
|
+
|
57
72
|
class FileEntry
|
58
73
|
attr_reader :path, :contents, :mode, :mtime, :atime, :io
|
59
74
|
|
data/test/test_download.rb
CHANGED
@@ -11,7 +11,7 @@ class TestDownload < Net::SCP::TestCase
|
|
11
11
|
assert_scripted { scp.download!("/path/to/remote.txt", "/path/to/local.txt") }
|
12
12
|
assert_equal "a" * 1234, file.io.string
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def test_download_file_with_spaces_in_name_should_escape_remote_file_name
|
16
16
|
file = prepare_file("/path/to/local file.txt", "")
|
17
17
|
|
@@ -25,6 +25,20 @@ class TestDownload < Net::SCP::TestCase
|
|
25
25
|
|
26
26
|
assert_scripted { scp.download!("/path/to/remote file.txt", "/path/to/local file.txt") }
|
27
27
|
end
|
28
|
+
|
29
|
+
def test_download_file_with_metacharacters_in_name_should_escape_remote_file_name
|
30
|
+
file = prepare_file("/path/to/local/#{awful_file_name}", "")
|
31
|
+
|
32
|
+
expect_scp_session "-f /path/to/remote/#{escaped_file_name}" do |channel|
|
33
|
+
channel.sends_ok
|
34
|
+
channel.gets_data "C0666 0 #{awful_file_name}\n"
|
35
|
+
channel.sends_ok
|
36
|
+
channel.gets_ok
|
37
|
+
channel.sends_ok
|
38
|
+
end
|
39
|
+
|
40
|
+
assert_scripted { scp.download!("/path/to/remote/#{awful_file_name}", "/path/to/local/#{awful_file_name}") }
|
41
|
+
end
|
28
42
|
|
29
43
|
def test_download_with_preserve_should_send_times
|
30
44
|
file = prepare_file("/path/to/local.txt", "a" * 1234, 0644, Time.at(1234567890, 123456), Time.at(12121212, 232323))
|
data/test/test_upload.rb
CHANGED
@@ -15,7 +15,7 @@ class TestUpload < Net::SCP::TestCase
|
|
15
15
|
|
16
16
|
assert_scripted { scp.upload!("/path/to/local.txt", "/path/to/remote.txt") }
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def test_upload_file_with_spaces_in_name_should_escape_remote_file_name
|
20
20
|
prepare_file("/path/to/local file.txt", "")
|
21
21
|
|
@@ -29,6 +29,20 @@ class TestUpload < Net::SCP::TestCase
|
|
29
29
|
|
30
30
|
assert_scripted { scp.upload!("/path/to/local file.txt", "/path/to/remote file.txt") }
|
31
31
|
end
|
32
|
+
|
33
|
+
def test_upload_file_with_metacharacters_in_name_should_escape_remote_file_name
|
34
|
+
prepare_file("/path/to/local/#{awful_file_name}", "")
|
35
|
+
|
36
|
+
expect_scp_session "-t /path/to/remote/#{escaped_file_name}" do |channel|
|
37
|
+
channel.gets_ok
|
38
|
+
channel.sends_data "C0666 0 #{awful_file_name}\n"
|
39
|
+
channel.gets_ok
|
40
|
+
channel.sends_ok
|
41
|
+
channel.gets_ok
|
42
|
+
end
|
43
|
+
|
44
|
+
assert_scripted { scp.upload!("/path/to/local/#{awful_file_name}", "/path/to/remote/#{awful_file_name}") }
|
45
|
+
end
|
32
46
|
|
33
47
|
def test_upload_file_with_preserve_should_send_times
|
34
48
|
prepare_file("/path/to/local.txt", "a" * 1234, 0666, Time.at(1234567890, 123456), Time.at(1234543210, 345678))
|
metadata
CHANGED
@@ -1,27 +1,40 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-scp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Jamis Buck
|
14
|
+
- Delano Mandelbaum
|
8
15
|
autorequire:
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date:
|
19
|
+
date: 2010-08-17 00:00:00 -04:00
|
13
20
|
default_executable:
|
14
21
|
dependencies:
|
15
22
|
- !ruby/object:Gem::Dependency
|
16
23
|
name: net-ssh
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
20
27
|
requirements:
|
21
28
|
- - ">="
|
22
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 409
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 99
|
34
|
+
- 1
|
23
35
|
version: 1.99.1
|
24
|
-
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
25
38
|
description: A pure Ruby implementation of the SCP client protocol
|
26
39
|
email: jamis@jamisbuck.org
|
27
40
|
executables: []
|
@@ -72,21 +85,28 @@ rdoc_options:
|
|
72
85
|
require_paths:
|
73
86
|
- lib
|
74
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
75
89
|
requirements:
|
76
90
|
- - ">="
|
77
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
78
95
|
version: "0"
|
79
|
-
version:
|
80
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
81
98
|
requirements:
|
82
99
|
- - ">="
|
83
100
|
- !ruby/object:Gem::Version
|
101
|
+
hash: 11
|
102
|
+
segments:
|
103
|
+
- 1
|
104
|
+
- 2
|
84
105
|
version: "1.2"
|
85
|
-
version:
|
86
106
|
requirements: []
|
87
107
|
|
88
108
|
rubyforge_project: net-ssh
|
89
|
-
rubygems_version: 1.3.
|
109
|
+
rubygems_version: 1.3.7
|
90
110
|
signing_key:
|
91
111
|
specification_version: 3
|
92
112
|
summary: A pure Ruby implementation of the SCP client protocol
|