From: gotoken@... (GOTO Kentaro) Date: 2000-08-23T22:14:43+09:00 Subject: [ruby-list:24408] Re: install guide draft ごとけんです In message "[ruby-list:24370] Re: install guide draft" on 00/08/22, kiri@pis.toba-cmt.ac.jp writes: >はい。厳密に言えばそれは http://www.freebsd.org/cgi/ports.cgi から捜す >ときにも同じことが言えると思います。したがって、確実に拾ってこようと思っ >たら ruby カテゴリーで引っ掛けるべきですね。ということで なるほど。current/INDEXを見ることにしました。いろいろどうもです。 -- gotoken % cat foo.rb require "net/ftp" remote_host = "ftp.freebsd.org" remote_index = "pub/FreeBSD/FreeBSD-current/ports/INDEX" local_index = "freebsd-current-ports-index" ftp = Net::FTP.open(remote_host,"anonymous") if not File::exist?(local_index) or File::size(local_index) != ftp.size(remote_index) or File::mtime(local_index) < ftp.mtime(remote_index) basename = File::basename(remote_index) STDERR.print "gettting #{basename}..." t, s, start = ftp.size(remote_index), 0, Time.now ftp.getbinaryfile(remote_index, local_index, 4096){|i| s += i.size r = (s.to_f/t * 100).to_i sec = (Time.now-start).to_i STDERR.print "\rgetting #{basename} #{s} of #{t} (#{r}%) #{sec}sec" } print "\n" else STDERR.print "#{local_index} is up to date. \n" end puts open(local_index).read. scan(/^([^\|]+)\|(?:[^\|]*\|){5}[^\|]*ruby/i). collect{|i| " * #{i}"}.sort