What is the easiest way to read a text file inside a zip file in Ruby? Something similar to PHPfile_get_contents("zip://archive.zip#article.txt")
file_get_contents("zip://archive.zip#article.txt")
require 'zip/zip' Zip::ZipFile.new("archive.zip").read("article.txt")
Try
require 'zip/zip' Zip::ZipFile.open("my.zip", Zip::ZipFile::CREATE) {|zipfile| puts zipfile.read("first.txt")}
I think this should work:
require 'zipruby' Zip::Archive.open('archive.zip') do |ar| ar.fopen('article.txt') do |f| content = f.read # do sth end end