26
26
[ ![ Liberapay Patrons] [ ⛳liberapay-img ]] [ ⛳liberapay ]
27
27
[ ![ Sponsor Me on Github] [ 🖇sponsor-img ]] [ 🖇sponsor ]
28
28
[ ![ Buy me a coffee] [ 🖇buyme-small-img ]] [ 🖇buyme ]
29
- [ ![ Polar Shield ] [ 🖇polar-img ]] [ 🖇polar ]
29
+ [ ![ Donate on Polar ] [ 🖇polar-img ]] [ 🖇polar ]
30
30
[ ![ Donate to my FLOSS or refugee efforts at ko-fi.com] [ 🖇kofi-img ]] [ 🖇kofi ]
31
31
[ ![ Donate to my FLOSS or refugee efforts using Patreon] [ 🖇patreon-img ]] [ 🖇patreon ]
32
32
@@ -92,7 +92,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
92
92
93
93
$ gem install version_gem
94
94
95
- ## Usage
95
+ ## Basic Usage
96
96
97
97
In the standard ` bundle gem my_lib ` code you get the following in ` lib/my_lib/version.rb ` :
98
98
162
162
163
163
Your ` version.rb ` file now abides the Ruby convention of directory / path matching the namespace / class!
164
164
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
166
214
167
215
The pattern of ` version.rb ` breaking the ruby convention of directory / path matching the namespace / class
168
216
is 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/
312
360
313
361
## 📌 Versioning
314
362
315
- This Library adheres to [ ![ Semantic Versioning 2.0.0 ] [ 📌semver-img ]] [ 📌semver ] .
363
+ This Library adheres to [ ![ Epoch Semantic Versioning] [ 📌semver-img ]] [ 📌semver ] .
316
364
Violations of this scheme should be reported as bugs.
317
365
Specifically, if a minor or patch version is released that breaks backward compatibility,
318
366
a 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.
320
369
321
370
### 📌 Is "Platform Support" part of the public API?
322
371
@@ -464,12 +513,15 @@ or one of the others at the head of this README.
464
513
[ ⛳liberapay ] : https://liberapay.com/pboling/donate
465
514
[ 🖇sponsor-img ] : https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
466
515
[ 🖇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
468
517
[ 🖇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
470
519
[ 🖇kofi ] : https://ko-fi.com/O5O86SNP4
471
520
[ 🖇patreon-img ] : https://img.shields.io/badge/patreon-donate-yellow.svg
472
521
[ 🖇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
473
525
[ 💎ruby-2.2i ] : https://img.shields.io/badge/Ruby-2.2-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
474
526
[ 💎ruby-2.3i ] : https://img.shields.io/badge/Ruby-2.3-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
475
527
[ 💎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.
503
555
[ 🪇conduct ] : CODE_OF_CONDUCT.md
504
556
[ 🪇conduct-img ] : https://img.shields.io/badge/Contributor_Covenant-2.1-4baaaa.svg
505
557
[ 📌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
508
560
[ 📌semver-breaking ] : https://github.com/semver/semver/issues/716#issuecomment-869336139
509
561
[ 📌major-versions-not-sacred ] : https://tom.preston-werner.com/2022/05/23/major-version-numbers-are-not-sacred.html
510
562
[ 📌changelog ] : CHANGELOG.md
@@ -522,6 +574,3 @@ or one of the others at the head of this README.
522
574
[ 📄ilo-declaration-img ] : https://img.shields.io/badge/ILO_Fundamental_Principles-✓-brightgreen.svg?style=flat
523
575
[ 🚎yard-current ] : http://rubydoc.info/gems/version_gem
524
576
[ 🚎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