分发 ruby 脚本的简单方法
我在一个文件夹中有一堆 ruby 脚本,这些脚本被添加到 $PATH
中,我认为其中一些可能对其他人有用。所以我想分发它们,我知道的唯一“好”方法是 rubygems(仅包含二进制文件的 gem),它具有非常有用的版本控制优势,但也有初始化时间的缺点(有时脚本开始之前需要几秒钟)跑步)。还有其他选择吗?
I have a bunch of ruby scripts in a folder which is added to $PATH
and I think that some of them might be usefult to others. So I want to distribute them and the only 'good' way I know is rubygems (gem containing only binary), it has a very useful advantage of versioning, but also a drawback of initialization time (sometimes it takes some seconds before script starts to run). Are there alternatives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Gem 对此已经足够好了。我使用 gem 来实现此目的,因为它的安装和更新非常方便。
Gem is good enought for this. I use gem for this purposes as it is very convenient to intall and update.
宝石就是为此而建造的。我不确定您认为 gem 是什么,但 RubyGems 是一个存储库,类似于 PHP 的 PEAR、ubuntu 的 aptitude 或 perl 的 CPAN,只不过它们包含 ruby 库。
通过将 ruby 库设为 gem,不会增加额外的开销或“初始化时间”。 RubyGems 只是安装您的库 - 它不执行任何其他操作。
Gems are built for this. I'm not sure what you think a gem is, but RubyGems is a repository like PEAR for PHP, aptitude for ubuntu, or CPAN for perl, except they contain ruby libraries.
There is no extra overhead or "initialization time" added to your ruby libraries by making them gems. RubyGems simply installs your library - it doesn't do anything else.
Gems 非常适合这种 Ruby 脚本。
要快速生成新的 gem,请尝试
捆绑 gem
< /a>.要在不使用 rubygems.org 的情况下快速分发 gem,并以可用于私有部署的方式,请查看 微型宝石。
如果您仍然认为不需要将它们包装在 gems 中,您可以简单地将可执行位添加到脚本中,为 ruby 添加 shebang 行,并删除
.rb
扩展名。然后与任何需要的人共享您的脚本文件。Gems are fine for this kind of Ruby script.
To quickly generate a new gem, try out
bundle gem
.To quickly distribute gems without using rubygems.org, and in a way that could work for private deployment, check out the idea for microgems.
If you still don't think you need to wrap these in gems, you can simply add the executable bit to your scripts, add shebang lines for ruby, and remove the
.rb
extension. Then share your script files with whoever wants them.