构造红宝石的现代方法是什么? [英] What is the modern way to structure a ruby gem?

查看:18
本文介绍了构造红宝石的现代方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bundler 的发布发生了很大变化?有没有可以作为基础的模板?最佳做法是什么?

Has much changed with the release of Bundler? Is there a template that can be used as a base? What are the best practices?

推荐答案

一些我觉得有用的帖子:

Some posts that I have found useful:

编辑 (2012-01-10):RubyGems 指南.我强烈建议从现在开始.

Edit (2012-01-10): An excellent all-around guide to gem best practices is RubyGems Guides. I would highly recommend starting here now.

总结要点:

  • 对代码使用基本的 lib/gem.rblib/gem/ 结构.
  • 将所有可执行文件放入bin,将任何数据文件放入data,将测试放入testspec.
  • 不要要求或依赖加载路径之外的文件.(VERSION 文件似乎经常出现在 gems 中的奇怪位置.)
  • 不要需要'rubygems'.
  • 不要篡改 $LOAD_PATH.
  • 如果你发现自己在写 require File.join(__FILE__, 'foo', 'bar'),那你就错了.
  • Use the basic lib/gem.rb and lib/gem/ structure for code.
  • Put any executables in bin, any data files in data and tests in test or spec.
  • Don't require or depend upon files outside of the load path. (VERSION files often seem to live in odd places in gems.)
  • Do not require 'rubygems'.
  • Do not tamper with the $LOAD_PATH.
  • If you find yourself writing require File.join(__FILE__, 'foo', 'bar'), you're doing it wrong.

这篇关于构造红宝石的现代方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆