zipruby 还是 ruby​​zip?

发布于 2024-11-27 13:08:33 字数 165 浏览 6 评论 0原文

我这里有一个 ruby​​ on Rails 站点(rails 2.0.2,ruby 1.8.6),安装了 ruby​​zip 和 zipruby,但它们在 File.exists 上有冲突?方法,所以我想删除一个。关于未来最好的 zipping api 的普遍共识是什么?

两者相比是否有显着优势?

I've got a ruby on rails site here (rails 2.0.2, ruby 1.8.6) with both rubyzip and zipruby installed, but they conflict on the File.exists? method so I want to remove one. What's the general consensus out there on the best zipping api going forward?

Are there significant advantages of one over another?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

回忆躺在深渊里 2024-12-04 13:08:33

据我所知,rubyzip 有时会奇怪地处理 zip 文件,因为它自己处理 zip 文件索引和记录。例如,如果您使用 ruby​​zip 解压 docx 文件并重新打包,Microsoft Word 将无法打开它。但 zipruby 使用非常标准的 libzip C 库(有轻微的定制)并且不会破坏 docx。因此,如果您的目标是格式兼容性,我建议使用 zipruby。也许自从我尝试后 ruby​​zip 已经有所改进 - 但你应该自己尝试一下。

From what I've seen, rubyzip sometimes handles zip files strangely because it does its own handling of the zip file index and records. For example, if you use rubyzip to unpack a docx file and repack it, Microsoft Word won't open it. But zipruby uses the very standard libzip C library (with slight customizations) and won't mangle a docx. So if you're aiming for format compatibility, I'd suggest using zipruby. Maybe rubyzip has improved since I tried it - but you should try it yourself.

安人多梦 2024-12-04 13:08:33

完全随机的答案,因为我也从未尝试过:从当前状态来看,RubyZip 可能更有希望。从以下(少量)数据来看,RubyZip 更受欢迎,并且似乎与新版本的 Ruby 配合得更好:

RubyZip with 1.9: http://isitruby19.com/rubyzip

ZipRuby 1.9:http://isitruby19.com/zipruby

除非你得到更好的证据,否则我会选择 ruby​​Zip。另请参阅 哪些 zip 库适用于 Ruby 1.9.2 ?。然而,还有一个 RubyZip 的分支 (https://github.com/postmodern/rubyzip2)表明它的受欢迎程度。而且文档看起来更有趣。

Totally random answer, as I've never tried either: moving forward from your current state, RubyZip might be more promising. Judging from the following (scant) data, RubyZip is both more popular and seems to work better with new versions of Ruby:

RubyZip with 1.9: http://isitruby19.com/rubyzip

ZipRuby with 1.9: http://isitruby19.com/zipruby

Unless you get some better evidence, I'd go with rubyZip. Also see What zip library works well with Ruby 1.9.2?. However, there's also a fork of RubyZip (https://github.com/postmodern/rubyzip2) again pointing to its popularity. And the docs looks more interesting.

左耳近心 2024-12-04 13:08:33

我经常使用 https://github.com/toretore/zippy gem,我认为它相当好的。它是 ruby​​zip 的包装器,极大地简化了 zip 文件的操作。

I have used https://github.com/toretore/zippy gem a lot and I think it is quite good. It is wrapper for rubyzip and it dramatically simplifies operations with zip files.

仅此而已 2024-12-04 13:08:33

如果您只需要从 zip 文件中获取单个文件或几个文件,您可以尝试使用 Pinch ,它可以让您通过 ruby​​ 中的 http 提取文件

捏:通过网络从 zip 文件内检索文件!

If you only need to get a single file or a few files from a zipfile you can try to use Pinch which will let you extract a file over http in ruby

Pinch: Retrieve a file from inside a zip file, over the network!

故人爱我别走 2024-12-04 13:08:33

rubyzip 似乎不提供密码保护,而 zipruby 则提供: 链接

rubyzip does not appear to do password protection, while zipruby does: link

和我恋爱吧 2024-12-04 13:08:33

看来 ruby​​zip 可以为文件存储不正确的未压缩值,这会导致某些解压缩库(如 miniz)在解压缩时失败。 zipruby 看起来存储了正确的未压缩大小。我会选择 zipruby。

It appears that rubyzip can store the incorrect uncompressed value for a file, which causes some uncompression libraries (like miniz) to fail when uncompressing. zipruby looks like it stores the correct uncompressed size. I'm going to go with zipruby.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文