2626[ ![ Liberapay Patrons] [ ⛳liberapay-img ]] [ ⛳liberapay ]
2727[ ![ Sponsor Me on Github] [ 🖇sponsor-img ]] [ 🖇sponsor ]
2828[ ![ Buy me a coffee] [ 🖇buyme-small-img ]] [ 🖇buyme ]
29- [ ![ Polar Shield ] [ 🖇polar-img ]] [ 🖇polar ]
29+ [ ![ Donate on Polar ] [ 🖇polar-img ]] [ 🖇polar ]
3030[ ![ Donate to my FLOSS or refugee efforts at ko-fi.com] [ 🖇kofi-img ]] [ 🖇kofi ]
3131[ ![ Donate to my FLOSS or refugee efforts using Patreon] [ 🖇patreon-img ]] [ 🖇patreon ]
3232
@@ -92,7 +92,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
9292
9393 $ gem install version_gem
9494
95- ## Usage
95+ ## Basic Usage
9696
9797In the standard ` bundle gem my_lib ` code you get the following in ` lib/my_lib/version.rb ` :
9898
162162
163163Your ` version.rb ` file now abides the Ruby convention of directory / path matching the namespace / class!
164164
165- ### Zeitwerk
165+ ## Epoch Usage (Epoch Semantic Versioning)
166+
167+ In the standard ` bundle gem my_lib ` code you get the following in ` lib/my_lib/version.rb ` :
168+
169+ ``` ruby
170+ module MyLib
171+ VERSION = " 0.1.0"
172+ end
173+ ```
174+
175+ Change it to a nested ` Version ` namespace (the one implied by the path => namespace convention):
176+
177+ ``` ruby
178+ module MyLib
179+ module Version
180+ VERSION = " 1024.3.8"
181+ end
182+ end
183+ ```
184+
185+ Now add the following near the top of the file the manages requiring external libraries.
186+ Using the same example of ` bundle gem my_lib ` , this would be ` lib/my_lib.rb ` .
187+
188+ ``` ruby
189+ require " version_gem"
190+ ```
191+
192+ Then, add the following wherever you want in the same file (recommend the bottom).
193+
194+ ``` ruby
195+ MyLib ::Version .class_eval do
196+ extend VersionGem ::Epoch
197+ end
198+ ```
199+
200+ And now you have some version introspection methods available:
201+
202+ ``` ruby
203+ MyLib ::Version .to_s # => "1024.3.8"
204+ MyLib ::Version .epoch # => 1
205+ MyLib ::Version .major # => 24
206+ MyLib ::Version .minor # => 3
207+ MyLib ::Version .patch # => 8
208+ MyLib ::Version .pre # => ""
209+ MyLib ::Version .to_a # => [1, 24, 3, 8]
210+ MyLib ::Version .to_h # => { epoch: 1, major: 24, minor: 3, patch: 8, pre: "" }
211+ ```
212+
213+ ## Usage with Zeitwerk
166214
167215The pattern of ` version.rb ` breaking the ruby convention of directory / path matching the namespace / class
168216is so entrenched that the ` zeitwerk ` library has a special carve-out for it. 🥺
@@ -312,11 +360,12 @@ Also see GitLab Contributors: [https://gitlab.com/oauth-xx/version_gem/-/graphs/
312360
313361## 📌 Versioning
314362
315- This Library adheres to [ ![ Semantic Versioning 2.0.0 ] [ 📌semver-img ]] [ 📌semver ] .
363+ This Library adheres to [ ![ Epoch Semantic Versioning] [ 📌semver-img ]] [ 📌semver ] .
316364Violations of this scheme should be reported as bugs.
317365Specifically, if a minor or patch version is released that breaks backward compatibility,
318366a new version should be immediately released that restores compatibility.
319- Breaking changes to the public API will only be introduced with new major versions.
367+ Breaking changes to the public API, including dropping a supported platform (i.e. minor version of Ruby), will only be introduced with new major versions.
368+ Epoch will only be bumped if there are dramatic changes, and that is not expected to happen ever.
320369
321370### 📌 Is "Platform Support" part of the public API?
322371
@@ -464,12 +513,15 @@ or one of the others at the head of this README.
464513[ ⛳liberapay ] : https://liberapay.com/pboling/donate
465514[ 🖇sponsor-img ] : https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
466515[ 🖇sponsor ] : https://github.com/sponsors/pboling
467- [ 🖇polar-img ] : https://polar.sh/embed/seeks-funding-shield .svg?org=pboling
516+ [ 🖇polar-img ] : https://img.shields.io/badge/polar-donate-yellow .svg
468517[ 🖇polar ] : https://polar.sh/pboling
469- [ 🖇kofi-img ] : https://img.shields.io/badge/buy_me_coffee-donate -yellow.svg
518+ [ 🖇kofi-img ] : https://img.shields.io/badge/a_more_different_coffee-✓ -yellow.svg
470519[ 🖇kofi ] : https://ko-fi.com/O5O86SNP4
471520[ 🖇patreon-img ] : https://img.shields.io/badge/patreon-donate-yellow.svg
472521[ 🖇patreon ] : https://patreon.com/galtzo
522+ [ 🖇buyme-img ] : https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20latte&emoji=&slug=pboling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff
523+ [ 🖇buyme ] : https://www.buymeacoffee.com/pboling
524+ [ 🖇buyme-small-img ] : https://img.shields.io/badge/buy_me_a_coffee-✓-yellow.svg?style=flat
473525[ 💎ruby-2.2i ] : https://img.shields.io/badge/Ruby-2.2-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
474526[ 💎ruby-2.3i ] : https://img.shields.io/badge/Ruby-2.3-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
475527[ 💎ruby-2.4i ] : https://img.shields.io/badge/Ruby-2.4-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
@@ -503,8 +555,8 @@ or one of the others at the head of this README.
503555[ 🪇conduct ] : CODE_OF_CONDUCT.md
504556[ 🪇conduct-img ] : https://img.shields.io/badge/Contributor_Covenant-2.1-4baaaa.svg
505557[ 📌pvc ] : http://guides.rubygems.org/patterns/#pessimistic-version-constraint
506- [ 📌semver ] : https://semver.org/spec/v2.0.0.html
507- [ 📌semver-img ] : https://img.shields.io/badge/semver-2.0.0 -FFDD67.svg?style=flat
558+ [ 📌semver ] : https://antfu.me/posts/epoch-semver
559+ [ 📌semver-img ] : https://img.shields.io/badge/epoch-semver -FFDD67.svg?style=flat
508560[ 📌semver-breaking ] : https://github.com/semver/semver/issues/716#issuecomment-869336139
509561[ 📌major-versions-not-sacred ] : https://tom.preston-werner.com/2022/05/23/major-version-numbers-are-not-sacred.html
510562[ 📌changelog ] : CHANGELOG.md
@@ -522,6 +574,3 @@ or one of the others at the head of this README.
522574[ 📄ilo-declaration-img ] : https://img.shields.io/badge/ILO_Fundamental_Principles-✓-brightgreen.svg?style=flat
523575[ 🚎yard-current ] : http://rubydoc.info/gems/version_gem
524576[ 🚎yard-head ] : https://rubydoc.info/github/oauth-xx/version_gem/main
525- [ 🖇buyme-img ] : https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20latte&emoji=&slug=pboling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff
526- [ 🖇buyme ] : https://www.buymeacoffee.com/pboling
527- [ 🖇buyme-small-img ] : https://img.shields.io/badge/Buy--Me--A--Coffee-✓-brightgreen.svg?style=flat
0 commit comments