diff --git a/ChangeLog b/ChangeLog index 65e48cc907..c91921fd56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 6 23:37:11 2010 Shugo Maeda + + * lib/net/ftp.rb (initialize): set @sock to a NullSocket instance to + raise FTPConnectionError when not connected. [ruby-dev:40258] + Sat Feb 6 23:25:57 2010 Shugo Maeda * ext/curses/view2.rb: replaced with Hugh Sasse's version. diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index 0bf1fb25ca..f393a15bff 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -25,6 +25,7 @@ module Net class FTPTempError < FTPError; end class FTPPermError < FTPError; end class FTPProtoError < FTPError; end + class FTPConnectionError < FTPError; end # :startdoc: # @@ -132,7 +133,7 @@ module Net @passive = false @debug_mode = false @resume = false - @sock = nil + @sock = NullSocket.new @logged_in = false if host connect(host) @@ -966,8 +967,15 @@ module Net return dirname end private :parse257 - end + # :stopdoc: + class NullSocket + def method_missing(mid, *args) + raise FTPConnectionError, "not connected" + end + end + # :startdoc: + end end