Write it simple.

Use constants to specify the version of your gem

· 1 min read

When developing gems or external libraries we frequently write the semantic versioning as a string.

module MyGem
  VERSION = '1.4.0'

And when releasing a new version, git diff will show us this line was modified.

Why not use a constant for each semver element instead?

Rewriting the previous version like this:

module MyGem
  MAJOR = 1
  MINOR = 4
  PATCH = 0

It will allow us to keep our git diff clean when releasing, and also make our version string less prone to typos.

why-not, ruby, gems