How to extract .rar archive using Ruby?

I need to unzip the .rar archive using Ruby. I could not find the stone. I discovered rar gem which allows you to create an archive.


I messed up unrar , which can be installed via gem 'unrar', git: ' git@github.com :aileron/unrar.git' . Here is an approximate sketch of its use ...

 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)) } 
+6
source share
1 answer

After some additional reading on this subject, it seems that any gems that were for this are mostly abandoned. But you can brew install unrar and use this from the Ruby system('unrar l your_file.rar') .

+4
source

Source: https://habr.com/ru/post/985543/


All Articles