mixlib-versioning 1.1.0 → 1.2.1
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 +4 -4
- data/.expeditor/config.yml +14 -0
- data/.expeditor/update_version.sh +9 -0
- data/.github/CODEOWNERS +3 -0
- data/.travis.yml +20 -19
- data/CHANGELOG.md +21 -7
- data/Gemfile +4 -4
- data/README.md +48 -29
- data/Rakefile +20 -6
- data/VERSION +1 -0
- data/lib/mixlib/versioning.rb +10 -8
- data/lib/mixlib/versioning/format.rb +25 -22
- data/lib/mixlib/versioning/format/git_describe.rb +1 -1
- data/lib/mixlib/versioning/format/opscode_semver.rb +3 -3
- data/lib/mixlib/versioning/format/partial_semver.rb +62 -0
- data/lib/mixlib/versioning/format/rubygems.rb +9 -3
- data/lib/mixlib/versioning/format/semver.rb +1 -1
- data/lib/mixlib/versioning/version.rb +1 -1
- data/mixlib-versioning.gemspec +14 -14
- data/spec/mixlib/versioning/format/git_describe_spec.rb +51 -51
- data/spec/mixlib/versioning/format/opscode_semver_spec.rb +43 -43
- data/spec/mixlib/versioning/format/partial_semver_spec.rb +121 -0
- data/spec/mixlib/versioning/format/rubygems_spec.rb +40 -40
- data/spec/mixlib/versioning/format/semver_spec.rb +31 -31
- data/spec/mixlib/versioning/format_spec.rb +39 -12
- data/spec/mixlib/versioning/versioning_spec.rb +100 -100
- data/spec/spec_helper.rb +5 -6
- data/spec/support/shared_examples/basic_semver.rb +7 -7
- data/spec/support/shared_examples/behaviors/comparable.rb +14 -14
- data/spec/support/shared_examples/behaviors/comparable_types.rb +56 -0
- data/spec/support/shared_examples/behaviors/filterable.rb +11 -11
- data/spec/support/shared_examples/behaviors/parses_valid_version_strings.rb +1 -1
- data/spec/support/shared_examples/behaviors/rejects_invalid_version_strings.rb +1 -1
- data/spec/support/shared_examples/behaviors/serializable.rb +7 -7
- data/spec/support/shared_examples/behaviors/sortable.rb +9 -9
- data/spec/support/shared_examples/semver.rb +54 -54
- metadata +25 -18
- data/.rubocop.yml +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75105073144a2c6b947409ff31f4fae6aaa4fb77
|
4
|
+
data.tar.gz: 27c19f85adc97a86c005da5233187ddfee957eee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6affd7ced58f3caf0ebd9e091e7cdd96745c3cfb0c0e95ab0fc462af358194fb7142c61087acdad3c5934dddfebcf411d4afdb33433654ff3f66419dcd84581
|
7
|
+
data.tar.gz: cc5f16b52af8badc2e016a97f1d799e62e81e29548836b420bac1bf47a6b7282f5b6ef14d36b596e0e8f2970d57f0198c08f4ba296253d416b405da65aa0b43b
|
@@ -0,0 +1,14 @@
|
|
1
|
+
slack:
|
2
|
+
notify_channel: eng-services-alerts
|
3
|
+
|
4
|
+
github:
|
5
|
+
maintainer_group: chef/engineering-services
|
6
|
+
version_tag_format: v{{version}}
|
7
|
+
|
8
|
+
merge_actions:
|
9
|
+
built_in:bump_version:
|
10
|
+
ignore_labels: "Version: Skip Bump"
|
11
|
+
bash:.expeditor/update_version.sh:
|
12
|
+
only_if: built_in:bump_version
|
13
|
+
built_in:update_changelog:
|
14
|
+
ignore_labels: "Changelog: Skip Update"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# After a PR merge, Chef Expeditor will bump the PATCH version in the VERSION file.
|
4
|
+
# It then executes this file to update any other files/components with that new version.
|
5
|
+
#
|
6
|
+
|
7
|
+
set -evx
|
8
|
+
|
9
|
+
sed -i -r "s/VERSION = \".+\"/VERSION = \"$(cat VERSION)\"/" lib/mixlib/versioning/version.rb
|
data/.github/CODEOWNERS
ADDED
data/.travis.yml
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
- 2.1.0
|
5
|
-
|
6
|
-
bundler_args: --jobs 7
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
7
4
|
|
5
|
+
matrix:
|
6
|
+
include:
|
7
|
+
- rvm: 2.3.4
|
8
|
+
- rvm: 2.4.1
|
9
|
+
- rvm: ruby-head
|
10
|
+
allow_failures:
|
11
|
+
- rvm: ruby-head
|
8
12
|
branches:
|
9
13
|
only:
|
10
|
-
|
14
|
+
- master
|
15
|
+
|
16
|
+
bundler_args: --without changelog
|
11
17
|
|
12
|
-
|
18
|
+
before_install:
|
19
|
+
- gem install bundler
|
20
|
+
- bundle --version
|
21
|
+
- gem update --system
|
22
|
+
- gem --version
|
13
23
|
|
14
|
-
|
15
|
-
|
16
|
-
on_change: true
|
17
|
-
on_failure: true
|
18
|
-
on_success: false
|
19
|
-
on_pull_requests: false
|
20
|
-
rooms:
|
21
|
-
# Build Statuses
|
22
|
-
- secure: IycrY52k8dhilnU3B2c8mem9LzofQlMISUZSDk2tys0cvW0U3lnCQQiSvT5kTtiKztUABEiT2UqU2QYwUfeW/yYrO3NjB2OBqehRKnEn2oEaapcIugvtsQMySfYqJ7IsKpyh3vTMmgyKPw3OCKh5OJn26lMdHH2R91SXcbUezKI=
|
23
|
-
# Release Engineering
|
24
|
-
- secure: JJlujHzKxsY74bfJHNxH6fQOF5IULeJECXkxx6uU/T+CjxydINwAH5lQ1RUleLZlH0BmQDgxK+O46hiuWdYAyhgCJY9bQOBWG+aQusXIoLvV3qj+rU0dX1wvjEuO/NzkZTPZy7HMGqmCxTdmx/OawoNnpXU8qsI/OJqbISv2bGo=
|
24
|
+
script:
|
25
|
+
- bundle exec rake travis:ci
|
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,32 @@
|
|
1
|
-
|
2
|
-
-------------------
|
1
|
+
# Mixlib::Versioning Changes
|
3
2
|
|
4
|
-
|
3
|
+
<!-- latest_release -->
|
4
|
+
## [v1.2.1](https://github.com/chef/mixlib-versioning/tree/v1.2.1) (2017-07-24)
|
5
|
+
|
6
|
+
#### Merged Pull Requests
|
7
|
+
- Use Expeditor for version bumping and CHANGELOG generation [#23](https://github.com/chef/mixlib-versioning/pull/23) ([schisamo](https://github.com/schisamo))
|
8
|
+
<!-- latest_release -->
|
9
|
+
|
10
|
+
<!-- release_rollup -->
|
11
|
+
### Changes since latest stable release
|
12
|
+
|
13
|
+
#### Merged Pull Requests
|
14
|
+
- Use Expeditor for version bumping and CHANGELOG generation [#23](https://github.com/chef/mixlib-versioning/pull/23) ([schisamo](https://github.com/schisamo)) <!-- 1.2.1 -->
|
15
|
+
<!-- release_rollup -->
|
16
|
+
|
17
|
+
## [1.1.0](https://github.com/chef/mixlib-versioning/tree/v1.1.0) (2015-06-15)
|
18
|
+
|
19
|
+
#### New features
|
5
20
|
|
6
21
|
* Allow parse to take a list of formats to choose from
|
7
22
|
* Update to SemVer 2.0.0
|
8
23
|
|
9
|
-
|
24
|
+
#### Improvements
|
10
25
|
|
11
26
|
* Add ability to compare directly with strings.
|
12
27
|
* Lock to RuboCop 0.31.0 (also fix style errors)
|
13
28
|
|
14
29
|
|
15
|
-
v1.0.0
|
16
|
-
-------------------
|
30
|
+
## [1.0.0](https://github.com/chef/mixlib-versioning/tree/v1.0.0) (2013-03-29)
|
17
31
|
|
18
|
-
* The initial release. Versioning parsing shouldn't suck.
|
32
|
+
* The initial release. Versioning parsing shouldn't suck.
|
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
3
|
|
4
4
|
group :docs do
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
5
|
+
gem "yard", "~> 0.8"
|
6
|
+
gem "redcarpet", "~> 2.2"
|
7
|
+
gem "github-markup", "~> 0.7"
|
8
8
|
end
|
data/README.md
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
# Mixlib::Versioning
|
2
2
|
|
3
|
-
[](https://codeclimate.com/github/chef/mixlib-versioning)
|
3
|
+
[](https://travis-ci.org/chef/mixlib-versioning) [](https://codeclimate.com/github/chef/mixlib-versioning)
|
5
4
|
|
6
5
|
This project is managed by the CHEF Release Engineering team. For more information on the Release Engineering team's contribution, triage, and release process, please consult the [CHEF Release Engineering OSS Management Guide](https://docs.google.com/a/chef.io/document/d/1oJB0vZb_3bl7_ZU2YMDBkMFdL-EWplW1BJv_FXTUOzg/edit).
|
7
6
|
|
8
|
-
Versioning is hard! `mixlib-versioning` is a general Ruby library that allows
|
9
|
-
you to parse, compare and manipulate version numbers in multiple formats.
|
10
|
-
Currently the following version string formats are supported:
|
7
|
+
Versioning is hard! `mixlib-versioning` is a general Ruby library that allows you to parse, compare and manipulate version numbers in multiple formats. Currently the following version string formats are supported:
|
11
8
|
|
12
|
-
|
9
|
+
## SemVer 2.0.0
|
13
10
|
|
14
11
|
**Specification:**
|
15
12
|
|
16
|
-
http://semver.org
|
13
|
+
<http://semver.org/>
|
17
14
|
|
18
15
|
**Supported Formats:**
|
19
16
|
|
@@ -23,10 +20,9 @@ MAJOR.MINOR.PATCH-PRERELEASE
|
|
23
20
|
MAJOR.MINOR.PATCH-PRERELEASE+BUILD
|
24
21
|
```
|
25
22
|
|
26
|
-
Not much to say here except:
|
27
|
-
brief, do yourself a favor and go read it.
|
23
|
+
Not much to say here except: _YUNO USE SEMVER!_ The specification is focused and brief, do yourself a favor and go read it.
|
28
24
|
|
29
|
-
|
25
|
+
## Opscode SemVer
|
30
26
|
|
31
27
|
**Supported Formats:**
|
32
28
|
|
@@ -43,11 +39,9 @@ MAJOR.MINOR.PATCH-beta.INDEX+YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1
|
|
43
39
|
MAJOR.MINOR.PATCH-rc.INDEX+YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1
|
44
40
|
```
|
45
41
|
|
46
|
-
All the fun of regular SemVer with some extra limits around what constitutes a
|
47
|
-
valid pre-release or build version string.
|
42
|
+
All the fun of regular SemVer with some extra limits around what constitutes a valid pre-release or build version string.
|
48
43
|
|
49
|
-
Valid prerelease version strings use the format: `PRERELEASE_STAGE.INDEX`.
|
50
|
-
Valid prerelease stages include: `alpha`, `beta` and `rc`.
|
44
|
+
Valid prerelease version strings use the format: `PRERELEASE_STAGE.INDEX`. Valid prerelease stages include: `alpha`, `beta` and `rc`.
|
51
45
|
|
52
46
|
All of the following are acceptable Opscode SemVer pre-release versions:
|
53
47
|
|
@@ -60,9 +54,7 @@ All of the following are acceptable Opscode SemVer pre-release versions:
|
|
60
54
|
11.0.8-rc.2
|
61
55
|
```
|
62
56
|
|
63
|
-
Build version strings are limited to timestamps (`YYYYMMDDHHMMSS`), git
|
64
|
-
describe strings (`git.COMMITS_SINCE.SHA1`) or a combination of the two
|
65
|
-
(`YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1`).
|
57
|
+
Build version strings are limited to timestamps (`YYYYMMDDHHMMSS`), git describe strings (`git.COMMITS_SINCE.SHA1`) or a combination of the two (`YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1`).
|
66
58
|
|
67
59
|
All of the following are acceptable Opscode build versions:
|
68
60
|
|
@@ -79,13 +71,13 @@ And as is true with regular SemVer you can mix pre-release and build versions:
|
|
79
71
|
11.0.8-alpha.2+20130308110833.git.2.94a1dde
|
80
72
|
```
|
81
73
|
|
82
|
-
|
74
|
+
## Rubygems
|
83
75
|
|
84
76
|
**specification:**
|
85
77
|
|
86
|
-
http://docs.rubygems.org/read/chapter/7
|
78
|
+
<http://docs.rubygems.org/read/chapter/7>
|
87
79
|
|
88
|
-
http://guides.rubygems.org/patterns
|
80
|
+
<http://guides.rubygems.org/patterns/>
|
89
81
|
|
90
82
|
**Supported Formats:**
|
91
83
|
|
@@ -94,9 +86,7 @@ MAJOR.MINOR.PATCH
|
|
94
86
|
MAJOR.MINOR.PATCH.PRERELEASE
|
95
87
|
```
|
96
88
|
|
97
|
-
Rubygems is
|
98
|
-
the pre-release version using a "dot". It also does not have the notion of a
|
99
|
-
build version like SemVer.
|
89
|
+
Rubygems is _almost_ SemVer compliant but it separates the main version from the pre-release version using a "dot". It also does not have the notion of a build version like SemVer.
|
100
90
|
|
101
91
|
Examples of valid Rubygems version strings:
|
102
92
|
|
@@ -108,11 +98,11 @@ Examples of valid Rubygems version strings:
|
|
108
98
|
10.1.1.rc.0
|
109
99
|
```
|
110
100
|
|
111
|
-
|
101
|
+
## Git Describe
|
112
102
|
|
113
103
|
**Specification:**
|
114
104
|
|
115
|
-
http://git-scm.com/docs/git-describe
|
105
|
+
<http://git-scm.com/docs/git-describe>
|
116
106
|
|
117
107
|
**Supported Formats:**
|
118
108
|
|
@@ -132,19 +122,42 @@ Examples of valid Git Describe version strings:
|
|
132
122
|
11.0.0-alpha.1-1-gcea071e
|
133
123
|
```
|
134
124
|
|
125
|
+
|
126
|
+
## SemVer Partial
|
127
|
+
|
128
|
+
|
129
|
+
```text
|
130
|
+
MAJOR
|
131
|
+
MAJOR.MINOR
|
132
|
+
```
|
133
|
+
|
134
|
+
Examples of valid SemVer Partial version strings:
|
135
|
+
|
136
|
+
```text
|
137
|
+
1
|
138
|
+
0.1
|
139
|
+
1.0
|
140
|
+
```
|
141
|
+
|
135
142
|
## Installation
|
136
143
|
|
137
144
|
Add this line to your application's Gemfile:
|
138
145
|
|
139
|
-
|
146
|
+
```
|
147
|
+
gem 'mixlib-versioning'
|
148
|
+
```
|
140
149
|
|
141
150
|
And then execute:
|
142
151
|
|
143
|
-
|
152
|
+
```
|
153
|
+
$ bundle
|
154
|
+
```
|
144
155
|
|
145
156
|
Or install it yourself as:
|
146
157
|
|
147
|
-
|
158
|
+
```
|
159
|
+
$ gem install mixlib-semver
|
160
|
+
```
|
148
161
|
|
149
162
|
## Usage
|
150
163
|
|
@@ -336,15 +349,20 @@ All documentation is written using YARD. You can generate a by running:
|
|
336
349
|
rake yard
|
337
350
|
```
|
338
351
|
|
352
|
+
## Contributing
|
353
|
+
|
354
|
+
For information on contributing to this project see <https://github.com/chef/chef/blob/master/CONTRIBUTING.md>
|
355
|
+
|
339
356
|
## License
|
340
357
|
|
341
358
|
| | |
|
342
359
|
|:---------------------|:-----------------------------------------|
|
343
360
|
| **Author:** | Seth Chisamore (schisamo@chef.io)
|
344
361
|
| **Author:** | Christopher Maier (cm@chef.io)
|
345
|
-
| **Copyright:** | Copyright (c) 2013
|
362
|
+
| **Copyright:** | Copyright (c) 2013-2017 Chef Software, Inc.
|
346
363
|
| **License:** | Apache License, Version 2.0
|
347
364
|
|
365
|
+
```text
|
348
366
|
Licensed under the Apache License, Version 2.0 (the "License");
|
349
367
|
you may not use this file except in compliance with the License.
|
350
368
|
You may obtain a copy of the License at
|
@@ -356,3 +374,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
|
356
374
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
357
375
|
See the License for the specific language governing permissions and
|
358
376
|
limitations under the License.
|
377
|
+
```
|
data/Rakefile
CHANGED
@@ -1,17 +1,31 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
require "mixlib/versioning/version"
|
2
5
|
|
3
|
-
require 'rspec/core/rake_task'
|
4
6
|
RSpec::Core::RakeTask.new(:unit)
|
5
7
|
|
6
|
-
require
|
7
|
-
|
8
|
+
require "chefstyle"
|
9
|
+
require "rubocop/rake_task"
|
10
|
+
desc "Run Ruby style checks"
|
8
11
|
RuboCop::RakeTask.new(:style)
|
9
12
|
|
10
|
-
require
|
13
|
+
require "yard"
|
11
14
|
YARD::Rake::YardocTask.new(:doc)
|
12
15
|
|
16
|
+
begin
|
17
|
+
require "github_changelog_generator/task"
|
18
|
+
|
19
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
20
|
+
config.issues = false
|
21
|
+
config.future_release = Mixlib::Versioning::VERSION
|
22
|
+
end
|
23
|
+
rescue LoadError
|
24
|
+
puts "github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs"
|
25
|
+
end
|
26
|
+
|
13
27
|
namespace :travis do
|
14
|
-
desc
|
28
|
+
desc "Run tests on Travis"
|
15
29
|
task ci: [:style, :unit]
|
16
30
|
end
|
17
31
|
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.2.1
|
data/lib/mixlib/versioning.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
3
|
# Author:: Christopher Maier (<cm@chef.io>)
|
4
4
|
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
5
|
+
# Copyright:: Copyright (c) 2017 Chef Software Inc.
|
5
6
|
# License:: Apache License, Version 2.0
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,8 +18,8 @@
|
|
17
18
|
# limitations under the License.
|
18
19
|
#
|
19
20
|
|
20
|
-
require
|
21
|
-
require
|
21
|
+
require "mixlib/versioning/exceptions"
|
22
|
+
require "mixlib/versioning/format"
|
22
23
|
|
23
24
|
module Mixlib
|
24
25
|
# @author Seth Chisamore (<schisamo@chef.io>)
|
@@ -29,6 +30,7 @@ module Mixlib
|
|
29
30
|
Mixlib::Versioning::Format::OpscodeSemVer,
|
30
31
|
Mixlib::Versioning::Format::SemVer,
|
31
32
|
Mixlib::Versioning::Format::Rubygems,
|
33
|
+
Mixlib::Versioning::Format::PartialSemVer,
|
32
34
|
].freeze
|
33
35
|
|
34
36
|
# Create a new {Format} instance given a version string to parse, and an
|
@@ -55,7 +57,7 @@ module Mixlib
|
|
55
57
|
#
|
56
58
|
def self.parse(version_string, format = nil)
|
57
59
|
if version_string.is_a?(Mixlib::Versioning::Format)
|
58
|
-
|
60
|
+
version_string
|
59
61
|
else
|
60
62
|
formats = if format
|
61
63
|
[format].flatten.map { |f| Mixlib::Versioning::Format.for(f) }
|
@@ -71,7 +73,7 @@ module Mixlib
|
|
71
73
|
next
|
72
74
|
end
|
73
75
|
end
|
74
|
-
|
76
|
+
parsed_version
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
@@ -135,7 +137,7 @@ module Mixlib
|
|
135
137
|
# attempt to parse a `Mixlib::Versioning::Format` instance if we were
|
136
138
|
# passed a string
|
137
139
|
unless filter_version.nil? ||
|
138
|
-
|
140
|
+
filter_version.is_a?(Mixlib::Versioning::Format)
|
139
141
|
filter_version = Mixlib::Versioning.parse(filter_version)
|
140
142
|
end
|
141
143
|
|
@@ -181,13 +183,13 @@ module Mixlib
|
|
181
183
|
in_release_line && if use_prerelease_versions && use_build_versions
|
182
184
|
v.prerelease_build?
|
183
185
|
elsif !use_prerelease_versions &&
|
184
|
-
|
186
|
+
use_build_versions
|
185
187
|
v.release_build?
|
186
188
|
elsif use_prerelease_versions &&
|
187
|
-
|
189
|
+
!use_build_versions
|
188
190
|
v.prerelease?
|
189
191
|
elsif !use_prerelease_versions &&
|
190
|
-
|
192
|
+
!use_build_versions
|
191
193
|
v.release?
|
192
194
|
end
|
193
195
|
end.max # select the most recent version
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
3
|
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
+
# Copyright:: Copyright (c) 2017 Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,10 +17,11 @@
|
|
16
17
|
# limitations under the License.
|
17
18
|
#
|
18
19
|
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
20
|
+
require "mixlib/versioning/format/git_describe"
|
21
|
+
require "mixlib/versioning/format/opscode_semver"
|
22
|
+
require "mixlib/versioning/format/rubygems"
|
23
|
+
require "mixlib/versioning/format/semver"
|
24
|
+
require "mixlib/versioning/format/partial_semver"
|
23
25
|
|
24
26
|
module Mixlib
|
25
27
|
class Versioning
|
@@ -30,15 +32,15 @@ module Mixlib
|
|
30
32
|
# @!attribute [r] minor
|
31
33
|
# @return [Integer] minor identifier
|
32
34
|
# @!attribute [r] patch
|
33
|
-
# @return [Integer] patch identifier
|
35
|
+
# @return [Integer, nil] patch identifier
|
34
36
|
# @!attribute [r] prerelease
|
35
|
-
# @return [String] pre-release identifier
|
37
|
+
# @return [String, nil] pre-release identifier
|
36
38
|
# @!attribute [r] build
|
37
|
-
# @return [String] build identifier
|
39
|
+
# @return [String, nil] build identifier
|
38
40
|
# @!attribute [r] iteration
|
39
|
-
# @return [String] build interation
|
41
|
+
# @return [String, nil] build interation
|
40
42
|
# @!attribute [r] input
|
41
|
-
# @return [String] original input version string that was parsed
|
43
|
+
# @return [String, nil] original input version string that was parsed
|
42
44
|
class Format
|
43
45
|
include Comparable
|
44
46
|
|
@@ -60,17 +62,18 @@ module Mixlib
|
|
60
62
|
#
|
61
63
|
def self.for(format_type)
|
62
64
|
if format_type.is_a?(Class) &&
|
63
|
-
|
65
|
+
format_type.ancestors.include?(Mixlib::Versioning::Format)
|
64
66
|
format_type
|
65
67
|
else
|
66
68
|
case format_type.to_s
|
67
|
-
when
|
68
|
-
when
|
69
|
-
when
|
70
|
-
when
|
69
|
+
when "semver" then Mixlib::Versioning::Format::SemVer
|
70
|
+
when "opscode_semver" then Mixlib::Versioning::Format::OpscodeSemVer
|
71
|
+
when "git_describe" then Mixlib::Versioning::Format::GitDescribe
|
72
|
+
when "rubygems" then Mixlib::Versioning::Format::Rubygems
|
73
|
+
when "partial_semver" then Mixlib::Versioning::Format::PartialSemVer
|
71
74
|
else
|
72
75
|
msg = "'#{format_type}' is not a supported Mixlib::Versioning format"
|
73
|
-
|
76
|
+
raise Mixlib::Versioning::UnknownFormatError, msg
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
@@ -90,7 +93,7 @@ module Mixlib
|
|
90
93
|
# @param version_string [String] string representation of the version
|
91
94
|
# @raise [Mixlib::Versioning::ParseError] raised if parsing fails
|
92
95
|
def parse(_version_string)
|
93
|
-
|
96
|
+
raise Error, "You must override the #parse"
|
94
97
|
end
|
95
98
|
|
96
99
|
# @return [Boolean] Whether or not this is a release version
|
@@ -153,7 +156,7 @@ module Mixlib
|
|
153
156
|
vars = instance_variables.map do |n|
|
154
157
|
"#{n}=#{instance_variable_get(n).inspect}"
|
155
158
|
end
|
156
|
-
format(
|
159
|
+
format("#<%s:0x%x %s>", self.class, object_id, vars.join(", "))
|
157
160
|
end
|
158
161
|
|
159
162
|
# Returns SemVer compliant string representation of this {Format}
|
@@ -167,7 +170,7 @@ module Mixlib
|
|
167
170
|
# {Format} instance
|
168
171
|
# @todo create a proper serialization abstraction
|
169
172
|
def to_semver_string
|
170
|
-
s = [@major, @minor, @patch].join(
|
173
|
+
s = [@major, @minor, @patch].map(&:to_i).join(".")
|
171
174
|
s += "-#{@prerelease}" if @prerelease
|
172
175
|
s += "+#{@build}" if @build
|
173
176
|
s
|
@@ -184,7 +187,7 @@ module Mixlib
|
|
184
187
|
# {Format} instance
|
185
188
|
# @todo create a proper serialization abstraction
|
186
189
|
def to_rubygems_string
|
187
|
-
s = [@major, @minor, @patch].join(
|
190
|
+
s = [@major, @minor, @patch].map(&:to_i).join(".")
|
188
191
|
s += ".#{@prerelease}" if @prerelease
|
189
192
|
s
|
190
193
|
end
|
@@ -269,7 +272,7 @@ module Mixlib
|
|
269
272
|
end
|
270
273
|
|
271
274
|
def hash
|
272
|
-
[@major, @minor, @patch, @prerelease, @build].compact.join(
|
275
|
+
[@major, @minor, @patch, @prerelease, @build].compact.join(".").hash
|
273
276
|
end
|
274
277
|
|
275
278
|
#########################################################################
|
@@ -303,8 +306,8 @@ module Mixlib
|
|
303
306
|
# Both `a_item` and `b_item` should be Strings; `nil` is not a
|
304
307
|
# valid input.
|
305
308
|
def compare_dot_components(a_item, b_item)
|
306
|
-
a_components = a_item.split(
|
307
|
-
b_components = b_item.split(
|
309
|
+
a_components = a_item.split(".")
|
310
|
+
b_components = b_item.split(".")
|
308
311
|
|
309
312
|
max_length = [a_components.length, b_components.length].max
|
310
313
|
|