Skip to content

Commit 0f7e3b1

Browse files
authored
Merge pull request #6 from oauth-xx/epoch_semver
✨ Support for Epoch SemVer
2 parents d98edf3 + 052267e commit 0f7e3b1

File tree

10 files changed

+271
-58
lines changed

10 files changed

+271
-58
lines changed

Gemfile.lock

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
GIT
22
remote: https://github.com/pboling/appraisal
3-
revision: f5b830cb783ecb83e271c18c29c827af4986578d
3+
revision: a3a3e4b7db67d9b085f96b2ffddd2b51bd8a1196
44
branch: galtzo
55
specs:
66
appraisal (3.0.0.rc1)
77
bundler (>= 1.17.3)
88
rake (>= 10)
9-
thor (>= 0.14.0)
9+
thor (>= 0.14)
1010

1111
PATH
1212
remote: .
1313
specs:
14-
version_gem (1.1.6)
14+
version_gem (1.1.7)
1515

1616
GEM
1717
remote: https://rubygems.org/
1818
specs:
1919
ansi (1.5.0)
20-
ast (2.4.2)
21-
backports (3.25.0)
20+
ast (2.4.3)
21+
backports (3.25.1)
2222
benchmark (0.4.0)
2323
bigdecimal (3.1.9)
2424
bundler-audit (0.9.2)
@@ -30,7 +30,7 @@ GEM
3030
debug (1.10.0)
3131
irb (~> 1.10)
3232
reline (>= 0.3.8)
33-
diff-lcs (1.6.0)
33+
diff-lcs (1.6.1)
3434
diffy (3.4.3)
3535
docile (1.4.1)
3636
dry-configurable (1.3.0)
@@ -47,13 +47,13 @@ GEM
4747
concurrent-ruby (~> 1.0)
4848
dry-core (~> 1.1)
4949
zeitwerk (~> 2.6)
50-
dry-schema (1.13.4)
50+
dry-schema (1.14.1)
5151
concurrent-ruby (~> 1.0)
5252
dry-configurable (~> 1.0, >= 1.0.1)
53-
dry-core (~> 1.0, < 2)
54-
dry-initializer (~> 3.0)
55-
dry-logic (>= 1.4, < 2)
56-
dry-types (>= 1.7, < 2)
53+
dry-core (~> 1.1)
54+
dry-initializer (~> 3.2)
55+
dry-logic (~> 1.5)
56+
dry-types (~> 1.8)
5757
zeitwerk (~> 2.6)
5858
dry-types (1.8.2)
5959
bigdecimal (~> 3.0)
@@ -64,12 +64,12 @@ GEM
6464
zeitwerk (~> 2.6)
6565
github-markup (5.0.1)
6666
io-console (0.8.0)
67-
irb (1.15.1)
67+
irb (1.15.2)
6868
pp (>= 0.6.0)
6969
rdoc (>= 4.0.0)
7070
reline (>= 0.4.2)
71-
json (2.10.1)
72-
kettle-soup-cover (1.0.4)
71+
json (2.10.2)
72+
kettle-soup-cover (1.0.5)
7373
simplecov (~> 0.22)
7474
simplecov-cobertura (~> 2.1)
7575
simplecov-console (~> 0.9, >= 0.9.1)
@@ -80,16 +80,17 @@ GEM
8080
version_gem (~> 1.1, >= 1.1.4)
8181
language_server-protocol (3.17.0.4)
8282
lint_roller (1.1.0)
83-
logger (1.6.6)
83+
logger (1.7.0)
8484
method_source (1.1.0)
8585
ostruct (0.6.1)
8686
parallel (1.26.3)
87-
parser (3.3.7.1)
87+
parser (3.3.8.0)
8888
ast (~> 2.4.1)
8989
racc
9090
pp (0.6.2)
9191
prettyprint
9292
prettyprint (0.2.0)
93+
prism (1.4.0)
9394
pry (0.15.2)
9495
coderay (~> 1.1)
9596
method_source (~> 1.0)
@@ -99,17 +100,17 @@ GEM
99100
racc (1.8.1)
100101
rainbow (3.1.1)
101102
rake (13.2.1)
102-
rdoc (6.12.0)
103+
rdoc (6.13.1)
103104
psych (>= 4.0.0)
104-
redcarpet (3.6.0)
105-
reek (6.4.0)
106-
dry-schema (~> 1.13.0)
105+
redcarpet (3.6.1)
106+
reek (6.5.0)
107+
dry-schema (~> 1.13)
107108
logger (~> 1.6)
108109
parser (~> 3.3.0)
109110
rainbow (>= 2.0, < 4.0)
110111
rexml (~> 3.1)
111112
regexp_parser (2.10.0)
112-
reline (0.6.0)
113+
reline (0.6.1)
113114
io-console (~> 0.5)
114115
rexml (3.4.1)
115116
rspec (3.13.0)
@@ -126,18 +127,20 @@ GEM
126127
diff-lcs (>= 1.2.0, < 2.0)
127128
rspec-support (~> 3.13.0)
128129
rspec-support (3.13.2)
129-
rubocop (1.71.2)
130+
rubocop (1.75.2)
130131
json (~> 2.3)
131-
language_server-protocol (>= 3.17.0)
132+
language_server-protocol (~> 3.17.0.2)
133+
lint_roller (~> 1.1.0)
132134
parallel (~> 1.10)
133135
parser (>= 3.3.0.2)
134136
rainbow (>= 2.2.2, < 4.0)
135137
regexp_parser (>= 2.9.3, < 3.0)
136-
rubocop-ast (>= 1.38.0, < 2.0)
138+
rubocop-ast (>= 1.44.0, < 2.0)
137139
ruby-progressbar (~> 1.7)
138140
unicode-display_width (>= 2.4.0, < 4.0)
139-
rubocop-ast (1.38.0)
140-
parser (>= 3.3.1.0)
141+
rubocop-ast (1.44.1)
142+
parser (>= 3.3.7.2)
143+
prism (~> 1.4)
141144
rubocop-gradual (0.3.6)
142145
diff-lcs (>= 1.2.0, < 2.0)
143146
diffy (~> 3.0)
@@ -150,15 +153,19 @@ GEM
150153
version_gem (>= 1.1.2, < 3)
151154
rubocop-md (1.2.4)
152155
rubocop (>= 1.45)
153-
rubocop-packaging (0.5.2)
154-
rubocop (>= 1.33, < 2.0)
155-
rubocop-performance (1.23.1)
156-
rubocop (>= 1.48.1, < 2.0)
157-
rubocop-ast (>= 1.31.1, < 2.0)
158-
rubocop-rake (0.6.0)
159-
rubocop (~> 1.0)
160-
rubocop-rspec (3.4.0)
161-
rubocop (~> 1.61)
156+
rubocop-packaging (0.6.0)
157+
lint_roller (~> 1.1.0)
158+
rubocop (>= 1.72.1, < 2.0)
159+
rubocop-performance (1.25.0)
160+
lint_roller (~> 1.1)
161+
rubocop (>= 1.75.0, < 2.0)
162+
rubocop-ast (>= 1.38.0, < 2.0)
163+
rubocop-rake (0.7.1)
164+
lint_roller (~> 1.1)
165+
rubocop (>= 1.72.1)
166+
rubocop-rspec (3.5.0)
167+
lint_roller (~> 1.1)
168+
rubocop (~> 1.72, >= 1.72.1)
162169
rubocop-ruby2_2 (2.0.5)
163170
rubocop-gradual (~> 0.3, >= 0.3.1)
164171
rubocop-md (~> 1.2)
@@ -167,10 +174,11 @@ GEM
167174
rubocop-thread_safety (~> 0.5, >= 0.5.1)
168175
standard-rubocop-lts (~> 1.0, >= 1.0.7)
169176
version_gem (>= 1.1.3, < 3)
170-
rubocop-shopify (2.15.1)
171-
rubocop (~> 1.51)
172-
rubocop-thread_safety (0.6.0)
173-
rubocop (>= 1.48.1)
177+
rubocop-shopify (2.16.0)
178+
rubocop (~> 1.62)
179+
rubocop-thread_safety (0.7.2)
180+
lint_roller (~> 1.1)
181+
rubocop (~> 1.72, >= 1.72.1)
174182
ruby-progressbar (1.13.0)
175183
simplecov (0.22.0)
176184
docile (~> 1.1)
@@ -188,18 +196,18 @@ GEM
188196
simplecov-rcov (0.3.7)
189197
simplecov (>= 0.4.1)
190198
simplecov_json_formatter (0.1.4)
191-
standard (1.45.0)
199+
standard (1.49.0)
192200
language_server-protocol (~> 3.17.0.2)
193201
lint_roller (~> 1.0)
194-
rubocop (~> 1.71.0)
202+
rubocop (~> 1.75.2)
195203
standard-custom (~> 1.0.0)
196-
standard-performance (~> 1.6)
204+
standard-performance (~> 1.8)
197205
standard-custom (1.0.2)
198206
lint_roller (~> 1.0)
199207
rubocop (~> 1.50)
200-
standard-performance (1.6.0)
208+
standard-performance (1.8.0)
201209
lint_roller (~> 1.1)
202-
rubocop-performance (~> 1.23.0)
210+
rubocop-performance (~> 1.25.0)
203211
standard-rubocop-lts (1.0.10)
204212
rspec-block_is_expected (~> 1.0, >= 1.0.5)
205213
standard (>= 1.35.1, < 2)
@@ -208,7 +216,7 @@ GEM
208216
version_gem (>= 1.1.4, < 3)
209217
stone_checksums (1.0.0)
210218
version_gem (>= 1.1.5, < 3)
211-
stringio (3.1.5)
219+
stringio (3.1.6)
212220
terminal-table (4.0.0)
213221
unicode-display_width (>= 1.1.1, < 4)
214222
thor (1.3.2)

README.md

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
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

9797
In the standard `bundle gem my_lib` code you get the following in `lib/my_lib/version.rb`:
9898

@@ -162,7 +162,55 @@ end
162162

163163
Your `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

167215
The pattern of `version.rb` breaking the ruby convention of directory / path matching the namespace / class
168216
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/
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].
316364
Violations of this scheme should be reported as bugs.
317365
Specifically, if a minor or patch version is released that breaks backward compatibility,
318366
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.
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

lib/version_gem.rb

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require_relative "version_gem/version"
44
require_relative "version_gem/basic"
5+
require_relative "version_gem/epoch"
56

67
# Namespace of this library
78
module VersionGem

lib/version_gem/api.rb

100644100755
File mode changed.

0 commit comments

Comments
 (0)