version_gem 1.0.0 → 1.1.0

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: d64ccd004d84d985193814b22b94eb0131e7d3de5d4414a775a82343ac3b88bb
4
- data.tar.gz: b99052895d88af63e8d5e217ca18d0161b8edca03ee4cd17e3a07cd2a8e8e3a5
3
+ metadata.gz: 21e250531f2630bae1d9b1961c58451b9bb25bcacff9e725ecfc8b58e5b23997
4
+ data.tar.gz: 236e288d1bc0ea792e86887555c716224e441448aae87b6a2d4e4f78d195c2d0
5
5
  SHA512:
6
- metadata.gz: d5ef0dac07a5548b9e6fd0f21eacfd16443acb196ad9c8f3fce45f851f74129fd2a30de5674bcebcb97ed73efc0d0cc0c71fd8b42a71d5d18a50282e33604d38
7
- data.tar.gz: c96480d2fcd3d8b0b0c3566a967a8f7dd197558301eb4075e6ad525eb179871f7f97256e65785b06ef5587f0229adcd8339ca9bee048908a2c6ed4d593439c5b
6
+ metadata.gz: 9dee2a6a560776eb93d8104fbe4e2c20e31a62172103972b94f636d1dd793d0c623674d78c31f8a21139167e4d09e48d292efd53d27a3de943349505e1d467f4
7
+ data.tar.gz: eecbc666ad24fd08d2516bc5c64b5ada2273fc153199dba97f089254eeb4fcefaa8d0e903832dae31c39108e1eb31301deb57c152b48f0c2f30e919558737266
data/CHANGELOG.md CHANGED
@@ -13,9 +13,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
 
14
14
  ### Removed
15
15
 
16
- s## [1.0.0] - 2022-06-21
16
+ ## [1.1.0] - 2022-06-24
17
+ ### Fixed
18
+ - to_a uses same type casting as major, minor, patch, and pre
19
+ ### Added
20
+ - RSpec Matchers and Shared Example
21
+
22
+ ## [1.0.2] - 2022-06-23
23
+ ### Added
24
+ - Delay loading of library code until after code coverage tool is loaded
25
+
26
+ ## [1.0.1] - 2022-06-23
27
+ ### Added
28
+ - CI Build improvements
29
+ - Code coverage reporting
30
+ - Documentation improvements
31
+ - Badges!
32
+
33
+ ## [1.0.0] - 2022-06-21
17
34
  ### Added
18
35
  - Initial release, with basic version parsing API
19
36
 
20
- [Unreleased]: https://github.com/pboling/version_gem/compare/v1.0.0...HEAD
37
+ [Unreleased]: https://github.com/pboling/version_gem/compare/v1.1.0...HEAD
38
+ [1.1.0]: https://github.com/pboling/version_gem/compare/v1.0.2...v1.1.0
39
+ [1.0.2]: https://github.com/pboling/version_gem/compare/v1.0.1...v1.0.2
40
+ [1.0.1]: https://github.com/pboling/version_gem/compare/v1.0.0...v1.0.1
21
41
  [1.0.0]: https://github.com/pboling/version_gem/compare/a3055964517c159bf214712940982034b75264be...v1.0.0
data/README.md CHANGED
@@ -14,6 +14,144 @@ MyLib::Version.to_h # => { major: 1, minor: 2, patch: 3, pre: "rc3" }
14
14
 
15
15
  This library was extracted from the gem [`oauth2`](https://github.com/oauth-xx/oauth2).
16
16
 
17
+ This gem has no runtime dependencies.
18
+
19
+ <!--
20
+ Numbering rows and badges in each row as a visual "database" lookup,
21
+ as the table is extremely dense, and it can be very difficult to find anything
22
+ Putting one on each row here, to document the emoji that should be used, and for ease of copy/paste.
23
+
24
+ row #s:
25
+ 1️⃣
26
+ 2️⃣
27
+ 3️⃣
28
+ 4️⃣
29
+ 5️⃣
30
+ 6️⃣
31
+ 7️⃣
32
+
33
+ badge #s:
34
+ ⛳️
35
+ 🖇
36
+ 🏘
37
+ 🚎
38
+ 🖐
39
+ 🧮
40
+ 📗
41
+
42
+ appended indicators:
43
+ ♻️ - URL needs to be updated from SASS integration. Find / Replace is insufficient.
44
+ -->
45
+
46
+ | | Project | bundle add version_gem |
47
+ |:----|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
48
+ | 1️⃣ | name, license, docs, standards | [![RubyGems.org][⛳️name-img]][⛳️gem] [![License: MIT][🖇src-license-img]][🖇src-license] [![RubyDoc.info][🚎yard-img]][🚎yard] [![SemVer 2.0.0][🧮semver-img]][semver] [![Keep-A-Changelog 1.0.0][📗keep-changelog-img]][📗keep-changelog] |
49
+ | 2️⃣ | version & activity | [![Gem Version][⛳️version-img]][⛳️gem] [![Total Downloads][🖇DL-total-img]][⛳️gem] [![Download Rank][🏘DL-rank-img]][⛳️gem] [![Source Code][🚎src-home-img]][🚎src-home] [![Open PRs][🖐prs-o-img]][🖐prs-o] [![Closed PRs][🧮prs-c-img]][🧮prs-c] <!--[![Next Version][📗next-img]][📗next]--> |
50
+ | 3️⃣ | maintanence & linting | [![Maintainability][⛳cclim-maint-img♻️]][⛳cclim-maint] [![Helpers][🖇triage-help-img]][🖇triage-help] [![Depfu][🏘depfu-img♻️]][🏘depfu♻️] [![Contributors][🚎contributors-img]][🚎contributors] [![Style][🖐style-wf-img]][🖐style-wf] [![Kloc Roll][🧮kloc-img]][🧮kloc] |
51
+ | 4️⃣ | testing | [![Open Issues][⛳iss-o-img]][⛳iss-o] [![Closed Issues][🖇iss-c-img]][🖇iss-c] [![Supported][🏘sup-wf-img]][🏘sup-wf] [![Heads][🚎heads-wf-img]][🚎heads-wf] [![Unofficial Support][🖐uns-wf-img]][🖐uns-wf] <!--[![MacOS][🧮mac-wf-img]][🧮mac-wf] [![Windows][📗win-wf-img]][📗win-wf]--> |
52
+ | 5️⃣ | coverage & security | [![CodeClimate][⛳cclim-cov-img♻️]][⛳cclim-cov] [![CodeCov][🖇codecov-img♻️]][🖇codecov] [![Coveralls][🏘coveralls-img]][🏘coveralls] [![Security Policy][🚎sec-pol-img]][🚎sec-pol] [![CodeQL][🖐codeQL-img]][🖐codeQL] [![Code Coverage][🧮cov-wf-img]][🧮cov-wf] |
53
+ | 6️⃣ | resources | [![Discussion][⛳gh-discussions-img]][⛳gh-discussions] [![Get help on Codementor][🖇codementor-img]][🖇codementor] [![Chat][🏘chat-img]][🏘chat] [![Blog][🚎blog-img]][🚎blog] [![Wiki][🖐wiki-img]][🖐wiki] |
54
+ | 7️⃣ | spread 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Tweet @ Peter][🏘tweet-img]][🏘tweet] [🌏][aboutme] [👼][angelme] [💻][coderme] |
55
+
56
+ <!--
57
+ The link tokens in the following sections should be kept ordered by the row and badge numbering scheme
58
+ -->
59
+
60
+ <!-- 1️⃣ name, license, docs -->
61
+ [⛳️gem]: https://rubygems.org/gems/version_gem
62
+ [⛳️name-img]: https://img.shields.io/badge/name-version_gem-brightgreen.svg?style=flat
63
+ [🖇src-license]: https://opensource.org/licenses/MIT
64
+ [🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg
65
+ [🚎yard]: https://www.rubydoc.info/github/pboling/version_gem
66
+ [🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat
67
+ [🧮semver-img]: https://img.shields.io/badge/semver-2.0.0-FFDD67.svg?style=flat
68
+ [📗keep-changelog]: https://keepachangelog.com/en/1.0.0/
69
+ [📗keep-changelog-img]: https://img.shields.io/badge/keep--a--changelog-1.0.0-FFDD67.svg?style=flat
70
+
71
+ <!-- 2️⃣ version & activity -->
72
+ [⛳️version-img]: http://img.shields.io/gem/v/version_gem.svg
73
+ [🖇DL-total-img]: https://img.shields.io/gem/dt/version_gem.svg
74
+ [🏘DL-rank-img]: https://img.shields.io/gem/rt/version_gem.svg
75
+ [🚎src-home]: https://github.com/pboling/version_gem
76
+ [🚎src-home-img]: https://img.shields.io/badge/source-github-brightgreen.svg?style=flat
77
+ [🖐prs-o]: https://github.com/pboling/version_gem/pulls
78
+ [🖐prs-o-img]: https://img.shields.io/github/issues-pr/pboling/version_gem
79
+ [🧮prs-c]: https://github.com/pboling/version_gem/pulls?q=is%3Apr+is%3Aclosed
80
+ [🧮prs-c-img]: https://img.shields.io/github/issues-pr-closed/pboling/version_gem
81
+ [📗next]: https://github.com/pboling/version_gem/milestone/1
82
+ [📗next-img]: https://img.shields.io/github/milestones/progress/pboling/version_gem/1?label=Next%20Version
83
+
84
+ <!-- 3️⃣ maintanence & linting -->
85
+ [⛳cclim-maint]: https://codeclimate.com/github/pboling/version_gem/maintainability
86
+ [⛳cclim-maint-img♻️]: https://api.codeclimate.com/v1/badges/b504d61c4ed1d46aec02/maintainability
87
+ [🖇triage-help]: https://www.codetriage.com/pboling/version_gem
88
+ [🖇triage-help-img]: https://www.codetriage.com/pboling/version_gem/badges/users.svg
89
+ [🏘depfu♻️]: https://depfu.com/github/pboling/version_gem?project_id=35803
90
+ [🏘depfu-img♻️]: https://badges.depfu.com/badges/5d8943de6cfdf1ee048ad6d907f3e35b/count.svg
91
+ [🚎contributors]: https://github.com/pboling/version_gem/graphs/contributors
92
+ [🚎contributors-img]: https://img.shields.io/github/contributors-anon/pboling/version_gem
93
+ [🖐style-wf]: https://github.com/pboling/version_gem/actions/workflows/style.yml
94
+ [🖐style-wf-img]: https://github.com/pboling/version_gem/actions/workflows/style.yml/badge.svg
95
+ [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
96
+ [🧮kloc-img]: https://img.shields.io/tokei/lines/github.com/pboling/version_gem
97
+
98
+ <!-- 4️⃣ testing -->
99
+ [⛳iss-o]: https://github.com/pboling/version_gem/issues
100
+ [⛳iss-o-img]: https://img.shields.io/github/issues-raw/pboling/version_gem
101
+ [🖇iss-c]: https://github.com/pboling/version_gem/issues?q=is%3Aissue+is%3Aclosed
102
+ [🖇iss-c-img]: https://img.shields.io/github/issues-closed-raw/pboling/version_gem
103
+ [🏘sup-wf]: https://github.com/pboling/version_gem/actions/workflows/supported.yml
104
+ [🏘sup-wf-img]: https://github.com/pboling/version_gem/actions/workflows/supported.yml/badge.svg
105
+ [🚎heads-wf]: https://github.com/pboling/version_gem/actions/workflows/heads.yml
106
+ [🚎heads-wf-img]: https://github.com/pboling/version_gem/actions/workflows/heads.yml/badge.svg
107
+ [🖐uns-wf]: https://github.com/pboling/version_gem/actions/workflows/unsupported.yml
108
+ [🖐uns-wf-img]: https://github.com/pboling/version_gem/actions/workflows/unsupported.yml/badge.svg
109
+ [🧮mac-wf]: https://github.com/pboling/version_gem/actions/workflows/macos.yml
110
+ [🧮mac-wf-img]: https://github.com/pboling/version_gem/actions/workflows/macos.yml/badge.svg
111
+ [📗win-wf]: https://github.com/pboling/version_gem/actions/workflows/windows.yml
112
+ [📗win-wf-img]: https://github.com/pboling/version_gem/actions/workflows/windows.yml/badge.svg
113
+
114
+ <!-- 5️⃣ coverage & security -->
115
+ [⛳cclim-cov]: https://codeclimate.com/github/pboling/version_gem/test_coverage
116
+ [⛳cclim-cov-img♻️]: https://api.codeclimate.com/v1/badges/b504d61c4ed1d46aec02/test_coverage
117
+ [🖇codecov-img♻️]: https://codecov.io/gh/pboling/version_gem/branch/main/graph/badge.svg?token=79c3X4vtfO
118
+ [🖇codecov]: https://codecov.io/gh/pboling/version_gem
119
+ [🏘coveralls]: https://coveralls.io/github/pboling/version_gem?branch=main
120
+ [🏘coveralls-img]: https://coveralls.io/repos/github/pboling/version_gem/badge.svg?branch=main
121
+ [🚎sec-pol]: https://github.com/pboling/version_gem/blob/main/SECURITY.md
122
+ [🚎sec-pol-img]: https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat
123
+ [🖐codeQL]: https://github.com/pboling/version_gem/security/code-scanning
124
+ [🖐codeQL-img]: https://github.com/pboling/version_gem/actions/workflows/codeql-analysis.yml/badge.svg
125
+ [🧮cov-wf]: https://github.com/pboling/version_gem/actions/workflows/coverage.yml
126
+ [🧮cov-wf-img]: https://github.com/pboling/version_gem/actions/workflows/coverage.yml/badge.svg
127
+
128
+ <!-- 6️⃣ resources -->
129
+ [⛳gh-discussions]: https://github.com/pboling/version_gem/discussions
130
+ [⛳gh-discussions-img]: https://img.shields.io/github/discussions/pboling/version_gem
131
+ [🖇codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
132
+ [🖇codementor-img]: https://cdn.codementor.io/badges/get_help_github.svg
133
+ [🏘chat]: https://gitter.im/pboling/version_gem
134
+ [🏘chat-img]: https://img.shields.io/gitter/room/pboling/version_gem.svg
135
+ [🚎blog]: http://www.railsbling.com/tags/version_gem/
136
+ [🚎blog-img]: https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat
137
+ [🖐wiki]: https://github.com/pboling/version_gem/wiki
138
+ [🖐wiki-img]: https://img.shields.io/badge/wiki-examples-brightgreen.svg?style=flat
139
+
140
+ <!-- 7️⃣ spread 💖 -->
141
+ [⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
142
+ [⛳liberapay]: https://liberapay.com/pboling/donate
143
+ [🖇sponsor-img]: https://img.shields.io/badge/sponsor-pboling.svg?style=social&logo=github
144
+ [🖇sponsor]: https://github.com/sponsors/pboling
145
+ [🏘tweet-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
146
+ [🏘tweet]: http://twitter.com/galtzo
147
+
148
+ <!-- Maintainer Contact Links -->
149
+ [railsbling]: http://www.railsbling.com
150
+ [peterboling]: http://www.peterboling.com
151
+ [aboutme]: https://about.me/peter.boling
152
+ [angelme]: https://angel.co/peter-boling
153
+ [coderme]:http://coderwall.com/pboling
154
+
17
155
  ## Installation
18
156
 
19
157
  Install the gem and add to the application's Gemfile by executing:
@@ -26,7 +164,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
26
164
 
27
165
  ## Usage
28
166
 
29
- In the standard `bundle gem my_lib` code you get the following in `lib/my_lib/version.rb:
167
+ In the standard `bundle gem my_lib` code you get the following in `lib/my_lib/version.rb`:
30
168
 
31
169
  ```ruby
32
170
  module MyLib
@@ -34,7 +172,7 @@ module MyLib
34
172
  end
35
173
  ```
36
174
 
37
- Add a Version namespace (the one implied by the path => namespace convention):
175
+ Change it to a nested `Version` namespace (the one implied by the path => namespace convention):
38
176
 
39
177
  ```ruby
40
178
  module MyLib
@@ -75,6 +213,43 @@ MyLib::Version.to_h # => { major: 0, minor: 1, patch: 0, pre: "" }
75
213
 
76
214
  Your `version.rb` file now abides the Ruby convention of directory / path matching the namespace / class!
77
215
 
216
+ ### Caveat
217
+
218
+ This design keeps your `version.rb` file compatible with the way `gemspec` files use them.
219
+ This means that the introspection is _not_ available within the gemspec.
220
+ The enhancement from this gem is only available at runtime.
221
+
222
+ ### RSpec Matchers
223
+
224
+ In `spec_helper.rb`:
225
+ ```ruby
226
+ require 'version_gem/rspec'
227
+ ```
228
+
229
+ Then you can write a test like:
230
+
231
+ ```ruby
232
+ RSpec.describe MyLib::Version do
233
+ it_behaves_like 'a Version module', described_class
234
+ end
235
+
236
+ # Or, if you want to write your own, here is the a la carte menu:
237
+ RSpec.describe MyLib::Version do
238
+ it "is a Version module" do
239
+ expect(described_class).is_a?(Module)
240
+ expect(described_class).to have_version_constant
241
+ expect(described_class).to have_version_as_string
242
+ expect(described_class.to_s).to be_a(String)
243
+ expect(described_class).to have_major_as_integer
244
+ expect(described_class).to have_minor_as_integer
245
+ expect(described_class).to have_patch_as_integer
246
+ expect(described_class).to have_pre_as_nil_or_string
247
+ expect(described_class.to_h.keys).to match_array(%i[major minor patch pre])
248
+ expect(described_class.to_a).to be_a(Array)
249
+ end
250
+ end
251
+ ```
252
+
78
253
  ## Development
79
254
 
80
255
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -83,12 +258,104 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
83
258
 
84
259
  ## Contributing
85
260
 
86
- Bug reports and pull requests are welcome on GitHub at https://github.com/pboling/version_gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/pboling/version_gem/blob/main/CODE_OF_CONDUCT.md).
261
+ See [CONTRIBUTING.md][contributing]
262
+
263
+ ## Contributors
264
+
265
+ [![Contributors](https://contrib.rocks/image?repo=pboling/version_gem)]("https://github.com/pboling/version_gem/graphs/contributors")
266
+
267
+ Made with [contributors-img](https://contrib.rocks).
87
268
 
88
269
  ## License
89
270
 
90
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
271
+ The gem is available as open source under the terms of
272
+ the [MIT License][license] [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)][license-ref].
273
+ See [LICENSE][license] for the official [Copyright Notice][copyright-notice-explainer].
274
+
275
+ * Copyright (c) 2022 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
91
276
 
92
277
  ## Code of Conduct
93
278
 
94
279
  Everyone interacting in the VersionGem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pboling/version_gem/blob/main/CODE_OF_CONDUCT.md).
280
+
281
+ ## Versioning
282
+
283
+ This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as
284
+ bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be
285
+ immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new
286
+ major versions.
287
+
288
+ As a result of this policy, you can (and should) specify a dependency on this gem using
289
+ the [Pessimistic Version Constraint][pvc] with two digits of precision.
290
+
291
+ For example:
292
+
293
+ ```ruby
294
+ spec.add_dependency "version_gem", "~> 1.1"
295
+ ```
296
+
297
+ ## Security
298
+
299
+ See [SECURITY.md](https://github.com/pboling/version_gem/blob/main/SECURITY.md).
300
+
301
+ [copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
302
+
303
+ [gh_discussions]: https://github.com/pboling/version_gem/discussions
304
+
305
+ [conduct]: https://github.com/pboling/version_gem/blob/main/CODE_OF_CONDUCT.md
306
+
307
+ [contributing]: https://github.com/pboling/version_gem/blob/main/CONTRIBUTING.md
308
+
309
+ [security]: https://github.com/pboling/version_gem/blob/main/SECURITY.md
310
+
311
+ [license]: https://github.com/pboling/version_gem/blob/main/LICENSE.txt
312
+
313
+ [license-ref]: https://opensource.org/licenses/MIT
314
+
315
+ [semver]: http://semver.org/
316
+
317
+ [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
318
+
319
+ [railsbling]: http://www.railsbling.com
320
+
321
+ [peterboling]: http://www.peterboling.com
322
+
323
+ [aboutme]: https://about.me/peter.boling
324
+
325
+ [angelme]: https://angel.co/peter-boling
326
+
327
+ [coderme]:http://coderwall.com/pboling
328
+
329
+ [followme-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
330
+
331
+ [tweetme]: http://twitter.com/galtzo
332
+
333
+ [politicme]: https://nationalprogressiveparty.org
334
+
335
+ [documentation]: https://rubydoc.info/github/pboling/version_gem/main
336
+
337
+ [source]: https://github.com/pboling/version_gem/
338
+
339
+ [actions]: https://github.com/pboling/version_gem/actions
340
+
341
+ [issues]: https://github.com/pboling/version_gem/issues
342
+
343
+ [climate_maintainability]: https://codeclimate.com/github/pboling/version_gem/maintainability
344
+
345
+ [climate_coverage]: https://codeclimate.com/github/pboling/version_gem/test_coverage
346
+
347
+ [codecov_coverage]: https://codecov.io/gh/pboling/version_gem
348
+
349
+ [code_triage]: https://www.codetriage.com/pboling/version_gem
350
+
351
+ [blogpage]: http://www.railsbling.com/tags/version_gem/
352
+
353
+ [rubygems]: https://rubygems.org/gems/version_gem
354
+
355
+ [chat]: https://gitter.im/pboling/version_gem?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
356
+
357
+ [maintenancee_policy]: https://guides.rubyonrails.org/maintenance_policy.html#security-issues
358
+
359
+ [liberapay_donate]: https://liberapay.com/pboling/donate
360
+
361
+ [gh_sponsors]: https://github.com/sponsors/pboling
data/SECURITY.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  ## Supported Versions
4
4
 
5
- | Version | Supported |
6
- |--------------|-----------|
7
- | 1.0.<latest> | ✅ |
5
+ | Version | Supported |
6
+ |------------|-----------|
7
+ | 1.<latest> | ✅ |
8
8
 
9
9
  ## Reporting a Vulnerability
10
10
 
@@ -11,28 +11,28 @@ module VersionGem
11
11
  #
12
12
  # @return [Integer]
13
13
  def major
14
- to_a[0].to_i
14
+ _to_a[0].to_i
15
15
  end
16
16
 
17
17
  # The minor version
18
18
  #
19
19
  # @return [Integer]
20
20
  def minor
21
- to_a[1].to_i
21
+ _to_a[1].to_i
22
22
  end
23
23
 
24
24
  # The patch version
25
25
  #
26
26
  # @return [Integer]
27
27
  def patch
28
- to_a[2].to_i
28
+ _to_a[2].to_i
29
29
  end
30
30
 
31
31
  # The pre-release version, if any
32
32
  #
33
33
  # @return [String, NilClass]
34
34
  def pre
35
- to_a[3]
35
+ _to_a[3]
36
36
  end
37
37
 
38
38
  # The version number as a hash
@@ -47,10 +47,19 @@ module VersionGem
47
47
  }
48
48
  end
49
49
 
50
- # The version number as an array
50
+ # The version number as an array of cast values
51
51
  #
52
- # @return [Array]
52
+ # @return [Array<[Integer, String, NilClass]>]
53
53
  def to_a
54
+ [major, minor, patch, pre]
55
+ end
56
+
57
+ private
58
+
59
+ # The version number as an array of strings
60
+ #
61
+ # @return [Array<String>]
62
+ def _to_a
54
63
  self::VERSION.split('.')
55
64
  end
56
65
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :have_version_constant do
4
+ match do |version_mod|
5
+ version_mod.const_defined?(:VERSION, false)
6
+ end
7
+ end
8
+
9
+ RSpec::Matchers.define :have_version_as_string do
10
+ match do |version_mod|
11
+ !version_mod::VERSION.nil? && version_mod::VERSION.is_a?(String)
12
+ end
13
+ end
14
+
15
+ RSpec::Matchers.define :have_major_as_integer do
16
+ match do |version_mod|
17
+ version_mod.major.is_a?(Integer)
18
+ end
19
+ end
20
+
21
+ RSpec::Matchers.define :have_minor_as_integer do
22
+ match do |version_mod|
23
+ version_mod.minor.is_a?(Integer)
24
+ end
25
+ end
26
+
27
+ RSpec::Matchers.define :have_patch_as_integer do
28
+ match do |version_mod|
29
+ version_mod.patch.is_a?(Integer)
30
+ end
31
+ end
32
+
33
+ RSpec::Matchers.define :have_pre_as_nil_or_string do
34
+ match do |version_mod|
35
+ version_mod.pre.nil? || version_mod.pre.is_a?(String)
36
+ end
37
+ end
38
+
39
+ RSpec.shared_examples_for 'a Version module' do |version_mod|
40
+ it 'is introspectable' do
41
+ aggregate_failures 'introspectable api' do
42
+ expect(version_mod).is_a?(Module)
43
+ expect(version_mod).to have_version_constant
44
+ expect(version_mod).to have_version_as_string
45
+ expect(version_mod.to_s).to be_a(String)
46
+ expect(version_mod).to have_major_as_integer
47
+ expect(version_mod).to have_minor_as_integer
48
+ expect(version_mod).to have_patch_as_integer
49
+ expect(version_mod).to have_pre_as_nil_or_string
50
+ expect(version_mod.to_h.keys).to match_array(%i[major minor patch pre])
51
+ expect(version_mod.to_a).to be_a(Array)
52
+ end
53
+ end
54
+ end
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'basic'
4
-
5
3
  module VersionGem
6
4
  module Version
7
- VERSION = '1.0.0'.freeze
5
+ VERSION = '1.1.0'.freeze
8
6
  # This would work in this gem, but not in external libraries,
9
7
  # because version files are loaded in Gemspecs before bundler
10
8
  # has a chance to load dependencies.
data/lib/version_gem.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'version_gem/version'
4
+ require_relative 'version_gem/basic'
4
5
 
5
6
  module VersionGem
6
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: version_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-20 00:00:00.000000000 Z
11
+ date: 2022-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -86,20 +86,6 @@ dependencies:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
- - !ruby/object:Gem::Dependency
90
- name: rubocop-rake
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
89
  - !ruby/object:Gem::Dependency
104
90
  name: rubocop-performance
105
91
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +117,7 @@ files:
131
117
  - lib/version_gem/api.rb
132
118
  - lib/version_gem/basic.rb
133
119
  - lib/version_gem/error.rb
120
+ - lib/version_gem/rspec.rb
134
121
  - lib/version_gem/version.rb
135
122
  - sig/version_gem.rbs
136
123
  homepage: https://github.com/pboling/version_gem
@@ -138,10 +125,10 @@ licenses:
138
125
  - MIT
139
126
  metadata:
140
127
  homepage_uri: https://github.com/pboling/version_gem
141
- source_code_uri: https://github.com/pboling/version_gem/tree/v1.0.0
142
- changelog_uri: https://github.com/pboling/version_gem/blob/v1.0.0/CHANGELOG.md
128
+ source_code_uri: https://github.com/pboling/version_gem/tree/v1.1.0
129
+ changelog_uri: https://github.com/pboling/version_gem/blob/v1.1.0/CHANGELOG.md
143
130
  bug_tracker_uri: https://github.com/pboling/version_gem/issues
144
- documentation_uri: https://www.rubydoc.info/gems/version_gem/1.0.0
131
+ documentation_uri: https://www.rubydoc.info/gems/version_gem/1.1.0
145
132
  wiki_uri: https://github.com/pboling/version_gem/wiki
146
133
  rubygems_mfa_required: 'true'
147
134
  post_install_message: