简体   繁体   English

在Rails应用程序中启动Ruby Gem版本控制

[英]Starting Ruby Gem versioning within a Rails application

I have a Rails application that is pointing to a gem which is on github (not yet pushed to Ruby Gems) and it is not yet versioned so when I run bundle it looks like this: 我有一个Rails应用程序,它指向github上的gem(尚未推送到Ruby Gems),并且尚未版本化,因此当我运行bundle时,它看起来像这样:

 gem (0.0.0) from git@github.com:company/gem.git (at master)

I have been working on changes to the gem and want to begin versioning it so when I push to master it doesn't break functionality in the Rails application that relies on the previous gem. 我一直在努力对gem进行更改,并希望开始对其进行版本控制,因此当我推动对其进行掌握时,它不会破坏依赖于先前gem的Rails应用程序中的功能。 I am not sophisticated enough to make the gem backwards compatible so I was thinking versioning would be the best way to handle this problem. 我不够成熟,无法使gem向后兼容,所以我认为版本控制将是解决此问题的最佳方法。

I am looking for advice on how to begin versioning this gem, is it simply changing the gemspec to 0.0.1 and then changing the gemfile in my Rails application to point to that? 我正在寻找有关如何开始对此gem进行版本控制的建议,是否只是将gemspec更改为0.0.1,然后在Rails应用程序中将gemfile更改为指向该版本?

As per semantic versioning , you should start off at 0.1.0 and increment the MAJOR version for any updates that are not backward compatible, the MINOR version if it only introduces new features but is backward compatible, and the TINY version if it's a bug fix or the like. 根据语义版本控制 ,您应该从0.1.0开始,并为不向后兼容的任何更新增加MAJOR版本;如果MINOR版本仅引入新功能但向后兼容,则增加MINOR版本;如果已修复错误,则为TINY版本。或类似的东西。

That said, if you are hosting via GitHub only, you can simply change the gemspec version to your preference as well as add a tag to that commit. 就是说,如果您仅通过GitHub托管,则可以简单地将gemspec版本更改为您的首选项,并为该提交添加标签。 Adding a tag makes it easy to find the correct version in GitHub after you've moved on to other versions - if using Bundler, for instance, your Gemfile entry would look like this: 添加标签后,您便可以轻松转到GitHub上的正确版本了-例如,如果使用Bundler,您的Gemfile条目将如下所示:

gem 'your-gem', git: 'git://github.com/your-repo/your-gem.git', tag: 'v0.1.0'

You could also use the following (lengthy) set of commands to do this without bundler: 您也可以使用以下(冗长的)命令集来执行此操作,而无需使用捆绑程序:

git clone git://github.com/your-repo/your-gem.git
cd your-gem
git checkout v0.1.0
gem build your-gem.gemspec
gem install your-gem-0.1.0.gem

If you intend to host via http://rubygems.org , you'll need to make yourself an account and then push your new version up to there. 如果您打算通过http://rubygems.org进行托管,则需要先注册一个帐户,然后再将新版本推送到该帐户。 Rubygems will detect the version from the gemspec and provide it using the more standard Gemfile entry format: Rubygems将检测来自gemspec的版本,并使用更标准的Gemfile输入格式提供它:

gem 'your-gem', '=0.1.0'

Or using the gem command: 或使用gem命令:

gem install your-gem -v '=0.1.0'

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

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