[#1651] A min/max bug? — "Christoph" <chr_news@...>
Hi,
[#1690] Re: open-uri patch, added progress_proc hook — Elliott Hughes <ehughes@...>
In effect. I mean that if a method's interface is getting too complicated,
In article <AD4480A509455343AEFACCC231BA850F17C358@ukexchange>,
On Sun, Nov 16, 2003 at 07:51:42PM +0900, Tanaka Akira wrote:
[#1699] FileUtils bug and fix — Chad Fowler <chad@...>
As posted in ruby-talk:85349, I believe there is a bug in FileUtils.cp's
[#1706] gc_sweep in Ruby 1.8 — Richard Kilmer <rich@...>
I posted about this before but Matz wanted me to post more detail.
>>>>> "R" == Richard Kilmer <rich@infoether.com> writes:
[#1711] Re: open-uri patch, added progress_proc hook — "T. Onoma" <transami@...>
Tanaka Akira:
On Sunday 23 November 2003 07:12 pm, Mathieu Bouchard wrote:
On Sunday 23 November 2003 08:26 pm, Mathieu Bouchard wrote:
On Sunday 23 November 2003 09:32 pm, Mathieu Bouchard wrote:
On Sunday 23 November 2003 11:13 pm, Mathieu Bouchard wrote:
On Mon, Nov 24, 2003 at 05:32:09AM +0900, Mathieu Bouchard wrote:
[#1716] Re: open-uri patch, added progress_proc hook — "T. Onoma" <transami@...>
Tanaka Akira:
[#1718] Re: open-uri patch, added progress_proc hook — Elliott Hughes <ehughes@...>
In article <AD4480A509455343AEFACCC231BA850F17C434@ukexchange>,
On Saturday 22 November 2003 04:34 pm, Tanaka Akira wrote:
In article <200311221024.05642.transami@runbox.com>,
On Sunday 23 November 2003 02:24 am, Tanaka Akira wrote:
In article <200311230325.21687.transami@runbox.com>,
On Sunday 23 November 2003 03:10 pm, Tanaka Akira wrote:
In article <200311230648.41003.transami@runbox.com>,
On Monday 24 November 2003 03:19, Tanaka Akira wrote:
Sean E Russell [mailto:ser@germane-software.com] wrote:
[#1753] gc_sweep under 1.8 ... not syck.so — Richard Kilmer <rich@...>
We still encountered a gc_sweep in our use of Ruby 1.8 on Linux (v8).
>>>>> "R" == Richard Kilmer <rich@infoether.com> writes:
Yes, there are several (Ruby) threads working during this gc_sweep.
>>>>> "R" == Richard Kilmer <rich@infoether.com> writes:
of course this effects 300 machines ;-)
>>>>> "R" == Richard Kilmer <rich@infoether.com> writes:
The saga continues:
>>>>> "R" == Richard Kilmer <rich@infoether.com> writes:
There is a discussion (found by chad fowler) on ruby-dev (22000)
[#1755] Re: Controlled block variables — Jamis Buck <jgb3@...>
On Mon, 2003-11-24 at 02:04, T. Onoma wrote:
On Monday 24 November 2003 05:22 pm, Jamis Buck wrote:
On Monday 24 November 2003 11:51, T. Onoma wrote:
On Monday 24 November 2003 06:40 pm, Sean E Russell wrote:
On Tue, 25 Nov 2003, T. Onoma wrote:
On Monday 24 November 2003 14:02, T. Onoma wrote:
On Monday 24 November 2003 09:15 pm, Sean E Russell wrote:
[#1799] Syck install on Debian Standard (Ruby 1.6.7) — "T. Onoma" <transami@...>
Hi, I'm having some trouble installing Syck on Debain (woody). I'm not
On Friday 28 November 2003 09:17 am, T. Onoma wrote:
On Fri, Nov 28, 2003 at 05:22:48PM +0900, T. Onoma wrote:
[#1819] Re: configure.in: do not override CCDLDFLAGS, LDFLAGS, XLDFLAGS — Eric Sunshine <sunshine@...>
Hello,
open-uri patch, added progress_proc hook
hi, i am not familiear with any procedures for submitting changes to a ruby lib, so fogive me if I have not done this correctly. please email me if i need to do something differnetly. thanks.
i have made a small modification to open-uri to allow it to execute a proc in the data fetching loops. this has proved very useful to me in providing a progress reported download. (i used Ruby/ProgressBar). Note that in the future it might be nice to get open-uri to work more like a real IO.
- T. Onoma
here is the diff -u (let me know if i need to prove in different way):
--- open-uri.rb 2003-05-15 20:19:09.000000000 +0200
+++ /usr/lib/ruby/1.8/open-uri.rb 2003-11-14 09:18:36.000000000 +0100
@@ -54,6 +54,9 @@
#
#Author:: Tanaka Akira <akr@m17n.org>
+#ChangeLog
+# 2003-11-14 Added pogress_proc hook. (T. Onoma <transami@runbox.com>)
+
require 'uri'
require 'stringio'
require 'time'
@@ -63,7 +66,7 @@
alias open_uri_original_open open # :nodoc:
# makes possible to open URIs.
- # If the first argument is URI::HTTP, URI::FTP or
+ # If the first argument is URI::HTTP, URI::FTP or
# String beginning with http:// or ftp://,
# the URI is opened.
# The opened file object is extended by OpenURI::Meta.
@@ -93,6 +96,7 @@
def OpenURI.open_uri(name, *rest) # :nodoc:
uri = URI::Generic === name ? name : URI.parse(name)
mode, perm, rest = OpenURI.scan_open_optional_arguments(*rest)
+ progress_proc = rest.shift if !rest.empty? && Proc === rest.first
options = rest.shift if !rest.empty? && Hash === rest.first
raise ArgumentError.new("extra arguments") if !rest.empty?
@@ -102,7 +106,7 @@
raise ArgumentError.new("invalid access mode #{mode} (#{uri.class} resource is read only.)")
end
- io = open_loop(uri, options || {})
+ io = open_loop(uri, options || {}, progress_proc)
if block_given?
begin
yield io
@@ -114,7 +118,7 @@
end
end
- def OpenURI.open_loop(uri, options) # :nodoc:
+ def OpenURI.open_loop(uri, options, progress_proc=nil) # :nodoc:
header = {}
options.each {|k, v|
if String === k
@@ -140,9 +144,9 @@
begin
buf = Buffer.new
if proxy_uri = find_proxy.call(uri)
- proxy_uri.proxy_open(buf, uri, header)
+ proxy_uri.proxy_open(buf, uri, header, progress_proc)
else
- uri.direct_open(buf, header)
+ uri.direct_open(buf, header, progress_proc)
end
rescue Redirect
loc = $!.uri
@@ -353,15 +357,18 @@
end
class HTTP
- def direct_open(buf, header) # :nodoc:
- proxy_open(buf, request_uri, header)
+ def direct_open(buf, header, progress_proc) # :nodoc:
+ proxy_open(buf, request_uri, header, progress_proc)
end
- def proxy_open(buf, uri, header) # :nodoc:
+ def proxy_open(buf, uri, header, progress_proc=nil) # :nodoc:
require 'net/http'
- resp = Net::HTTP.start(self.host, self.port) {|http|
- http.get(uri.to_s, header) {|str| buf << str}
- }
+ resp = Net::HTTP.start(self.host, self.port) { |http|
+ http.get(uri.to_s, header) { |str|
+ buf << str
+ progress_proc.call(buf.io.pos) if progress_proc
+ }
+ }
io = buf.io
io.rewind
io.status = [resp.code, resp.message]
@@ -382,9 +389,9 @@
end
class FTP
- def direct_open(buf, header) # :nodoc:
+ def direct_open(buf, header, progress_proc=nil) # :nodoc:
require 'net/ftp'
- # xxx: header is discarded.
+ # xxx: header is discarded.
# todo: extract user/passwd from .netrc.
user = 'anonymous'
passwd = nil
@@ -392,7 +399,10 @@
ftp = Net::FTP.open(self.host)
ftp.login(user, passwd)
- ftp.getbinaryfile(self.path, '/dev/null', Net::FTP::DEFAULT_BLOCKSIZE) {|str| buf << str}
+ ftp.getbinaryfile(self.path, '/dev/null', Net::FTP::DEFAULT_BLOCKSIZE) { |str|
+ buf << str
+ progress_proc.call(buf.io.pos) if progress_proc
+ }
ftp.close
buf.io.rewind
end