require "net/ftp" require "rubygems/package" require "pathname" ftp = Net::FTP.new("ftp.usa.openbsd.org") ftp.login ftp.chdir("pub/OpenBSD") latest_release = ftp.nlst latest_release = latest_release.grep(/\d/) latest_release = latest_release.max ftp.chdir(latest_release) ftp.getbinaryfile("ports.tar.gz") ftp.close tgz = File.open("ports.tar.gz", "rb") Gem::Package.new("").extract_tar_gz(tgz, "") categories = Pathname.glob("ports/*/").map { |i| i.basename.to_s } ports = Pathname.glob("ports/*/*/").map { |i| i.basename.to_s } categories.each do |category| Category.create!(...) end ports.each do |port| Port.create!(...) end