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

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

问题描述

Bundler的发布有多大变化?有没有可以用作基地的模板?什么是最佳做法?

解决方案

有些帖子我发现有用:





编辑(2012-01-10):宝石最佳实践的全面指导是 RubyGems指南。我强烈建议现在从这里开始。



总结关键点:$ b​​
$ b


  • 为代码使用基本的 lib / gem.rb lib / gem / 结构。

  • 将任何可执行文件放入 bin 中,将 data 中的任何数据文件放入 test spec

  • 不要 require 或依赖加载路径之外的文件。 ( VERSION 文件通常似乎生活在宝石中的奇怪位置。)

  • 不要 require'rubygems'

  • 请勿篡改 $ LOAD_PATH

  • 如果您发现自己写了需要File.join(__ FILE__,'foo','bar'),那么您就错了。


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:

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

To summarize the key points:

  • 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天全站免登陆