version_gem 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +34 -5
- data/SECURITY.md +3 -3
- data/lib/version_gem/api.rb +15 -6
- data/lib/version_gem/rspec.rb +54 -0
- data/lib/version_gem/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21e250531f2630bae1d9b1961c58451b9bb25bcacff9e725ecfc8b58e5b23997
|
4
|
+
data.tar.gz: 236e288d1bc0ea792e86887555c716224e441448aae87b6a2d4e4f78d195c2d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dee2a6a560776eb93d8104fbe4e2c20e31a62172103972b94f636d1dd793d0c623674d78c31f8a21139167e4d09e48d292efd53d27a3de943349505e1d467f4
|
7
|
+
data.tar.gz: eecbc666ad24fd08d2516bc5c64b5ada2273fc153199dba97f089254eeb4fcefaa8d0e903832dae31c39108e1eb31301deb57c152b48f0c2f30e919558737266
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
13
13
|
|
14
14
|
### Removed
|
15
15
|
|
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
|
+
|
16
22
|
## [1.0.2] - 2022-06-23
|
17
23
|
### Added
|
18
24
|
- Delay loading of library code until after code coverage tool is loaded
|
@@ -28,7 +34,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
28
34
|
### Added
|
29
35
|
- Initial release, with basic version parsing API
|
30
36
|
|
31
|
-
[Unreleased]: https://github.com/pboling/version_gem/compare/v1.0
|
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
|
32
39
|
[1.0.2]: https://github.com/pboling/version_gem/compare/v1.0.1...v1.0.2
|
33
40
|
[1.0.1]: https://github.com/pboling/version_gem/compare/v1.0.0...v1.0.1
|
34
41
|
[1.0.0]: https://github.com/pboling/version_gem/compare/a3055964517c159bf214712940982034b75264be...v1.0.0
|
data/README.md
CHANGED
@@ -86,8 +86,8 @@ The link tokens in the following sections should be kept ordered by the row and
|
|
86
86
|
[⛳cclim-maint-img♻️]: https://api.codeclimate.com/v1/badges/b504d61c4ed1d46aec02/maintainability
|
87
87
|
[🖇triage-help]: https://www.codetriage.com/pboling/version_gem
|
88
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=
|
90
|
-
[🏘depfu-img♻️]: https://badges.depfu.com/badges/
|
89
|
+
[🏘depfu♻️]: https://depfu.com/github/pboling/version_gem?project_id=35803
|
90
|
+
[🏘depfu-img♻️]: https://badges.depfu.com/badges/5d8943de6cfdf1ee048ad6d907f3e35b/count.svg
|
91
91
|
[🚎contributors]: https://github.com/pboling/version_gem/graphs/contributors
|
92
92
|
[🚎contributors-img]: https://img.shields.io/github/contributors-anon/pboling/version_gem
|
93
93
|
[🖐style-wf]: https://github.com/pboling/version_gem/actions/workflows/style.yml
|
@@ -219,6 +219,37 @@ This design keeps your `version.rb` file compatible with the way `gemspec` files
|
|
219
219
|
This means that the introspection is _not_ available within the gemspec.
|
220
220
|
The enhancement from this gem is only available at runtime.
|
221
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
|
+
|
222
253
|
## Development
|
223
254
|
|
224
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.
|
@@ -227,8 +258,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
227
258
|
|
228
259
|
## Contributing
|
229
260
|
|
230
|
-
## Contributing
|
231
|
-
|
232
261
|
See [CONTRIBUTING.md][contributing]
|
233
262
|
|
234
263
|
## Contributors
|
@@ -262,7 +291,7 @@ the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
|
262
291
|
For example:
|
263
292
|
|
264
293
|
```ruby
|
265
|
-
spec.add_dependency "version_gem", "~> 1.
|
294
|
+
spec.add_dependency "version_gem", "~> 1.1"
|
266
295
|
```
|
267
296
|
|
268
297
|
## Security
|
data/SECURITY.md
CHANGED
data/lib/version_gem/api.rb
CHANGED
@@ -11,28 +11,28 @@ module VersionGem
|
|
11
11
|
#
|
12
12
|
# @return [Integer]
|
13
13
|
def major
|
14
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/version_gem/version.rb
CHANGED
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
|
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-
|
11
|
+
date: 2022-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/version_gem/api.rb
|
118
118
|
- lib/version_gem/basic.rb
|
119
119
|
- lib/version_gem/error.rb
|
120
|
+
- lib/version_gem/rspec.rb
|
120
121
|
- lib/version_gem/version.rb
|
121
122
|
- sig/version_gem.rbs
|
122
123
|
homepage: https://github.com/pboling/version_gem
|
@@ -124,10 +125,10 @@ licenses:
|
|
124
125
|
- MIT
|
125
126
|
metadata:
|
126
127
|
homepage_uri: https://github.com/pboling/version_gem
|
127
|
-
source_code_uri: https://github.com/pboling/version_gem/tree/v1.0
|
128
|
-
changelog_uri: https://github.com/pboling/version_gem/blob/v1.0
|
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
|
129
130
|
bug_tracker_uri: https://github.com/pboling/version_gem/issues
|
130
|
-
documentation_uri: https://www.rubydoc.info/gems/version_gem/1.0
|
131
|
+
documentation_uri: https://www.rubydoc.info/gems/version_gem/1.1.0
|
131
132
|
wiki_uri: https://github.com/pboling/version_gem/wiki
|
132
133
|
rubygems_mfa_required: 'true'
|
133
134
|
post_install_message:
|