version_gem 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 779a53b7ab4b5e47e80eedc36f0551e2786886dcac2eb91928537bc9535793cd
4
- data.tar.gz: 8c51c4dc1e88dd9e144dc22197f3992096e2da71ab55e324ca59aec907a40eb1
3
+ metadata.gz: 90cc40b0bf2d460aecbcd09d57edcff0a7d5d57b364ecad37a006ffea01390bc
4
+ data.tar.gz: 48057a10145944f754e9ad2fbc3cf6892d36f742b684483cbebd4421d966b275
5
5
  SHA512:
6
- metadata.gz: 4944471f27fa5bf9013c4f1009ae0ae21f81fe92b345ff3f5a4b400861147dbbb67d10323222278dacb1b92a1f4eddf2e2fc6aef069e3e7b89d637507ee70518
7
- data.tar.gz: 7a030e85c153ec35b2075a18e24a3ba3f64b8fb6c7891f794beea9e45c7b4a130e32e6a350a397a4df3888981704696c2f1fb6d076a362da5fa0a578ed7326f9
6
+ metadata.gz: 3e2c38503358416ef03fd15c174d392228385d75c000b137394098367e27167a96221de652815c4b509376bfc432ce32ed384370b997b37c2e3a90fb3cdc32f8
7
+ data.tar.gz: ae251c1c3bd424472f94efa84c3b0d111d0d20054d442b116bb3ae7ad3a7b4afef690d408b157a32f64256dc1daefb8ade74ed7922e501d65cdc23e5003822c4
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -22,6 +22,19 @@ Please file a bug if you notice a violation of semantic versioning.
22
22
  ### Fixed
23
23
  ### Removed
24
24
 
25
+ ## [1.1.7] 2025-04-15 ([tag][1.1.7t])
26
+ - Line Coverage: 100.0% (117 / 117)
27
+ - Branch Coverage: 100.0% (4 / 4)
28
+ - 76.92% documented
29
+ ### Added
30
+ - Support for Epoch Semantic Versioning
31
+ - `extend VersionGem::Epoch` in your library's `MyLib::Version` module
32
+ - Support for JRuby 10 (@pboling)
33
+ - More documentation (@pboling)
34
+ ### Removed
35
+ - Ruby 2.2 removed from CI, though technically still supported
36
+ - can't run directly in GHA anymore
37
+
25
38
  ## [1.1.6] 2025-02-24 ([tag][1.1.6t])
26
39
  - Line Coverage: 100.0% (77 / 77)
27
40
  - Branch Coverage: 100.0% (2 / 2)
@@ -117,7 +130,9 @@ Please file a bug if you notice a violation of semantic versioning.
117
130
  ### Added
118
131
  - Initial release, with basic version parsing API (@pboling)
119
132
 
120
- [Unreleased]: https://gitlab.com/oauth-xx/version_gem/-/compare/v1.1.6...main
133
+ [Unreleased]: https://gitlab.com/oauth-xx/version_gem/-/compare/v1.1.7...main
134
+ [1.1.7]: https://gitlab.com/oauth-xx/version_gem/-/compare/v1.1.6...v1.1.7
135
+ [1.1.7t]: https://gitlab.com/oauth-xx/oauth2/-/tags/v1.1.7
121
136
  [1.1.6]: https://gitlab.com/oauth-xx/version_gem/-/compare/v1.1.5...v1.1.6
122
137
  [1.1.6t]: https://gitlab.com/oauth-xx/oauth2/-/tags/v1.1.6
123
138
  [1.1.5]: https://gitlab.com/oauth-xx/version_gem/-/compare/v1.1.4...v1.1.5
data/README.md CHANGED
@@ -17,7 +17,6 @@
17
17
  [![CI Legacy][🚎4-lg-wfi]][🚎4-lg-wf]
18
18
  [![CI Unsupported][🚎7-us-wfi]][🚎7-us-wf]
19
19
  [![CI Ancient][🚎1-an-wfi]][🚎1-an-wf]
20
- [![CI Hoary][🚎8-ho-wfi]][🚎8-ho-wf]
21
20
  [![CI Test Coverage][🚎2-cov-wfi]][🚎2-cov-wf]
22
21
  [![CI Style][🚎5-st-wfi]][🚎5-st-wf]
23
22
 
@@ -26,7 +25,7 @@
26
25
  [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay]
27
26
  [![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor]
28
27
  [![Buy me a coffee][🖇buyme-small-img]][🖇buyme]
29
- [![Polar Shield][🖇polar-img]][🖇polar]
28
+ [![Donate on Polar][🖇polar-img]][🖇polar]
30
29
  [![Donate to my FLOSS or refugee efforts at ko-fi.com][🖇kofi-img]][🖇kofi]
31
30
  [![Donate to my FLOSS or refugee efforts using Patreon][🖇patreon-img]][🖇patreon]
32
31
 
@@ -39,7 +38,7 @@ This gem has a very niche purpose, which is:
39
38
  3. allowing 100% test coverage of Ruby code, including the `Version` module.
40
39
 
41
40
  As proof in the pudding, this gem achieves 100% test coverage for lines and branches,
42
- all 77 and 2 of them, respectively; coverage enabled in part by patterns from this library.
41
+ all 117 and 4 of them, respectively; coverage enabled in part by patterns from this library.
43
42
  You can make it happen for your library too!
44
43
 
45
44
  If this isn't **precisely** your use case you may be better off looking at
@@ -70,10 +69,10 @@ This gem has no runtime dependencies.
70
69
 
71
70
  | Tokens to Remember | [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace] |
72
71
  |-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
73
- | Works with JRuby | [![JRuby 9.1 Compat][💎jruby-9.1i]][🚎10-j-wf] [![JRuby 9.2 Compat][💎jruby-9.2i]][🚎10-j-wf] [![JRuby 9.3 Compat][💎jruby-9.3i]][🚎10-j-wf] [![JRuby 9.4 Compat][💎jruby-c-i]][🚎11-c-wf] [![JRuby HEAD Compat][💎jruby-headi]][🚎3-hd-wf] |
72
+ | Works with JRuby | [![JRuby 9.1 Compat][💎jruby-9.1i]][🚎10-j-wf] [![JRuby 9.2 Compat][💎jruby-9.2i]][🚎10-j-wf] [![JRuby 9.3 Compat][💎jruby-9.3i]][🚎10-j-wf] [![JRuby 9.4 Compat][💎jruby-9.4i]][🚎10-j-wf] [![JRuby 10.0 Compat][💎jruby-c-i]][🚎11-c-wf] [![JRuby HEAD Compat][💎jruby-headi]][🚎3-hd-wf] |
74
73
  | Works with Truffle Ruby | [![Truffle Ruby 22.3 Compat][💎truby-22.3i]][🚎9-t-wf] [![Truffle Ruby 23.0 Compat][💎truby-23.0i]][🚎9-t-wf] [![Truffle Ruby 23.1 Compat][💎truby-23.1i]][🚎9-t-wf] [![Truffle Ruby 24.1 Compat][💎truby-c-i]][🚎11-c-wf] [![Truffle Ruby HEAD Compat][💎truby-headi]][🚎3-hd-wf] |
75
74
  | Works with MRI Ruby 3 | [![Ruby 3.0 Compat][💎ruby-3.0i]][🚎4-lg-wf] [![Ruby 3.1 Compat][💎ruby-3.1i]][🚎6-s-wf] [![Ruby 3.2 Compat][💎ruby-3.2i]][🚎6-s-wf] [![Ruby 3.3 Compat][💎ruby-3.3i]][🚎6-s-wf] [![Ruby 3.4 Compat][💎ruby-c-i]][🚎11-c-wf] [![Ruby HEAD Compat][💎ruby-headi]][🚎3-hd-wf] |
76
- | Works with MRI Ruby 2 | [![Ruby 2.2 Compat][💎ruby-2.2i]][🚎8-ho-wf] [![Ruby 2.3 Compat][💎ruby-2.3i]][🚎1-an-wf] [![Ruby 2.4 Compat][💎ruby-2.4i]][🚎1-an-wf] [![Ruby 2.5 Compat][💎ruby-2.5i]][🚎1-an-wf] [![Ruby 2.6 Compat][💎ruby-2.6i]][🚎7-us-wf] [![Ruby 2.7 Compat][💎ruby-2.7i]][🚎7-us-wf] |
75
+ | Works with MRI Ruby 2 | [![Ruby 2.3 Compat][💎ruby-2.3i]][🚎1-an-wf] [![Ruby 2.4 Compat][💎ruby-2.4i]][🚎1-an-wf] [![Ruby 2.5 Compat][💎ruby-2.5i]][🚎1-an-wf] [![Ruby 2.6 Compat][💎ruby-2.6i]][🚎7-us-wf] [![Ruby 2.7 Compat][💎ruby-2.7i]][🚎7-us-wf] |
77
76
  | Source | [![Source on GitLab.com][📜src-gl-img]][📜src-gl] [![Source on Github.com][📜src-gh-img]][📜src-gh] [![The best SHA: dQw4w9WgXcQ!][🧮kloc-img]][🧮kloc] |
78
77
  | Documentation | [![Current release on RubyDoc.info][📜docs-cr-rd-img]][🚎yard-current] [![HEAD on RubyDoc.info][📜docs-head-rd-img]][🚎yard-head] [![BDFL Blog][🚂bdfl-blog-img]][🚂bdfl-blog] [![Wiki][📜wiki-img]][📜wiki] |
79
78
  | Compliance | [![License: MIT][📄license-img]][📄license-ref] [![📄ilo-declaration-img]][📄ilo-declaration] [![Security Policy][🔐security-img]][🔐security] [![CodeQL][🖐codeQL-img]][🖐codeQL] [![Contributor Covenant 2.1][🪇conduct-img]][🪇conduct] [![SemVer 2.0.0][📌semver-img]][📌semver] [![Keep-A-Changelog 1.0.0][📗keep-changelog-img]][📗keep-changelog] |
@@ -92,7 +91,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
92
91
 
93
92
  $ gem install version_gem
94
93
 
95
- ## Usage
94
+ ## Basic Usage
96
95
 
97
96
  In the standard `bundle gem my_lib` code you get the following in `lib/my_lib/version.rb`:
98
97
 
@@ -162,7 +161,96 @@ end
162
161
 
163
162
  Your `version.rb` file now abides the Ruby convention of directory / path matching the namespace / class!
164
163
 
165
- ### Zietwerk
164
+ ## Epoch Usage (Epoch Semantic Versioning, as of version 1.1.7)
165
+
166
+ In the standard `bundle gem my_lib` code you get the following in `lib/my_lib/version.rb`:
167
+
168
+ ```ruby
169
+ module MyLib
170
+ VERSION = "0.1.0"
171
+ end
172
+ ```
173
+
174
+ Change it to a nested `Version` namespace (the one implied by the path => namespace convention):
175
+
176
+ ```ruby
177
+ module MyLib
178
+ module Version
179
+ VERSION = "0.1.0"
180
+ end
181
+ end
182
+ ```
183
+
184
+ The Epoch and Major versions are derived from the formula:
185
+
186
+ ```
187
+ {EPOCH * 1000 + MAJOR}.MINOR.PATCH
188
+ ```
189
+
190
+ This will start your library with the following version segments:
191
+
192
+ * `epoch = 0`
193
+ * `major = 0`
194
+ * `minor = 1`
195
+ * `patch = 0`
196
+ * `pre = nil`
197
+
198
+ And the segments are defined as:
199
+
200
+ ```
201
+ EPOCH: Increment when you make significant or groundbreaking changes.
202
+ MAJOR: Increment when you make minor incompatible API changes.
203
+ MINOR: Increment when you add functionality in a backwards-compatible manner.
204
+ PATCH: Increment when you make backwards-compatible bug fixes.
205
+ ```
206
+
207
+ Therefore, if you set your version number to:
208
+
209
+ ```ruby
210
+ VERSION = "27016.42.86-pre.7"
211
+ ```
212
+
213
+ You will get the following version segments:
214
+
215
+ ```
216
+ {
217
+ epoch: 27,
218
+ major: 16,
219
+ minor: 42,
220
+ patch: 86,
221
+ pre: "pre-7",
222
+ }
223
+ ```
224
+
225
+ Now add the following near the top of the file the manages requiring external libraries.
226
+ Using the same example of `bundle gem my_lib`, this would be `lib/my_lib.rb`.
227
+
228
+ ```ruby
229
+ require "version_gem"
230
+ ```
231
+
232
+ Then, add the following wherever you want in the same file (recommend the bottom).
233
+
234
+ ```ruby
235
+ MyLib::Version.class_eval do
236
+ extend VersionGem::Epoch
237
+ end
238
+ ```
239
+
240
+ And now you have some version introspection methods available:
241
+
242
+ ```ruby
243
+ MyLib::Version.to_s # => "1024.3.8"
244
+ MyLib::Version.epoch # => 1
245
+ MyLib::Version.major # => 24
246
+ MyLib::Version.minor # => 3
247
+ MyLib::Version.patch # => 8
248
+ MyLib::Version.pre # => ""
249
+ MyLib::Version.to_a # => [1, 24, 3, 8]
250
+ MyLib::Version.to_h # => { epoch: 1, major: 24, minor: 3, patch: 8, pre: "" }
251
+ ```
252
+
253
+ ## Usage with Zeitwerk
166
254
 
167
255
  The pattern of `version.rb` breaking the ruby convention of directory / path matching the namespace / class
168
256
  is so entrenched that the `zeitwerk` library has a special carve-out for it. 🥺
@@ -260,9 +348,11 @@ RSpec.describe(MyLib::Version) do
260
348
  expect(described_class).to(have_version_as_string)
261
349
  expect(described_class.to_s).to(be_a(String))
262
350
  expect(described_class).to(have_major_as_integer)
351
+ expect(described_class).to(have_epoch_as_integer)
263
352
  expect(described_class).to(have_minor_as_integer)
264
353
  expect(described_class).to(have_patch_as_integer)
265
354
  expect(described_class).to(have_pre_as_nil_or_string)
355
+ # This would be %i[epoch major minor patch pre] for epoch version schemes
266
356
  expect(described_class.to_h.keys).to(match_array(%i[major minor patch pre]))
267
357
  expect(described_class.to_a).to(be_a(Array))
268
358
  end
@@ -312,11 +402,13 @@ Also see GitLab Contributors: [https://gitlab.com/oauth-xx/version_gem/-/graphs/
312
402
 
313
403
  ## 📌 Versioning
314
404
 
315
- This Library adheres to [![Semantic Versioning 2.0.0][📌semver-img]][📌semver].
405
+ This Library adheres to [![Epoch Semantic Versioning][📌semver-img]][📌semver].
316
406
  Violations of this scheme should be reported as bugs.
317
407
  Specifically, if a minor or patch version is released that breaks backward compatibility,
318
408
  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.
409
+ Breaking changes to the public API, including dropping a supported platform (i.e. minor version of Ruby),
410
+ will only be introduced with new major versions.
411
+ Epoch will only be bumped if there are dramatic changes, and that is not expected to happen ever.
320
412
 
321
413
  ### 📌 Is "Platform Support" part of the public API?
322
414
 
@@ -426,10 +518,10 @@ or one of the others at the head of this README.
426
518
  [👽oss-helpi]: https://www.codetriage.com/oauth-xx/version_gem/badges/users.svg
427
519
  [👽version]: https://rubygems.org/gems/version_gem
428
520
  [👽versioni]: https://img.shields.io/gem/v/version_gem.svg
429
- [🔑cc-mnt]: https://codeclimate.com/github/oauth-xx/version_gem/maintainability
430
- [🔑cc-mnti♻️]: https://api.codeclimate.com/v1/badges/e26c543320ca0d14e871/maintainability
431
- [🔑cc-cov]: https://codeclimate.com/github/oauth-xx/version_gem/test_coverage
432
- [🔑cc-covi♻️]: https://api.codeclimate.com/v1/badges/e26c543320ca0d14e871/test_coverage
521
+ [🔑cc-mnt]: https://qlty.sh/gh/oauth-xx/projects/version_gem
522
+ [🔑cc-mnti♻️]: https://qlty.sh/badges/19404e90-9168-451a-8dac-882382cb768d/maintainability.svg
523
+ [🔑cc-cov]: https://qlty.sh/gh/oauth-xx/projects/version_gem
524
+ [🔑cc-covi♻️]: https://qlty.sh/badges/19404e90-9168-451a-8dac-882382cb768d/test_coverage.svg
433
525
  [🔑codecov]: https://codecov.io/gh/oauth-xx/version_gem
434
526
  [🔑codecovi♻️]: https://codecov.io/gh/oauth-xx/version_gem/branch/main/graph/badge.svg?token=cc6UdZCpAL
435
527
  [🔑coveralls]: https://coveralls.io/github/oauth-xx/version_gem?branch=main
@@ -452,8 +544,6 @@ or one of the others at the head of this README.
452
544
  [🚎6-s-wfi]: https://github.com/oauth-xx/version_gem/actions/workflows/supported.yml/badge.svg
453
545
  [🚎7-us-wf]: https://github.com/oauth-xx/version_gem/actions/workflows/unsupported.yml
454
546
  [🚎7-us-wfi]: https://github.com/oauth-xx/version_gem/actions/workflows/unsupported.yml/badge.svg
455
- [🚎8-ho-wf]: https://github.com/oauth-xx/version_gem/actions/workflows/hoary.yml
456
- [🚎8-ho-wfi]: https://github.com/oauth-xx/version_gem/actions/workflows/hoary.yml/badge.svg
457
547
  [🚎9-t-wf]: https://github.com/oauth-xx/version_gem/actions/workflows/truffle.yml
458
548
  [🚎9-t-wfi]: https://github.com/oauth-xx/version_gem/actions/workflows/truffle.yml/badge.svg
459
549
  [🚎10-j-wf]: https://github.com/oauth-xx/version_gem/actions/workflows/jruby.yml
@@ -464,13 +554,15 @@ or one of the others at the head of this README.
464
554
  [⛳liberapay]: https://liberapay.com/pboling/donate
465
555
  [🖇sponsor-img]: https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
466
556
  [🖇sponsor]: https://github.com/sponsors/pboling
467
- [🖇polar-img]: https://polar.sh/embed/seeks-funding-shield.svg?org=pboling
557
+ [🖇polar-img]: https://img.shields.io/badge/polar-donate-yellow.svg
468
558
  [🖇polar]: https://polar.sh/pboling
469
- [🖇kofi-img]: https://img.shields.io/badge/buy_me_coffee-donate-yellow.svg
559
+ [🖇kofi-img]: https://img.shields.io/badge/a_more_different_coffee-✓-yellow.svg
470
560
  [🖇kofi]: https://ko-fi.com/O5O86SNP4
471
561
  [🖇patreon-img]: https://img.shields.io/badge/patreon-donate-yellow.svg
472
562
  [🖇patreon]: https://patreon.com/galtzo
473
- [💎ruby-2.2i]: https://img.shields.io/badge/Ruby-2.2-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
563
+ [🖇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
564
+ [🖇buyme]: https://www.buymeacoffee.com/pboling
565
+ [🖇buyme-small-img]: https://img.shields.io/badge/buy_me_a_coffee-✓-yellow.svg?style=flat
474
566
  [💎ruby-2.3i]: https://img.shields.io/badge/Ruby-2.3-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
475
567
  [💎ruby-2.4i]: https://img.shields.io/badge/Ruby-2.4-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
476
568
  [💎ruby-2.5i]: https://img.shields.io/badge/Ruby-2.5-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
@@ -490,6 +582,7 @@ or one of the others at the head of this README.
490
582
  [💎jruby-9.1i]: https://img.shields.io/badge/JRuby-9.1-FBE742?style=for-the-badge&logo=ruby&logoColor=red
491
583
  [💎jruby-9.2i]: https://img.shields.io/badge/JRuby-9.2-FBE742?style=for-the-badge&logo=ruby&logoColor=red
492
584
  [💎jruby-9.3i]: https://img.shields.io/badge/JRuby-9.3-FBE742?style=for-the-badge&logo=ruby&logoColor=red
585
+ [💎jruby-9.4i]: https://img.shields.io/badge/JRuby-9.4-FBE742?style=for-the-badge&logo=ruby&logoColor=red
493
586
  [💎jruby-c-i]: https://img.shields.io/badge/JRuby-current-FBE742?style=for-the-badge&logo=ruby&logoColor=green
494
587
  [💎jruby-headi]: https://img.shields.io/badge/JRuby-HEAD-FBE742?style=for-the-badge&logo=ruby&logoColor=blue
495
588
  [🤝issues]: https://github.com/oauth-xx/version_gem/issues
@@ -503,15 +596,15 @@ or one of the others at the head of this README.
503
596
  [🪇conduct]: CODE_OF_CONDUCT.md
504
597
  [🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-2.1-4baaaa.svg
505
598
  [📌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
599
+ [📌semver]: https://antfu.me/posts/epoch-semver
600
+ [📌semver-img]: https://img.shields.io/badge/epoch-semver-FFDD67.svg?style=flat
508
601
  [📌semver-breaking]: https://github.com/semver/semver/issues/716#issuecomment-869336139
509
602
  [📌major-versions-not-sacred]: https://tom.preston-werner.com/2022/05/23/major-version-numbers-are-not-sacred.html
510
603
  [📌changelog]: CHANGELOG.md
511
604
  [📗keep-changelog]: https://keepachangelog.com/en/1.0.0/
512
605
  [📗keep-changelog-img]: https://img.shields.io/badge/keep--a--changelog-1.0.0-FFDD67.svg?style=flat
513
606
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
514
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.077-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
607
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.117-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
515
608
  [🔐security]: SECURITY.md
516
609
  [🔐security-img]: https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat
517
610
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -522,6 +615,3 @@ or one of the others at the head of this README.
522
615
  [📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-brightgreen.svg?style=flat
523
616
  [🚎yard-current]: http://rubydoc.info/gems/version_gem
524
617
  [🚎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
File without changes
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "error"
4
+ require_relative "api"
5
+
6
+ module VersionGem
7
+ # Support for Epoch Semantic Versioning
8
+ # See: https://antfu.me/posts/epoch-semver
9
+ module Epoch
10
+ EPOCH_SIZE = 1_000
11
+
12
+ class << self
13
+ def extended(base)
14
+ raise Error, "VERSION must be defined before 'extend #{name}'" unless defined?(base::VERSION)
15
+
16
+ base.extend(Api)
17
+ base.extend(OverloadApiForEpoch)
18
+ end
19
+ end
20
+
21
+ module OverloadApiForEpoch
22
+ # *** OVERLOAD METHODS FROM API ***
23
+ #
24
+ # The epoch version
25
+ #
26
+ # @return [Integer]
27
+ def epoch
28
+ @epoch ||= _major / EPOCH_SIZE
29
+ end
30
+
31
+ # The major version
32
+ #
33
+ # @return [Integer]
34
+ def major
35
+ @major ||= _major % EPOCH_SIZE
36
+ end
37
+
38
+ # The version number as a hash
39
+ #
40
+ # @return [Hash]
41
+ def to_h
42
+ @to_h ||= {
43
+ epoch: epoch,
44
+ major: major,
45
+ minor: minor,
46
+ patch: patch,
47
+ pre: pre,
48
+ }
49
+ end
50
+
51
+ # NOTE: This is not the same as _to_a, which returns an array of strings
52
+ #
53
+ # The version number as an array of cast values
54
+ # where epoch and major are derived from a single string:
55
+ # EPOCH * 1000 + MAJOR
56
+ #
57
+ # @return [Array<[Integer, String, NilClass]>]
58
+ def to_a
59
+ @to_a ||= [epoch, major, minor, patch, pre]
60
+ end
61
+
62
+ private
63
+
64
+ def _major
65
+ @_major ||= _to_a[0].to_i
66
+ end
67
+ end
68
+ end
69
+ end
@@ -12,6 +12,12 @@ RSpec::Matchers.define(:have_version_as_string) do
12
12
  end
13
13
  end
14
14
 
15
+ RSpec::Matchers.define(:have_epoch_as_integer) do
16
+ match do |version_mod|
17
+ version_mod.epoch.is_a?(Integer)
18
+ end
19
+ end
20
+
15
21
  RSpec::Matchers.define(:have_major_as_integer) do
16
22
  match do |version_mod|
17
23
  version_mod.major.is_a?(Integer)
@@ -52,3 +58,21 @@ RSpec.shared_examples_for("a Version module") do |version_mod|
52
58
  end
53
59
  end
54
60
  end
61
+
62
+ RSpec.shared_examples_for("an Epoch Version module") do |version_mod|
63
+ it "is introspectable" do
64
+ aggregate_failures "introspectable api" do
65
+ expect(version_mod).is_a?(Module)
66
+ expect(version_mod).to(have_version_constant)
67
+ expect(version_mod).to(have_version_as_string)
68
+ expect(version_mod.to_s).to(be_a(String))
69
+ expect(version_mod).to(have_epoch_as_integer)
70
+ expect(version_mod).to(have_major_as_integer)
71
+ expect(version_mod).to(have_minor_as_integer)
72
+ expect(version_mod).to(have_patch_as_integer)
73
+ expect(version_mod).to(have_pre_as_nil_or_string)
74
+ expect(version_mod.to_h.keys).to(match_array(%i[epoch major minor patch pre]))
75
+ expect(version_mod.to_a).to(be_a(Array))
76
+ end
77
+ end
78
+ end
@@ -2,11 +2,13 @@
2
2
 
3
3
  module VersionGem
4
4
  module Version
5
- VERSION = "1.1.6"
5
+ VERSION = "1.1.7"
6
6
  # This would work in this gem, but not in external libraries,
7
7
  # because version files are loaded in Gemspecs before bundler
8
8
  # has a chance to load dependencies.
9
9
  # Instead, see lib/version_gem.rb for a solution that will work everywhere
10
10
  # extend VersionGem::Basic
11
+ # or
12
+ # extend VersionGem::Epoch
11
13
  end
12
14
  end
data/lib/version_gem.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "version_gem/version"
4
4
  require_relative "version_gem/basic"
5
+ require_relative "version_gem/epoch"
5
6
 
6
7
  # Namespace of this library
7
8
  module VersionGem
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: version_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -35,7 +35,7 @@ cert_chain:
35
35
  I5o+DRfXQHqKucx1ldFHvI2rE/kSCWqGTHN2eyu1sqCPeOoIMxrltJhaejKPkxqj
36
36
  zaF9Og==
37
37
  -----END CERTIFICATE-----
38
- date: 2025-02-24 00:00:00.000000000 Z
38
+ date: 2025-04-15 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rspec
@@ -116,6 +116,7 @@ files:
116
116
  - lib/version_gem.rb
117
117
  - lib/version_gem/api.rb
118
118
  - lib/version_gem/basic.rb
119
+ - lib/version_gem/epoch.rb
119
120
  - lib/version_gem/error.rb
120
121
  - lib/version_gem/rspec.rb
121
122
  - lib/version_gem/ruby.rb
@@ -124,11 +125,11 @@ homepage: https://gitlab.com/oauth-xx/version_gem
124
125
  licenses:
125
126
  - MIT
126
127
  metadata:
127
- homepage_uri: https://gitlab.com/oauth-xx/version_gem
128
- source_code_uri: https://gitlab.com/oauth-xx/version_gem/-/tree/v1.1.6
129
- changelog_uri: https://gitlab.com/oauth-xx/version_gem/-/blob/v1.1.6/CHANGELOG.md
128
+ homepage_uri: https://railsbling.com/tags/version_gem/
129
+ source_code_uri: https://gitlab.com/oauth-xx/version_gem/-/tree/v1.1.7
130
+ changelog_uri: https://gitlab.com/oauth-xx/version_gem/-/blob/v1.1.7/CHANGELOG.md
130
131
  bug_tracker_uri: https://gitlab.com/oauth-xx/version_gem/-/issues
131
- documentation_uri: https://www.rubydoc.info/gems/version_gem/1.1.6
132
+ documentation_uri: https://www.rubydoc.info/gems/version_gem/1.1.7
132
133
  wiki_uri: https://gitlab.com/oauth-xx/version_gem/-/wiki
133
134
  mailing_list_uri: https://groups.google.com/g/oauth-ruby
134
135
  funding_uri: https://liberapay.com/pboling
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
155
  - !ruby/object:Gem::Version
155
156
  version: '0'
156
157
  requirements: []
157
- rubygems_version: 3.6.4
158
+ rubygems_version: 3.6.6
158
159
  specification_version: 4
159
160
  summary: Enhance your VERSION! Sugar for Version modules.
160
161
  test_files: []
metadata.gz.sig CHANGED
Binary file