Has anyone already implemented a ruby script to check if a new ruby snapshot is available? Would be neat if it could do this without downloading the snapshot.
It seems the Ruby 1.8.1 snapshot is updated fairly frequently and the download page doesn't indicate the date/time stamp (so we periodically download, untar, ungzip and examine the timestamps manually).
You could write a script that FTP's to the server and uses the list
command to get the filestamp of the file and compare it to a filestamp
locally.
-ryan
···
On Sat, 10 Jul 2004 04:58:49 +0900, Randy Lawrence <jm@zzzzzzzzzzzz.com> wrote:
Has anyone already implemented a ruby script to check if a new ruby
snapshot is available? Would be neat if it could do this without
downloading the snapshot.
It seems the Ruby 1.8.1 snapshot is updated fairly frequently and the
download page doesn't indicate the date/time stamp (so we periodically
download, untar, ungzip and examine the timestamps manually).
You could write a script that FTP's to the server and uses the list
command to get the filestamp of the file and compare it to a filestamp
locally.
-ryan
Has anyone already implemented a ruby script to check if a new ruby
snapshot is available? Would be neat if it could do this without
downloading the snapshot.
It seems the Ruby 1.8.1 snapshot is updated fairly frequently and the
download page doesn't indicate the date/time stamp (so we periodically
download, untar, ungzip and examine the timestamps manually).
Yea, we just poked a hole in our firewall to allow ftp now. We were downloading to our public server, and then downloading to our lan. Now we can just connect directly.
···
On Sat, 10 Jul 2004 04:58:49 +0900, Randy Lawrence <jm@zzzzzzzzzzzz.com> wrote:
> Has anyone already implemented a ruby script to check if a new ruby
> snapshot is available? Would be neat if it could do this without
> downloading the snapshot.
>
> It seems the Ruby 1.8.1 snapshot is updated fairly frequently and the
> download page doesn't indicate the date/time stamp (so we periodically
> download, untar, ungzip and examine the timestamps manually).
You could write a script that FTP's to the server and uses the list
command to get the filestamp of the file and compare it to a filestamp
locally.
If it would save some of Matz' valuable bandwith, it's worth doing.
All you need to do is run this, then find out why it didn't do
what I expected on your machine.
File.utime isn't universally available (according to PickAxe I).
That often means "Windows has no chance", but it works for me.
daz
···
On Sat, 10 Jul 2004 04:58:49 +0900, Randy Lawrence wrote:
#---------------------------------------------------------------
# <ftp_snap.rb> -DfB- 2004/07/10
# Download stable-snapshot only if updated
# [Y,M,D,h,m] to Time
def pdt_to_time(pdt, now = Time.now)
unless pdt[1,4].compact.size==4
raise "#{pdt[1,4].inspect} ... expected [M, D, h, m]"
end
pdt[0] ||= now.year # assume year
pdt[0] -= 1 if pdt[1] > now.month # last year ?
Time.utc(*pdt[0,5])
end
require 'ParseDate'
require 'net/ftp'
ftp = Net::FTP.open(ftp_site)
END { ftp.close unless ftp.closed? }
ftp.login
##
ftp.chdir('/pub/lang/ruby')
fline = ftp.list(fn_snap)
if fline.empty?
ftp.chdir('/pub/ruby')
fline = ftp.list(fn_snap)
end
unless fline.size==1
puts '+++', fline, '+++'
raise "Multiple, or no files match \"#{fn_snap}\""
end
# <---- Jan..Dec ---->
fline[0] =~ /(\s[AFJMNOS][aceopu][b-y]\s.*)#{Regexp.quote(fn_snap)}\Z/
ft = pdt_to_time(ParseDate::parsedate($1))
ft_prev = File.exist?(fn_snap_save) ? File.mtime(fn_snap_save).utc : 0
if ft > ft_prev
if ft_prev > 0
puts "Replacing: #{ft_prev}"
else
puts "No previous snapshot found (first run)"
end
puts "Getting latest (#{ft}) ..."
ftp.getbinaryfile(fn_snap, fn_snap_save, 1024)
File.utime(ft, ft, fn_snap_save)
else
puts "Existing snapshot is current"
end
If it would save some of Matz' valuable bandwith, it's worth doing.
All you need to do is run this, then find out why it didn't do
what I expected on your machine.
File.utime isn't universally available (according to PickAxe I).
That often means "Windows has no chance", but it works for me.
daz
#---------------------------------------------------------------
# <ftp_snap.rb> -DfB- 2004/07/10
# Download stable-snapshot only if updated
# [Y,M,D,h,m] to Time
def pdt_to_time(pdt, now = Time.now)
unless pdt[1,4].compact.size==4
raise "#{pdt[1,4].inspect} ... expected [M, D, h, m]"
end
pdt[0] ||= now.year # assume year
pdt[0] -= 1 if pdt[1] > now.month # last year ?
Time.utc(*pdt[0,5])
end
require 'ParseDate'
require 'net/ftp'
ftp = Net::FTP.open(ftp_site)
END { ftp.close unless ftp.closed? }
ftp.login
##
ftp.chdir('/pub/lang/ruby')
fline = ftp.list(fn_snap)
if fline.empty?
ftp.chdir('/pub/ruby')
fline = ftp.list(fn_snap)
end
unless fline.size==1
puts '+++', fline, '+++'
raise "Multiple, or no files match \"#{fn_snap}\""
end
# <---- Jan..Dec ---->
fline[0] =~ /(\s[AFJMNOS][aceopu][b-y]\s.*)#{Regexp.quote(fn_snap)}\Z/
ft = pdt_to_time(ParseDate::parsedate($1))
ft_prev = File.exist?(fn_snap_save) ? File.mtime(fn_snap_save).utc : 0
if ft > ft_prev
if ft_prev > 0
puts "Replacing: #{ft_prev}"
else
puts "No previous snapshot found (first run)"
end
puts "Getting latest (#{ft}) ..."
ftp.getbinaryfile(fn_snap, fn_snap_save, 1024)
File.utime(ft, ft, fn_snap_save)
else
puts "Existing snapshot is current"
end
You are much to kind. Thank you very much!
Aside from the functionality, it is good for ruby beginners like me to see other people's ruby coding style.