[#1207] warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...>
This message was posted to ruby-talk, but I didn't get responce from
>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:
ts wrote:
>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:
ts wrote:
>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:
ts wrote:
>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:
ts wrote:
>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:
Hi,
[#1229] stack problem — Mathieu Bouchard <matju@...>
On Sat, Jul 12, 2003 at 01:59:53PM +0900, Mathieu Bouchard wrote:
On Tue, Jul 15, 2003 at 01:26:43AM +0900, Mathieu Bouchard wrote:
Hi,
[#1237] FTP.new with block — Gavin Sinclair <gsinclair@...>
Hi,
>>>>> "G" == Gavin Sinclair <gsinclair@soyabean.com.au> writes:
Hi,
Mathieu Bouchard wrote:
On Sun, Jul 20, 2003 at 03:06:13AM +0900, Dave Thomas wrote:
>>>>> "R" == Richard Zidlicky <rz@linux-m68k.org> writes:
On Sun, Jul 20, 2003 at 06:51:03PM +0900, ts wrote:
>>>>> "R" == Richard Zidlicky <rz@linux-m68k.org> writes:
On Mon, Jul 21, 2003 at 09:59:19PM +0900, ts wrote:
[#1249] File.write(path, data)? — Gavin Sinclair <gsinclair@...>
I am glad to see File.read(path) in Ruby 1.8. But what about
[#1256] testunit, exit status and at_exit — Dave Thomas <dave@...>
I'd really like TestUnit to be able to return an exit status when I run
-----BEGIN PGP SIGNED MESSAGE-----
Sean E. Russell [mailto:ser@germane-software.com] wrote:
Hi,
[#1257] Add have_defined() and rework have_struct_member() — Michal Rokos <m.rokos@...>
Hello,
[#1297] Fix for Bug 1058 — Markus Walser <walser@...>
Hi,
Hi,
On Friday 25 July 2003 10:58, Yukihiro Matsumoto wrote:
Hi,
On Friday 25 July 2003 11:46, Yukihiro Matsumoto wrote:
I tried to figure out what's wrong. So far I havn't a solution:
Hello,
> Check the value of klass by
Hi,
[#1309] exceptions and such — Mathieu Bouchard <matju@...>
[#1310] adding NodeDump and ii — nobu.nokada@...
Hi,
>>>>> "n" == nobu nokada <nobu.nokada@softhome.net> writes:
[Patch] FTP.new with block
Hi,
I've modified lib/net/ftp.rb (not committed, obviously) so that
FTP.new and FTP.open are like their File counterparts: they accept a
block, pass in the ftp object, and ensure the FTP connection is closed
at the end of (or premature exit from) the block.
Here is the extent of my testing:
irb(main):001:0>
irb(main):002:0* require 'net/ftp'
=> true
irb(main):003:0> Net::FTP.open('ftp.ruby-lang.org') do
irb(main):004:1* |ftp|
irb(main):005:1* ftp.login 'anonymous', 'guest'
irb(main):006:1> ftp.chdir 'pub/ruby'
irb(main):007:1> puts ftp.ls
irb(main):008:1> end
drwxr-xr-x 2 1001 users 4096 Jul 17 1998 1.0
drwxr-xr-x 2 1001 users 4096 Oct 7 1997 1.1a
drwxr-xr-x 2 1001 users 4096 Jul 16 1998 1.1b
[...]
drwxrwxr-x 2 1001 staff 4096 Jun 26 03:19 snapshots
lrwxrwxrwx 1 1001 users 3 Apr 5 2001 stable -> 1.6
-rw-r--r-- 1 1001 users 995195 Jul 18 19:00 stable-snapshot.tar.gz
=> #<Net::FTP:0x1016be50 @resume=false, @binary=true, @mon_entering_queue=[], @lastresp="226", @debu
g_mode=false, @mon_count=0, @welcome="230 Anonymous access granted, restrictions apply.\n", @return_
code="\n", @mon_owner=nil, @sock=#<TCPSocket:0x1016bd48>, @passive=false, @mon_waiting_queue=[]>
irb(main):009:0>
Patch follows signoff.
Gavin
Index: ftp.rb
===================================================================
RCS file: /src/ruby/lib/net/ftp.rb,v
retrieving revision 1.17
diff -u -r1.17 ftp.rb
--- ftp.rb 13 Jun 2003 00:26:51 -0000 1.17
+++ ftp.rb 19 Jul 2003 13:08:09 -0000
@@ -87,8 +87,8 @@
#
# A synonym for +FTP.new+, but with a mandatory host parameter.
#
- def FTP.open(host, user = nil, passwd = nil, acct = nil)
- new(host, user, passwd, acct)
+ def FTP.open(host, user = nil, passwd = nil, acct = nil, &block) # :yield: ftp
+ new(host, user, passwd, acct, &block)
end
#
@@ -96,7 +96,10 @@
# is made. Additionally, if the +user+ is given, the given user name,
# password, and (optionally) account are used to log in. See #login.
#
- def initialize(host = nil, user = nil, passwd = nil, acct = nil)
+ # If a block is given, it is passed the +FTP+ object, which will be closed
+ # when the block finishes, or when an exception is raised.
+ #
+ def initialize(host = nil, user = nil, passwd = nil, acct = nil) # :yield: ftp
super()
@binary = true
@passive = false
@@ -108,6 +111,13 @@
if user
login(user, passwd, acct)
end
+ end
+ if block_given?
+ begin
+ yield self
+ ensure
+ close
+ end
end
end