Question

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:

 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. 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.

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?

Was it helpful?

Solution

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.

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. 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:

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. Rubygems will detect the version from the gemspec and provide it using the more standard Gemfile entry format:

gem 'your-gem', '=0.1.0'

Or using the gem command:

gem install your-gem -v '=0.1.0'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top