Skip to content

Commit 7a059cd

Browse files
authored
Merge branch 'master' into add-limit-argument
2 parents 5b33074 + 8af7582 commit 7a059cd

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

lib/net/sftp/operations/file.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ def print(*items)
153153
nil
154154
end
155155

156+
def size
157+
stat.size
158+
end
159+
160+
def rewind
161+
self.pos = 0
162+
end
163+
156164
# Writes each argument to the stream, appending a newline to any item
157165
# that does not already end in a newline. Array arguments are flattened.
158166
def puts(*items)

lib/net/sftp/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def to_i
5656

5757
# The prerelease component of this version of the Net::SFTP library
5858
# nil allowed
59-
PRE = "rc2"
59+
PRE = "rc3"
6060

6161
# The current version of the Net::SFTP library as a Version instance
6262
CURRENT = new(*[MAJOR, MINOR, TINY, PRE].compact)

net-sftp.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ Gem::Specification.new do |spec|
3131
spec.specification_version = 3
3232

3333
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
34-
spec.add_runtime_dependency(%q<net-ssh>, [">= 2.6.5", "< 5.0.0"])
34+
spec.add_runtime_dependency(%q<net-ssh>, [">= 2.6.5", "< 6.0.0"])
3535
spec.add_development_dependency(%q<test-unit>, [">= 0"])
3636
spec.add_development_dependency(%q<mocha>, [">= 0"])
3737
else
38-
spec.add_dependency(%q<net-ssh>, [">= 2.6.5", "< 5.0.0"])
38+
spec.add_dependency(%q<net-ssh>, [">= 2.6.5", "< 6.0.0"])
3939
spec.add_dependency(%q<test-unit>, [">= 0"])
4040
spec.add_dependency(%q<mocha>, [">= 0"])
4141
end
4242
else
43-
spec.add_dependency(%q<net-ssh>, [">= 2.6.5", "< 5.0.0"])
43+
spec.add_dependency(%q<net-ssh>, [">= 2.6.5", "< 6.0.0"])
4444
spec.add_dependency(%q<test-unit>, [">= 0"])
4545
spec.add_dependency(%q<mocha>, [">= 0"])
4646
end

test/test_file.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,20 @@ def test_stat_should_return_attributes_object_for_handle
196196
@sftp.expects(:fstat!).with("handle").returns(stat)
197197
assert_equal stat, @file.stat
198198
end
199+
200+
def test_size_should_return_size_from_stat
201+
stat = stub(size: 1024)
202+
@sftp.expects(:fstat!).with("handle").returns(stat)
203+
assert_equal 1024, @file.size
204+
end
205+
206+
def test_rewind
207+
@sftp.expects(:write!).with("handle", 0, "hello world\n")
208+
@sftp.expects(:read!).with("handle", 12, 8192).returns("hello world\n")
209+
@sftp.expects(:read!).with("handle", 0, 8192).returns("hello world\n")
210+
@file.puts "hello world\n"
211+
assert_equal "hello", @file.read(5)
212+
@file.rewind
213+
assert_equal "hello world", @file.read(11)
214+
end
199215
end

test/test_upload.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def prepare_directory
207207

208208
def expect_file(path, data)
209209
File.stubs(:directory?).with(path).returns(false)
210-
File.stubs(:exists?).with(path).returns(true)
210+
File.stubs(:exist?).with(path).returns(true)
211211
file = StringIO.new(data)
212212
file.stubs(:stat).returns(stub("stat", :size => data.length))
213213
File.stubs(:open).with(path, "rb").returns(file)

0 commit comments

Comments
 (0)