简体   繁体   English

创建依赖于Rails的宝石,发布/测试策略

[英]Creating a Gem dependent on rails, strategy for publishing/testing

I am in the process of open sourcing a gem I wrote. 我正在开源我编写的宝石。 The gem handles cache more efficiently and you can tag your keys in groups. gem可以更有效地处理缓存,您可以按组标记密钥。

The thing is, the in order to test it you really need an application that connects to cache with Rails.cache, meaning the gem is dependent on Rails and you need to have an application to test it out. 事实是,要测试它,您确实需要一个使用Rails.cache连接到缓存的应用程序,这意味着gem依赖于Rails,您需要一个应用程序对其进行测试。

What's the strategy in open sourcing a gem like this, should my repository be a complete website and the gemspec point out only the spec and the lib directory? 开源这样的gem的策略是什么,我的存储库应该是一个完整的网站,gemspec仅指出spec和lib目录吗?

if you download the lib and spec alone, all of the tests will fail since Rails.cache is not accesible. 如果仅下载lib和spec,则所有测试都会失败,因为Rails.cache无法访问。

I would love suggestions about how to open source this sort of gem and how should my repository should look like. 我很乐意提供有关如何将此类gem开源以及我的存储库应如何显示的建议。

Thanks 谢谢

Your repository should only include the files related to the gem itself, a lot of people simply add rails as a development dependency(in the gemspec or Gemfile of your gem). 您的存储库应仅包含与gem本身相关的文件,很多人只是将rails添加为开发依赖项(在gem的gemspec或Gemfile中)。

TIP: To test your gem locally --before releasing the gem-- you can do the following: 提示:要在本地测试您的宝石(在发布宝石之前),您可以执行以下操作:

  • Package your gem 包装你的宝石

  • Create a new rails project(if you are using RVM creating a new gemset is recommendable) 创建一个新的Rails项目(如果使用RVM,建议创建一个新的gemset)

  • Include your gem in the Gemfile like this: 像这样在Gemfile中包含您的gem:

     gem 'your_gem' path=>'home/path_to_your_gem/your_gem' 
  • When you are ready release the gem ;) 当您准备好释放宝石时;)

I feel that as long as you specify in the README that the gem runs on top of rails you will be fine. 我觉得,只要您在自述文件中指定gem在导轨上运行,就可以了。

Hope this helps, 希望这可以帮助,

Jazmin 贾兹敏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM