6
我需要使用Ruby解壓縮一個.rar文件。雖然我找不到寶石。
我發現了rar只允許創建檔案的gem。如何使用Ruby提取.rar檔案?
我stumpled約unrar可以經由gem 'unrar', git: '[email protected]:aileron/unrar.git'
安裝。這裏是使用它的一個粗略的草圖...
require 'unrar'
archive = Unrar.new('test.rar')
file_id = archive.list_contents.first[:filename]
File.open('output-name', 'w') { |file| file.write(archive.extract(file_id)) }
如果可能的話,我更喜歡寶石。我嘗試'gem'rar_file',git:'[email protected]:johanlunds/rar_file.git'沒有成功。 – JJD