构造红宝石的现代方法是什么? [英] What is the modern way to structure a ruby gem?
本文介绍了构造红宝石的现代方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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:
- http://chneukirchen.github.com/rps/
- http://tomayko.com/writings/require-rubygems-antipattern
- http://yehudakatz.com/2009/07/24/rubygems-良好实践/
- http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
编辑 (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.rb
和lib/gem/
结构. - 将所有可执行文件放入
bin
,将任何数据文件放入data
,将测试放入test
或spec
. - 不要
要求
或依赖加载路径之外的文件.(VERSION
文件似乎经常出现在 gems 中的奇怪位置.) - 不要
需要'rubygems'
. - 不要篡改
$LOAD_PATH
. - 如果你发现自己在写
require File.join(__FILE__, 'foo', 'bar')
,那你就错了.
- Use the basic
lib/gem.rb
andlib/gem/
structure for code. - Put any executables in
bin
, any data files indata
and tests intest
orspec
. - 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屋!
查看全文