From d5d6b149df3d2d565859599334327e378e5b2a84 Mon Sep 17 00:00:00 2001 From: shugo Date: Tue, 8 Sep 2015 06:08:20 +0000 Subject: [PATCH] * lib/net/ftp.rb (list): fetch all the lines before yielding a block to allow other commands in the block. [Feature #11454] Patched by Srikanth Shreenivas. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++ lib/net/ftp.rb | 15 ++--- test/net/ftp/test_ftp.rb | 140 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index a62145d4fc..a8665e2d88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Sep 8 15:01:19 2015 Shugo Maeda + + * lib/net/ftp.rb (list): fetch all the lines before yielding a block + to allow other commands in the block. [Feature #11454] + Patched by Srikanth Shreenivas. + Tue Sep 8 12:05:00 2015 NAKAMURA Usaku * win32/win32.c (rb_w32_read_reparse_point): return correct required diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index 3eec86ae99..724f4b85bd 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -755,15 +755,14 @@ module Net args.each do |arg| cmd = "#{cmd} #{arg}" end - if block - retrlines(cmd, &block) - else - lines = [] - retrlines(cmd) do |line| - lines << line - end - return lines + lines = [] + retrlines(cmd) do |line| + lines << line end + if block + lines.each(&block) + end + return lines end alias ls list alias dir list diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index 618a9da287..ad8ef5aa37 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -741,6 +741,146 @@ class FTPTest < Test::Unit::TestCase end end + def test_retrlines + commands = [] + text_data = <