mixlib-versioning 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 +7 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +22 -0
- data/.travis.yml +24 -0
- data/CHANGELOG.md +16 -1
- data/Gemfile +3 -4
- data/README.md +9 -15
- data/Rakefile +15 -3
- data/lib/mixlib/versioning.rb +32 -29
- data/lib/mixlib/versioning/exceptions.rb +1 -1
- data/lib/mixlib/versioning/format.rb +33 -31
- data/lib/mixlib/versioning/format/git_describe.rb +5 -7
- data/lib/mixlib/versioning/format/opscode_semver.rb +6 -17
- data/lib/mixlib/versioning/format/rubygems.rb +6 -8
- data/lib/mixlib/versioning/format/semver.rb +9 -11
- data/lib/mixlib/versioning/version.rb +2 -2
- data/mixlib-versioning.gemspec +20 -14
- data/spec/mixlib/versioning/format/git_describe_spec.rb +143 -131
- data/spec/mixlib/versioning/format/opscode_semver_spec.rb +106 -81
- data/spec/mixlib/versioning/format/rubygems_spec.rb +119 -104
- data/spec/mixlib/versioning/format/semver_spec.rb +98 -77
- data/spec/mixlib/versioning/format_spec.rb +17 -25
- data/spec/mixlib/versioning/versioning_spec.rb +163 -141
- data/spec/spec_helper.rb +2 -2
- data/spec/support/shared_examples/basic_semver.rb +19 -21
- data/spec/support/shared_examples/behaviors/comparable.rb +80 -0
- data/spec/support/shared_examples/behaviors/filterable.rb +19 -31
- data/spec/support/shared_examples/behaviors/parses_valid_version_strings.rb +4 -7
- data/spec/support/shared_examples/behaviors/rejects_invalid_version_strings.rb +3 -6
- data/spec/support/shared_examples/behaviors/serializable.rb +5 -7
- data/spec/support/shared_examples/behaviors/sortable.rb +7 -9
- data/spec/support/shared_examples/semver.rb +81 -69
- metadata +51 -26
- data/.yardopts +0 -7
- data/CONTRIBUTING.md +0 -188
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 28ef6df6d8dc796e621f82bcee6b89aba96c33c5
|
4
|
+
data.tar.gz: 3e245ccbd6e91f1580fb46b9cceb8beaef3f9571
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ad67861275ced52c5be0ef6f253a12417321b17c3f60211cc33e0a676224f0973270599fbc330be4ca67136f8f988128a67f25dc4dd98b3cf9e6108578a19e7
|
7
|
+
data.tar.gz: cf522492b9b76fad90a08330b7c5038c9b80e734fb6a309ff4925c3ee60400c294a62bb0d10355ed984ff868432636566224fcecf9c8166ec962308071f576da
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
AbcSize:
|
2
|
+
Enabled: false
|
3
|
+
BracesAroundHashParameters:
|
4
|
+
Enabled: false
|
5
|
+
ClassLength:
|
6
|
+
Enabled: false
|
7
|
+
CyclomaticComplexity:
|
8
|
+
Enabled: false
|
9
|
+
Documentation:
|
10
|
+
Enabled: false
|
11
|
+
Encoding:
|
12
|
+
Enabled: false
|
13
|
+
LineLength:
|
14
|
+
Enabled: false
|
15
|
+
MethodLength:
|
16
|
+
Enabled: false
|
17
|
+
PerceivedComplexity:
|
18
|
+
Enabled: false
|
19
|
+
RescueModifier:
|
20
|
+
Enabled: false
|
21
|
+
TrailingComma:
|
22
|
+
EnforcedStyleForMultiline: comma
|
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
rvm:
|
2
|
+
- 1.9.3
|
3
|
+
- 2.0.0
|
4
|
+
- 2.1.0
|
5
|
+
|
6
|
+
bundler_args: --jobs 7
|
7
|
+
|
8
|
+
branches:
|
9
|
+
only:
|
10
|
+
- master
|
11
|
+
|
12
|
+
script: bundle exec rake travis:ci
|
13
|
+
|
14
|
+
notifications:
|
15
|
+
hipchat:
|
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=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
-
|
1
|
+
v1.1.0 / 2015-06-15
|
2
|
+
-------------------
|
3
|
+
|
4
|
+
### New features
|
5
|
+
|
6
|
+
* Allow parse to take a list of formats to choose from
|
7
|
+
* Update to SemVer 2.0.0
|
8
|
+
|
9
|
+
### Improvements
|
10
|
+
|
11
|
+
* Add ability to compare directly with strings.
|
12
|
+
* Lock to RuboCop 0.31.0 (also fix style errors)
|
13
|
+
|
14
|
+
|
15
|
+
v1.0.0 / 2013-03-29
|
16
|
+
-------------------
|
2
17
|
|
3
18
|
* The initial release. Versioning parsing shouldn't suck.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# Mixlib::Versioning
|
2
2
|
|
3
|
+
[](https://travis-ci.org/chef/mixlib-versioning)
|
4
|
+
[](https://codeclimate.com/github/chef/mixlib-versioning)
|
5
|
+
|
6
|
+
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
|
+
|
3
8
|
Versioning is hard! `mixlib-versioning` is a general Ruby library that allows
|
4
9
|
you to parse, compare and manipulate version numbers in multiple formats.
|
5
10
|
Currently the following version string formats are supported:
|
6
11
|
|
7
|
-
### SemVer 2.0.0
|
12
|
+
### SemVer 2.0.0
|
8
13
|
|
9
14
|
**Specification:**
|
10
15
|
|
@@ -227,7 +232,7 @@ false
|
|
227
232
|
[1] #<Mixlib::Versioning::Format::OpscodeSemVer:0x3ff009d07260 @major=11, @minor=0, @patch=0, @prerelease="rc.1", @build=nil, @input="11.0.0-rc.1">,
|
228
233
|
[2] #<Mixlib::Versioning::Format::OpscodeSemVer:0x3ff009d0d3cc @major=11, @minor=0, @patch=0, @prerelease=nil, @build=nil, @input="11.0.0">
|
229
234
|
]
|
230
|
-
>> [v3, v1, v2].map{|v| v.to_s}.sort
|
235
|
+
>> [v3, v1, v2].map { |v| v.to_s}.sort
|
231
236
|
[
|
232
237
|
[0] "11.0.0",
|
233
238
|
[1] "11.0.0-beta.1",
|
@@ -331,21 +336,12 @@ All documentation is written using YARD. You can generate a by running:
|
|
331
336
|
rake yard
|
332
337
|
```
|
333
338
|
|
334
|
-
## Contributing
|
335
|
-
|
336
|
-
See the [CONTRIBUTING](CONTRIBUTING.md) document.
|
337
|
-
|
338
|
-
## Reporting Bugs
|
339
|
-
|
340
|
-
You can search for known issues in [Opscode's bug tracker][jira]. Tickets
|
341
|
-
should be filed under the **MIXLIB** project with the component set to
|
342
|
-
**"mixlib-versioning"**.
|
343
|
-
|
344
339
|
## License
|
345
340
|
|
346
341
|
| | |
|
347
342
|
|:---------------------|:-----------------------------------------|
|
348
|
-
| **Author:** | Seth Chisamore (schisamo@
|
343
|
+
| **Author:** | Seth Chisamore (schisamo@chef.io)
|
344
|
+
| **Author:** | Christopher Maier (cm@chef.io)
|
349
345
|
| **Copyright:** | Copyright (c) 2013 Opscode, Inc.
|
350
346
|
| **License:** | Apache License, Version 2.0
|
351
347
|
|
@@ -360,5 +356,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
|
360
356
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
361
357
|
See the License for the specific language governing permissions and
|
362
358
|
limitations under the License.
|
363
|
-
|
364
|
-
[jira]: http://tickets.opscode.com/browse/MIXLIB
|
data/Rakefile
CHANGED
@@ -1,6 +1,18 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
2
3
|
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new(:unit)
|
5
|
+
|
6
|
+
require 'rubocop/rake_task'
|
7
|
+
desc 'Run Ruby style checks'
|
8
|
+
RuboCop::RakeTask.new(:style)
|
9
|
+
|
3
10
|
require 'yard'
|
11
|
+
YARD::Rake::YardocTask.new(:doc)
|
12
|
+
|
13
|
+
namespace :travis do
|
14
|
+
desc 'Run tests on Travis'
|
15
|
+
task ci: [:style, :unit]
|
16
|
+
end
|
4
17
|
|
5
|
-
|
6
|
-
YARD::Rake::YardocTask.new
|
18
|
+
task default: [:style, :unit]
|
data/lib/mixlib/versioning.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@
|
3
|
-
# Author:: Christopher Maier (<cm@
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Author:: Christopher Maier (<cm@chef.io>)
|
4
4
|
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
@@ -21,46 +21,50 @@ require 'mixlib/versioning/exceptions'
|
|
21
21
|
require 'mixlib/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
|
+
].freeze
|
27
33
|
|
28
34
|
# Create a new {Format} instance given a version string to parse, and an
|
29
35
|
# optional format type.
|
30
36
|
#
|
31
37
|
# @example
|
32
|
-
# Mixlib::Versioning.parse(
|
33
|
-
# Mixlib::Versioning.parse(
|
34
|
-
# Mixlib::Versioning.parse(
|
35
|
-
# Mixlib::Versioning.parse(
|
38
|
+
# Mixlib::Versioning.parse('11.0.0')
|
39
|
+
# Mixlib::Versioning.parse('11.0.0', :semver)
|
40
|
+
# Mixlib::Versioning.parse('11.0.0', 'semver')
|
41
|
+
# Mixlib::Versioning.parse('11.0.0', Mixlib::Versioning::Format::SemVer)
|
36
42
|
#
|
37
43
|
# @param version_string [String] String representatin of the version to
|
38
44
|
# parse
|
39
|
-
# @param
|
45
|
+
# @param format [String, Symbol, Mixlib::Versioning::Format, Array] Optional
|
40
46
|
# format type to parse the version string as. If this is exluded all
|
41
47
|
# version types will be attempted from most specific to most specific
|
42
|
-
# with a preference for SemVer formats
|
43
|
-
#
|
48
|
+
# with a preference for SemVer formats. If it is an array, only version
|
49
|
+
# types in that list will be considered
|
44
50
|
# @raise [Mixlib::Versioning::ParseError] if the parse fails.
|
45
51
|
# @raise [Mixlib::Versioning::UnknownFormatError] if the given format type
|
46
52
|
# doesn't exist.
|
47
53
|
#
|
48
54
|
# @return
|
49
55
|
#
|
50
|
-
def self.parse(version_string,
|
51
|
-
if version_string.
|
56
|
+
def self.parse(version_string, format = nil)
|
57
|
+
if version_string.is_a?(Mixlib::Versioning::Format)
|
52
58
|
return version_string
|
53
|
-
elsif format_type
|
54
|
-
return Mixlib::Versioning::Format.for(format_type).new(version_string)
|
55
59
|
else
|
60
|
+
formats = if format
|
61
|
+
[format].flatten.map { |f| Mixlib::Versioning::Format.for(f) }
|
62
|
+
else
|
63
|
+
DEFAULT_FORMATS
|
64
|
+
end
|
56
65
|
# Attempt to parse from the most specific formats first.
|
57
66
|
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|
|
67
|
+
formats.each do |version|
|
64
68
|
begin
|
65
69
|
break parsed_version = version.new(version_string)
|
66
70
|
rescue Mixlib::Versioning::ParseError
|
@@ -103,7 +107,7 @@ module Mixlib
|
|
103
107
|
# 11.0.1 }
|
104
108
|
#
|
105
109
|
# Mixlib::Versioning.find_target_version(all,
|
106
|
-
#
|
110
|
+
# '11.0.1',
|
107
111
|
# true,
|
108
112
|
# true)
|
109
113
|
#
|
@@ -124,19 +128,19 @@ module Mixlib
|
|
124
128
|
# build version specifier will be filtered out.
|
125
129
|
#
|
126
130
|
def self.find_target_version(all_versions,
|
127
|
-
filter_version=nil,
|
128
|
-
use_prerelease_versions=false,
|
129
|
-
use_build_versions=false)
|
131
|
+
filter_version = nil,
|
132
|
+
use_prerelease_versions = false,
|
133
|
+
use_build_versions = false)
|
130
134
|
|
131
135
|
# attempt to parse a `Mixlib::Versioning::Format` instance if we were
|
132
136
|
# passed a string
|
133
137
|
unless filter_version.nil? ||
|
134
|
-
filter_version.
|
138
|
+
filter_version.is_a?(Mixlib::Versioning::Format)
|
135
139
|
filter_version = Mixlib::Versioning.parse(filter_version)
|
136
140
|
end
|
137
141
|
|
138
142
|
all_versions.map! do |v|
|
139
|
-
if v.
|
143
|
+
if v.is_a?(Mixlib::Versioning::Format)
|
140
144
|
v
|
141
145
|
else
|
142
146
|
Mixlib::Versioning.parse(v)
|
@@ -153,7 +157,7 @@ module Mixlib
|
|
153
157
|
# that prerelease, and then take the most recent. Otherwise, just
|
154
158
|
# return the specified prerelease version
|
155
159
|
if use_build_versions
|
156
|
-
all_versions.select{|v| v.in_same_prerelease_line?(filter_version)}.max
|
160
|
+
all_versions.select { |v| v.in_same_prerelease_line?(filter_version) }.max
|
157
161
|
else
|
158
162
|
filter_version
|
159
163
|
end
|
@@ -189,6 +193,5 @@ module Mixlib
|
|
189
193
|
end.max # select the most recent version
|
190
194
|
end # if
|
191
195
|
end # self.find_target_version
|
192
|
-
|
193
196
|
end # Versioning
|
194
197
|
end # Mixlib
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
3
|
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
@@ -23,8 +23,7 @@ require 'mixlib/versioning/format/semver'
|
|
23
23
|
|
24
24
|
module Mixlib
|
25
25
|
class Versioning
|
26
|
-
|
27
|
-
# @author Seth Chisamore (<schisamo@opscode.com>)
|
26
|
+
# @author Seth Chisamore (<schisamo@chef.io>)
|
28
27
|
#
|
29
28
|
# @!attribute [r] major
|
30
29
|
# @return [Integer] major identifier
|
@@ -60,18 +59,18 @@ module Mixlib
|
|
60
59
|
# @return [Class] the {Mixlib::Versioning::Format} class
|
61
60
|
#
|
62
61
|
def self.for(format_type)
|
63
|
-
if format_type.
|
62
|
+
if format_type.is_a?(Class) &&
|
64
63
|
format_type.ancestors.include?(Mixlib::Versioning::Format)
|
65
64
|
format_type
|
66
65
|
else
|
67
66
|
case format_type.to_s
|
68
|
-
when 'semver'
|
69
|
-
when 'opscode_semver'
|
70
|
-
when 'git_describe'
|
71
|
-
when 'rubygems'
|
67
|
+
when 'semver' then Mixlib::Versioning::Format::SemVer
|
68
|
+
when 'opscode_semver' then Mixlib::Versioning::Format::OpscodeSemVer
|
69
|
+
when 'git_describe' then Mixlib::Versioning::Format::GitDescribe
|
70
|
+
when 'rubygems' then Mixlib::Versioning::Format::Rubygems
|
72
71
|
else
|
73
|
-
msg = "'#{format_type
|
74
|
-
|
72
|
+
msg = "'#{format_type}' is not a supported Mixlib::Versioning format"
|
73
|
+
fail Mixlib::Versioning::UnknownFormatError, msg
|
75
74
|
end
|
76
75
|
end
|
77
76
|
end
|
@@ -90,8 +89,8 @@ module Mixlib
|
|
90
89
|
#
|
91
90
|
# @param version_string [String] string representation of the version
|
92
91
|
# @raise [Mixlib::Versioning::ParseError] raised if parsing fails
|
93
|
-
def parse(
|
94
|
-
|
92
|
+
def parse(_version_string)
|
93
|
+
fail Error, 'You must override the #parse'
|
95
94
|
end
|
96
95
|
|
97
96
|
# @return [Boolean] Whether or not this is a release version
|
@@ -101,22 +100,22 @@ module Mixlib
|
|
101
100
|
|
102
101
|
# @return [Boolean] Whether or not this is a pre-release version
|
103
102
|
def prerelease?
|
104
|
-
|
103
|
+
!@prerelease.nil? && @build.nil?
|
105
104
|
end
|
106
105
|
|
107
106
|
# @return [Boolean] Whether or not this is a release build version
|
108
107
|
def release_build?
|
109
|
-
|
108
|
+
@prerelease.nil? && !@build.nil?
|
110
109
|
end
|
111
110
|
|
112
111
|
# @return [Boolean] Whether or not this is a pre-release build version
|
113
112
|
def prerelease_build?
|
114
|
-
|
113
|
+
!@prerelease.nil? && !@build.nil?
|
115
114
|
end
|
116
115
|
|
117
116
|
# @return [Boolean] Whether or not this is a build version
|
118
117
|
def build?
|
119
|
-
|
118
|
+
!@build.nil?
|
120
119
|
end
|
121
120
|
|
122
121
|
# Returns `true` if `other` and this {Format} share the same `major`,
|
@@ -126,8 +125,8 @@ module Mixlib
|
|
126
125
|
# @return [Boolean]
|
127
126
|
def in_same_release_line?(other)
|
128
127
|
@major == other.major &&
|
129
|
-
|
130
|
-
|
128
|
+
@minor == other.minor &&
|
129
|
+
@patch == other.patch
|
131
130
|
end
|
132
131
|
|
133
132
|
# Returns `true` if `other` an share the same
|
@@ -137,9 +136,9 @@ module Mixlib
|
|
137
136
|
# @return [Boolean]
|
138
137
|
def in_same_prerelease_line?(other)
|
139
138
|
@major == other.major &&
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
@minor == other.minor &&
|
140
|
+
@patch == other.patch &&
|
141
|
+
@prerelease == other.prerelease
|
143
142
|
end
|
144
143
|
|
145
144
|
# @return [String] String representation of this {Format} instance
|
@@ -154,7 +153,7 @@ module Mixlib
|
|
154
153
|
vars = instance_variables.map do |n|
|
155
154
|
"#{n}=#{instance_variable_get(n).inspect}"
|
156
155
|
end
|
157
|
-
|
156
|
+
format('#<%s:0x%x %s>', self.class, object_id, vars.join(', '))
|
158
157
|
end
|
159
158
|
|
160
159
|
# Returns SemVer compliant string representation of this {Format}
|
@@ -168,7 +167,7 @@ module Mixlib
|
|
168
167
|
# {Format} instance
|
169
168
|
# @todo create a proper serialization abstraction
|
170
169
|
def to_semver_string
|
171
|
-
s = [@major, @minor, @patch].join(
|
170
|
+
s = [@major, @minor, @patch].join('.')
|
172
171
|
s += "-#{@prerelease}" if @prerelease
|
173
172
|
s += "+#{@build}" if @build
|
174
173
|
s
|
@@ -185,7 +184,7 @@ module Mixlib
|
|
185
184
|
# {Format} instance
|
186
185
|
# @todo create a proper serialization abstraction
|
187
186
|
def to_rubygems_string
|
188
|
-
s = [@major, @minor, @patch].join(
|
187
|
+
s = [@major, @minor, @patch].join('.')
|
189
188
|
s += ".#{@prerelease}" if @prerelease
|
190
189
|
s
|
191
190
|
end
|
@@ -197,6 +196,10 @@ module Mixlib
|
|
197
196
|
# @return [Integer] -1, 0, or 1 depending on whether the this version is
|
198
197
|
# less than, equal to, or greater than the other version
|
199
198
|
def <=>(other)
|
199
|
+
# Check whether the `other' is a String and if so, then get an
|
200
|
+
# instance of *this* class (e.g., GitDescribe, OpscodeSemVer,
|
201
|
+
# SemVer, Rubygems, etc.), so we can compare against it.
|
202
|
+
other = self.class.new(other) if other.is_a?(String)
|
200
203
|
|
201
204
|
# First, perform comparisons based on major, minor, and patch
|
202
205
|
# versions. These are always presnt and always non-nil
|
@@ -251,7 +254,7 @@ module Mixlib
|
|
251
254
|
end
|
252
255
|
|
253
256
|
# If we get down here, they're both equal
|
254
|
-
|
257
|
+
0
|
255
258
|
end
|
256
259
|
|
257
260
|
# @param other [Mixlib::Versioning::Format]
|
@@ -266,7 +269,7 @@ module Mixlib
|
|
266
269
|
end
|
267
270
|
|
268
271
|
def hash
|
269
|
-
[@major, @minor, @patch, @prerelease, @build].compact.join(
|
272
|
+
[@major, @minor, @patch, @prerelease, @build].compact.join('.').hash
|
270
273
|
end
|
271
274
|
|
272
275
|
#########################################################################
|
@@ -300,12 +303,12 @@ module Mixlib
|
|
300
303
|
# Both `a_item` and `b_item` should be Strings; `nil` is not a
|
301
304
|
# valid input.
|
302
305
|
def compare_dot_components(a_item, b_item)
|
303
|
-
a_components = a_item.split(
|
304
|
-
b_components = b_item.split(
|
306
|
+
a_components = a_item.split('.')
|
307
|
+
b_components = b_item.split('.')
|
305
308
|
|
306
309
|
max_length = [a_components.length, b_components.length].max
|
307
310
|
|
308
|
-
(0..(max_length-1)).each do |i|
|
311
|
+
(0..(max_length - 1)).each do |i|
|
309
312
|
# Convert the ith component into a number if possible
|
310
313
|
a = maybe_int(a_components[i])
|
311
314
|
b = maybe_int(b_components[i])
|
@@ -343,9 +346,8 @@ module Mixlib
|
|
343
346
|
|
344
347
|
# We've compared all components of both strings; if we've gotten
|
345
348
|
# down here, they're totally the same
|
346
|
-
|
349
|
+
0
|
347
350
|
end
|
348
|
-
|
349
351
|
end # Format
|
350
352
|
end # Versioning
|
351
353
|
end # Mixlib
|