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 } categories.each do |category| # puts "Creating #{ category }..." # # Category.create!( # name: category # ) ports = Pathname.glob("ports/#{ category }/*/").map { |i| i.basename.to_s } ports.each do |port| # puts "Creating #{ port }..." # # Port.create!( # name: port, # category_id: category.id, # summary: # description: # url: # ) # DOESN'T WORK puts description = File.read("ports/#{ category }/#{ port }/pkg/DESCR") end end # WORKS # puts file = File.read("ports/archivers/arc/pkg/DESCR")