mixlib-versioning 1.0.0 → 1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/mixlib/versioning.rb +41 -37
- data/lib/mixlib/versioning/exceptions.rb +2 -2
- data/lib/mixlib/versioning/format.rb +42 -38
- data/lib/mixlib/versioning/format/git_describe.rb +5 -7
- data/lib/mixlib/versioning/format/opscode_semver.rb +8 -19
- data/lib/mixlib/versioning/format/partial_semver.rb +62 -0
- data/lib/mixlib/versioning/format/rubygems.rb +14 -10
- data/lib/mixlib/versioning/format/semver.rb +9 -11
- data/lib/mixlib/versioning/version.rb +3 -3
- metadata +15 -87
- data/.gitignore +0 -18
- data/.yardopts +0 -7
- data/CHANGELOG.md +0 -3
- data/CONTRIBUTING.md +0 -188
- data/Gemfile +0 -9
- data/README.md +0 -364
- data/Rakefile +0 -6
- data/mixlib-versioning.gemspec +0 -22
- data/spec/mixlib/versioning/format/git_describe_spec.rb +0 -178
- data/spec/mixlib/versioning/format/opscode_semver_spec.rb +0 -113
- data/spec/mixlib/versioning/format/rubygems_spec.rb +0 -142
- data/spec/mixlib/versioning/format/semver_spec.rb +0 -107
- data/spec/mixlib/versioning/format_spec.rb +0 -69
- data/spec/mixlib/versioning/versioning_spec.rb +0 -259
- data/spec/spec_helper.rb +0 -43
- data/spec/support/shared_examples/basic_semver.rb +0 -42
- data/spec/support/shared_examples/behaviors/filterable.rb +0 -66
- data/spec/support/shared_examples/behaviors/parses_valid_version_strings.rb +0 -32
- data/spec/support/shared_examples/behaviors/rejects_invalid_version_strings.rb +0 -32
- data/spec/support/shared_examples/behaviors/serializable.rb +0 -51
- data/spec/support/shared_examples/behaviors/sortable.rb +0 -45
- data/spec/support/shared_examples/semver.rb +0 -105
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2be21e4975d6fa956538a0eb98cfe608f423a0b34aee5763e627ec31112c66b5
|
4
|
+
data.tar.gz: f7909f08f54a4d094516186f68747b96500a62cdcc8677fe6d631947d0d017c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b8554a17dc71628a23c83aeee7b7932733476d1b7769d9e83e5a27f0d884bfc18313a28a27348ca407dc5ac537df9f5a87d521debd45eca6b860b6cd83ba04f
|
7
|
+
data.tar.gz: 66d72d18122c944855affd93d57a8ad81f74aedbf8009305d9bd425fd46979b1e41d69cfc8e28d96492957f7ed1df7228a5178e31bfdef0173bcec9825b60972
|
data/lib/mixlib/versioning.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@
|
3
|
-
# Author:: Christopher Maier (<cm@
|
4
|
-
# Copyright:: Copyright (c) 2013
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Author:: Christopher Maier (<cm@chef.io>)
|
4
|
+
# Copyright:: Copyright (c) 2013-2018 Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,57 +17,62 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
require_relative "versioning/exceptions"
|
21
|
+
require_relative "versioning/format"
|
22
22
|
|
23
23
|
module Mixlib
|
24
|
-
# @author Seth Chisamore (<schisamo@
|
25
|
-
# @author Christopher Maier (<cm@
|
24
|
+
# @author Seth Chisamore (<schisamo@chef.io>)
|
25
|
+
# @author Christopher Maier (<cm@chef.io>)
|
26
26
|
class Versioning
|
27
|
+
DEFAULT_FORMATS = [
|
28
|
+
Mixlib::Versioning::Format::GitDescribe,
|
29
|
+
Mixlib::Versioning::Format::OpscodeSemVer,
|
30
|
+
Mixlib::Versioning::Format::SemVer,
|
31
|
+
Mixlib::Versioning::Format::Rubygems,
|
32
|
+
Mixlib::Versioning::Format::PartialSemVer,
|
33
|
+
].freeze
|
27
34
|
|
28
35
|
# Create a new {Format} instance given a version string to parse, and an
|
29
36
|
# optional format type.
|
30
37
|
#
|
31
38
|
# @example
|
32
|
-
# Mixlib::Versioning.parse(
|
33
|
-
# Mixlib::Versioning.parse(
|
34
|
-
# Mixlib::Versioning.parse(
|
35
|
-
# Mixlib::Versioning.parse(
|
39
|
+
# Mixlib::Versioning.parse('11.0.0')
|
40
|
+
# Mixlib::Versioning.parse('11.0.0', :semver)
|
41
|
+
# Mixlib::Versioning.parse('11.0.0', 'semver')
|
42
|
+
# Mixlib::Versioning.parse('11.0.0', Mixlib::Versioning::Format::SemVer)
|
36
43
|
#
|
37
44
|
# @param version_string [String] String representatin of the version to
|
38
45
|
# parse
|
39
|
-
# @param
|
46
|
+
# @param format [String, Symbol, Mixlib::Versioning::Format, Array] Optional
|
40
47
|
# format type to parse the version string as. If this is exluded all
|
41
48
|
# version types will be attempted from most specific to most specific
|
42
|
-
# with a preference for SemVer formats
|
43
|
-
#
|
49
|
+
# with a preference for SemVer formats. If it is an array, only version
|
50
|
+
# types in that list will be considered
|
44
51
|
# @raise [Mixlib::Versioning::ParseError] if the parse fails.
|
45
52
|
# @raise [Mixlib::Versioning::UnknownFormatError] if the given format type
|
46
53
|
# doesn't exist.
|
47
54
|
#
|
48
55
|
# @return
|
49
56
|
#
|
50
|
-
def self.parse(version_string,
|
51
|
-
if version_string.
|
52
|
-
|
53
|
-
elsif format_type
|
54
|
-
return Mixlib::Versioning::Format.for(format_type).new(version_string)
|
57
|
+
def self.parse(version_string, format = nil)
|
58
|
+
if version_string.is_a?(Mixlib::Versioning::Format)
|
59
|
+
version_string
|
55
60
|
else
|
61
|
+
formats = if format
|
62
|
+
[format].flatten.map { |f| Mixlib::Versioning::Format.for(f) }
|
63
|
+
else
|
64
|
+
DEFAULT_FORMATS
|
65
|
+
end
|
56
66
|
# Attempt to parse from the most specific formats first.
|
57
67
|
parsed_version = nil
|
58
|
-
|
59
|
-
Mixlib::Versioning::Format::GitDescribe,
|
60
|
-
Mixlib::Versioning::Format::OpscodeSemVer,
|
61
|
-
Mixlib::Versioning::Format::SemVer,
|
62
|
-
Mixlib::Versioning::Format::Rubygems
|
63
|
-
].each do |version|
|
68
|
+
formats.each do |version|
|
64
69
|
begin
|
65
70
|
break parsed_version = version.new(version_string)
|
66
71
|
rescue Mixlib::Versioning::ParseError
|
67
72
|
next
|
68
73
|
end
|
69
74
|
end
|
70
|
-
|
75
|
+
parsed_version
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
@@ -103,7 +108,7 @@ module Mixlib
|
|
103
108
|
# 11.0.1 }
|
104
109
|
#
|
105
110
|
# Mixlib::Versioning.find_target_version(all,
|
106
|
-
#
|
111
|
+
# '11.0.1',
|
107
112
|
# true,
|
108
113
|
# true)
|
109
114
|
#
|
@@ -124,19 +129,19 @@ module Mixlib
|
|
124
129
|
# build version specifier will be filtered out.
|
125
130
|
#
|
126
131
|
def self.find_target_version(all_versions,
|
127
|
-
filter_version=nil,
|
128
|
-
use_prerelease_versions=false,
|
129
|
-
use_build_versions=false)
|
132
|
+
filter_version = nil,
|
133
|
+
use_prerelease_versions = false,
|
134
|
+
use_build_versions = false)
|
130
135
|
|
131
136
|
# attempt to parse a `Mixlib::Versioning::Format` instance if we were
|
132
137
|
# passed a string
|
133
138
|
unless filter_version.nil? ||
|
134
|
-
|
139
|
+
filter_version.is_a?(Mixlib::Versioning::Format)
|
135
140
|
filter_version = Mixlib::Versioning.parse(filter_version)
|
136
141
|
end
|
137
142
|
|
138
143
|
all_versions.map! do |v|
|
139
|
-
if v.
|
144
|
+
if v.is_a?(Mixlib::Versioning::Format)
|
140
145
|
v
|
141
146
|
else
|
142
147
|
Mixlib::Versioning.parse(v)
|
@@ -153,7 +158,7 @@ module Mixlib
|
|
153
158
|
# that prerelease, and then take the most recent. Otherwise, just
|
154
159
|
# return the specified prerelease version
|
155
160
|
if use_build_versions
|
156
|
-
all_versions.select{|v| v.in_same_prerelease_line?(filter_version)}.max
|
161
|
+
all_versions.select { |v| v.in_same_prerelease_line?(filter_version) }.max
|
157
162
|
else
|
158
163
|
filter_version
|
159
164
|
end
|
@@ -177,18 +182,17 @@ module Mixlib
|
|
177
182
|
in_release_line && if use_prerelease_versions && use_build_versions
|
178
183
|
v.prerelease_build?
|
179
184
|
elsif !use_prerelease_versions &&
|
180
|
-
|
185
|
+
use_build_versions
|
181
186
|
v.release_build?
|
182
187
|
elsif use_prerelease_versions &&
|
183
|
-
|
188
|
+
!use_build_versions
|
184
189
|
v.prerelease?
|
185
190
|
elsif !use_prerelease_versions &&
|
186
|
-
|
191
|
+
!use_build_versions
|
187
192
|
v.release?
|
188
193
|
end
|
189
194
|
end.max # select the most recent version
|
190
195
|
end # if
|
191
196
|
end # self.find_target_version
|
192
|
-
|
193
197
|
end # Versioning
|
194
198
|
end # Mixlib
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@
|
3
|
-
# Copyright:: Copyright (c) 2013
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2013-2018 Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@
|
3
|
-
# Copyright:: Copyright (c) 2013
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2013-2018 Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,30 +16,30 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
require_relative "format/git_describe"
|
20
|
+
require_relative "format/opscode_semver"
|
21
|
+
require_relative "format/rubygems"
|
22
|
+
require_relative "format/semver"
|
23
|
+
require_relative "format/partial_semver"
|
23
24
|
|
24
25
|
module Mixlib
|
25
26
|
class Versioning
|
26
|
-
|
27
|
-
# @author Seth Chisamore (<schisamo@opscode.com>)
|
27
|
+
# @author Seth Chisamore (<schisamo@chef.io>)
|
28
28
|
#
|
29
29
|
# @!attribute [r] major
|
30
30
|
# @return [Integer] major identifier
|
31
31
|
# @!attribute [r] minor
|
32
32
|
# @return [Integer] minor identifier
|
33
33
|
# @!attribute [r] patch
|
34
|
-
# @return [Integer] patch identifier
|
34
|
+
# @return [Integer, nil] patch identifier
|
35
35
|
# @!attribute [r] prerelease
|
36
|
-
# @return [String] pre-release identifier
|
36
|
+
# @return [String, nil] pre-release identifier
|
37
37
|
# @!attribute [r] build
|
38
|
-
# @return [String] build identifier
|
38
|
+
# @return [String, nil] build identifier
|
39
39
|
# @!attribute [r] iteration
|
40
|
-
# @return [String] build interation
|
40
|
+
# @return [String, nil] build interation
|
41
41
|
# @!attribute [r] input
|
42
|
-
# @return [String] original input version string that was parsed
|
42
|
+
# @return [String, nil] original input version string that was parsed
|
43
43
|
class Format
|
44
44
|
include Comparable
|
45
45
|
|
@@ -60,17 +60,18 @@ module Mixlib
|
|
60
60
|
# @return [Class] the {Mixlib::Versioning::Format} class
|
61
61
|
#
|
62
62
|
def self.for(format_type)
|
63
|
-
if format_type.
|
64
|
-
|
63
|
+
if format_type.is_a?(Class) &&
|
64
|
+
format_type.ancestors.include?(Mixlib::Versioning::Format)
|
65
65
|
format_type
|
66
66
|
else
|
67
67
|
case format_type.to_s
|
68
|
-
when
|
69
|
-
when
|
70
|
-
when
|
71
|
-
when
|
68
|
+
when "semver" then Mixlib::Versioning::Format::SemVer
|
69
|
+
when "opscode_semver" then Mixlib::Versioning::Format::OpscodeSemVer
|
70
|
+
when "git_describe" then Mixlib::Versioning::Format::GitDescribe
|
71
|
+
when "rubygems" then Mixlib::Versioning::Format::Rubygems
|
72
|
+
when "partial_semver" then Mixlib::Versioning::Format::PartialSemVer
|
72
73
|
else
|
73
|
-
msg = "'#{format_type
|
74
|
+
msg = "'#{format_type}' is not a supported Mixlib::Versioning format"
|
74
75
|
raise Mixlib::Versioning::UnknownFormatError, msg
|
75
76
|
end
|
76
77
|
end
|
@@ -90,7 +91,7 @@ module Mixlib
|
|
90
91
|
#
|
91
92
|
# @param version_string [String] string representation of the version
|
92
93
|
# @raise [Mixlib::Versioning::ParseError] raised if parsing fails
|
93
|
-
def parse(
|
94
|
+
def parse(_version_string)
|
94
95
|
raise Error, "You must override the #parse"
|
95
96
|
end
|
96
97
|
|
@@ -101,22 +102,22 @@ module Mixlib
|
|
101
102
|
|
102
103
|
# @return [Boolean] Whether or not this is a pre-release version
|
103
104
|
def prerelease?
|
104
|
-
|
105
|
+
!@prerelease.nil? && @build.nil?
|
105
106
|
end
|
106
107
|
|
107
108
|
# @return [Boolean] Whether or not this is a release build version
|
108
109
|
def release_build?
|
109
|
-
|
110
|
+
@prerelease.nil? && !@build.nil?
|
110
111
|
end
|
111
112
|
|
112
113
|
# @return [Boolean] Whether or not this is a pre-release build version
|
113
114
|
def prerelease_build?
|
114
|
-
|
115
|
+
!@prerelease.nil? && !@build.nil?
|
115
116
|
end
|
116
117
|
|
117
118
|
# @return [Boolean] Whether or not this is a build version
|
118
119
|
def build?
|
119
|
-
|
120
|
+
!@build.nil?
|
120
121
|
end
|
121
122
|
|
122
123
|
# Returns `true` if `other` and this {Format} share the same `major`,
|
@@ -126,8 +127,8 @@ module Mixlib
|
|
126
127
|
# @return [Boolean]
|
127
128
|
def in_same_release_line?(other)
|
128
129
|
@major == other.major &&
|
129
|
-
|
130
|
-
|
130
|
+
@minor == other.minor &&
|
131
|
+
@patch == other.patch
|
131
132
|
end
|
132
133
|
|
133
134
|
# Returns `true` if `other` an share the same
|
@@ -137,9 +138,9 @@ module Mixlib
|
|
137
138
|
# @return [Boolean]
|
138
139
|
def in_same_prerelease_line?(other)
|
139
140
|
@major == other.major &&
|
140
|
-
|
141
|
-
|
142
|
-
|
141
|
+
@minor == other.minor &&
|
142
|
+
@patch == other.patch &&
|
143
|
+
@prerelease == other.prerelease
|
143
144
|
end
|
144
145
|
|
145
146
|
# @return [String] String representation of this {Format} instance
|
@@ -154,7 +155,7 @@ module Mixlib
|
|
154
155
|
vars = instance_variables.map do |n|
|
155
156
|
"#{n}=#{instance_variable_get(n).inspect}"
|
156
157
|
end
|
157
|
-
"#<%s:0x%x %s>"
|
158
|
+
format("#<%s:0x%x %s>", self.class, object_id, vars.join(", "))
|
158
159
|
end
|
159
160
|
|
160
161
|
# Returns SemVer compliant string representation of this {Format}
|
@@ -168,7 +169,7 @@ module Mixlib
|
|
168
169
|
# {Format} instance
|
169
170
|
# @todo create a proper serialization abstraction
|
170
171
|
def to_semver_string
|
171
|
-
s = [@major, @minor, @patch].join(".")
|
172
|
+
s = [@major, @minor, @patch].map(&:to_i).join(".")
|
172
173
|
s += "-#{@prerelease}" if @prerelease
|
173
174
|
s += "+#{@build}" if @build
|
174
175
|
s
|
@@ -185,7 +186,7 @@ module Mixlib
|
|
185
186
|
# {Format} instance
|
186
187
|
# @todo create a proper serialization abstraction
|
187
188
|
def to_rubygems_string
|
188
|
-
s = [@major, @minor, @patch].join(".")
|
189
|
+
s = [@major, @minor, @patch].map(&:to_i).join(".")
|
189
190
|
s += ".#{@prerelease}" if @prerelease
|
190
191
|
s
|
191
192
|
end
|
@@ -197,6 +198,10 @@ module Mixlib
|
|
197
198
|
# @return [Integer] -1, 0, or 1 depending on whether the this version is
|
198
199
|
# less than, equal to, or greater than the other version
|
199
200
|
def <=>(other)
|
201
|
+
# Check whether the `other' is a String and if so, then get an
|
202
|
+
# instance of *this* class (e.g., GitDescribe, OpscodeSemVer,
|
203
|
+
# SemVer, Rubygems, etc.), so we can compare against it.
|
204
|
+
other = self.class.new(other) if other.is_a?(String)
|
200
205
|
|
201
206
|
# First, perform comparisons based on major, minor, and patch
|
202
207
|
# versions. These are always presnt and always non-nil
|
@@ -251,7 +256,7 @@ module Mixlib
|
|
251
256
|
end
|
252
257
|
|
253
258
|
# If we get down here, they're both equal
|
254
|
-
|
259
|
+
0
|
255
260
|
end
|
256
261
|
|
257
262
|
# @param other [Mixlib::Versioning::Format]
|
@@ -305,7 +310,7 @@ module Mixlib
|
|
305
310
|
|
306
311
|
max_length = [a_components.length, b_components.length].max
|
307
312
|
|
308
|
-
(0..(max_length-1)).each do |i|
|
313
|
+
(0..(max_length - 1)).each do |i|
|
309
314
|
# Convert the ith component into a number if possible
|
310
315
|
a = maybe_int(a_components[i])
|
311
316
|
b = maybe_int(b_components[i])
|
@@ -323,7 +328,7 @@ module Mixlib
|
|
323
328
|
# Now we need to compare appropriately based on type.
|
324
329
|
#
|
325
330
|
# Numbers have lower precedence than strings; therefore, if
|
326
|
-
# the components are of
|
331
|
+
# the components are of different types (String vs. Integer),
|
327
332
|
# we just return -1 for the numeric one and we're done.
|
328
333
|
#
|
329
334
|
# If both are the same type (Integer vs. Integer, or String
|
@@ -343,9 +348,8 @@ module Mixlib
|
|
343
348
|
|
344
349
|
# We've compared all components of both strings; if we've gotten
|
345
350
|
# down here, they're totally the same
|
346
|
-
|
351
|
+
0
|
347
352
|
end
|
348
|
-
|
349
353
|
end # Format
|
350
354
|
end # Versioning
|
351
355
|
end # Mixlib
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@
|
3
|
-
# Author:: Christopher Maier (<cm@
|
4
|
-
# Copyright:: Copyright (c) 2013
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Author:: Christopher Maier (<cm@chef.io>)
|
4
|
+
# Copyright:: Copyright (c) 2013-2018 Chef Software, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -41,10 +41,9 @@ module Mixlib
|
|
41
41
|
# 11.0.0-alpha.1-1-gcea071e
|
42
42
|
# ```
|
43
43
|
#
|
44
|
-
# @author Seth Chisamore (<schisamo@
|
45
|
-
# @author Christopher Maier (<cm@
|
44
|
+
# @author Seth Chisamore (<schisamo@chef.io>)
|
45
|
+
# @author Christopher Maier (<cm@chef.io>)
|
46
46
|
class GitDescribe < Format
|
47
|
-
|
48
47
|
GIT_DESCRIBE_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:\-|\.)?(.+)?\-(\d+)\-g([a-f0-9]{7,40})(?:\-)?(\d+)?$/
|
49
48
|
|
50
49
|
attr_reader :commits_since, :commit_sha
|
@@ -64,7 +63,6 @@ module Mixlib
|
|
64
63
|
# we'll store our internal information in that format
|
65
64
|
@build = "#{@commits_since}.g#{@commit_sha}.#{@iteration}"
|
66
65
|
end
|
67
|
-
|
68
66
|
end # class GitDescribe
|
69
67
|
end # class Format
|
70
68
|
end # module Versioning
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@
|
3
|
-
# Author:: Christopher Maier (<cm@
|
4
|
-
# Copyright:: Copyright (c) 2013
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Author:: Christopher Maier (<cm@chef.io>)
|
4
|
+
# Copyright:: Copyright (c) 2013-2018 Chef Software, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
20
|
+
require_relative "semver"
|
21
21
|
|
22
22
|
module Mixlib
|
23
23
|
class Versioning
|
@@ -51,10 +51,9 @@ module Mixlib
|
|
51
51
|
# 11.0.0-alpha1+20121218164140.git.207.694b062
|
52
52
|
# ```
|
53
53
|
#
|
54
|
-
# @author Seth Chisamore (<schisamo@
|
55
|
-
# @author Christopher Maier (<cm@
|
54
|
+
# @author Seth Chisamore (<schisamo@chef.io>)
|
55
|
+
# @author Christopher Maier (<cm@chef.io>)
|
56
56
|
class OpscodeSemVer < SemVer
|
57
|
-
|
58
57
|
# The pattern is: `YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1`
|
59
58
|
OPSCODE_BUILD_REGEX = /^\d{14}(\.git\.\d+\.[a-f0-9]{7})?$/
|
60
59
|
|
@@ -72,19 +71,9 @@ module Mixlib
|
|
72
71
|
def parse(version_string)
|
73
72
|
super(version_string)
|
74
73
|
|
75
|
-
unless @prerelease.nil?
|
76
|
-
|
77
|
-
raise Mixlib::Versioning::ParseError, "'#{@prerelease}' is not a valid Opscode pre-release signifier!"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
unless @build.nil?
|
82
|
-
unless @build.match(OPSCODE_BUILD_REGEX)
|
83
|
-
raise Mixlib::Versioning::ParseError, "'#{@build}' is not a valid Opscode build signifier!"
|
84
|
-
end
|
85
|
-
end
|
74
|
+
raise Mixlib::Versioning::ParseError, "'#{@prerelease}' is not a valid Opscode pre-release signifier!" unless @prerelease.nil? || @prerelease.match(OPSCODE_PRERELEASE_REGEX)
|
75
|
+
raise Mixlib::Versioning::ParseError, "'#{@build}' is not a valid Opscode build signifier!" unless @build.nil? || @build.match(OPSCODE_BUILD_REGEX)
|
86
76
|
end
|
87
|
-
|
88
77
|
end # class OpscodeSemVer
|
89
78
|
end # class Format
|
90
79
|
end # module Versioning
|