mixlib-versioning 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.expeditor/config.yml +14 -0
  3. data/.expeditor/update_version.sh +9 -0
  4. data/.github/CODEOWNERS +3 -0
  5. data/.travis.yml +20 -19
  6. data/CHANGELOG.md +21 -7
  7. data/Gemfile +4 -4
  8. data/README.md +48 -29
  9. data/Rakefile +20 -6
  10. data/VERSION +1 -0
  11. data/lib/mixlib/versioning.rb +10 -8
  12. data/lib/mixlib/versioning/format.rb +25 -22
  13. data/lib/mixlib/versioning/format/git_describe.rb +1 -1
  14. data/lib/mixlib/versioning/format/opscode_semver.rb +3 -3
  15. data/lib/mixlib/versioning/format/partial_semver.rb +62 -0
  16. data/lib/mixlib/versioning/format/rubygems.rb +9 -3
  17. data/lib/mixlib/versioning/format/semver.rb +1 -1
  18. data/lib/mixlib/versioning/version.rb +1 -1
  19. data/mixlib-versioning.gemspec +14 -14
  20. data/spec/mixlib/versioning/format/git_describe_spec.rb +51 -51
  21. data/spec/mixlib/versioning/format/opscode_semver_spec.rb +43 -43
  22. data/spec/mixlib/versioning/format/partial_semver_spec.rb +121 -0
  23. data/spec/mixlib/versioning/format/rubygems_spec.rb +40 -40
  24. data/spec/mixlib/versioning/format/semver_spec.rb +31 -31
  25. data/spec/mixlib/versioning/format_spec.rb +39 -12
  26. data/spec/mixlib/versioning/versioning_spec.rb +100 -100
  27. data/spec/spec_helper.rb +5 -6
  28. data/spec/support/shared_examples/basic_semver.rb +7 -7
  29. data/spec/support/shared_examples/behaviors/comparable.rb +14 -14
  30. data/spec/support/shared_examples/behaviors/comparable_types.rb +56 -0
  31. data/spec/support/shared_examples/behaviors/filterable.rb +11 -11
  32. data/spec/support/shared_examples/behaviors/parses_valid_version_strings.rb +1 -1
  33. data/spec/support/shared_examples/behaviors/rejects_invalid_version_strings.rb +1 -1
  34. data/spec/support/shared_examples/behaviors/serializable.rb +7 -7
  35. data/spec/support/shared_examples/behaviors/sortable.rb +9 -9
  36. data/spec/support/shared_examples/semver.rb +54 -54
  37. metadata +25 -18
  38. data/.rubocop.yml +0 -22
@@ -0,0 +1,121 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Author:: Ryan Hass (<rhass@chef.io>)
4
+ # Copyright:: Copyright (c) 2017 Chef Software Inc.
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require "spec_helper"
21
+
22
+ describe Mixlib::Versioning::Format::PartialSemVer do
23
+ subject { described_class.new(version_string) }
24
+
25
+ it_has_behavior "serializable", [
26
+ "1",
27
+ "12",
28
+ "1.2",
29
+ "1.23",
30
+ "12.3",
31
+ "12.34",
32
+ ]
33
+
34
+ it_has_behavior "sortable" do
35
+ let(:unsorted_version_strings) do
36
+ %w{
37
+ 2
38
+ 1.1
39
+ 1
40
+ 1.0
41
+ 2.0
42
+ 1.2
43
+ }
44
+ end
45
+ let(:sorted_version_strings) do
46
+ %w{
47
+ 1
48
+ 1.0
49
+ 1.1
50
+ 1.2
51
+ 2
52
+ 2.0
53
+ }
54
+ end
55
+ let(:min) { "1" }
56
+ let(:max) { "2.0" }
57
+ end # it_has_behavior
58
+
59
+ it_has_behavior "filterable" do
60
+ let(:unsorted_version_strings) do
61
+ %w{
62
+ 2
63
+ 1.1
64
+ 1
65
+ 1.0
66
+ 2.0
67
+ 1.2
68
+ 12.0
69
+ 12
70
+ }
71
+ end
72
+ let(:release_versions) do
73
+ %w{
74
+ 2.0
75
+ 1.1
76
+ 1.0
77
+ 1.0
78
+ 2.0
79
+ 1.2
80
+ 12.0
81
+ 12.0
82
+ }
83
+ end
84
+ end # it_has_behavior
85
+
86
+ it_has_behavior "comparable", [
87
+ "1", "2",
88
+ "1", "1.1",
89
+ "1.1", "2",
90
+ "1.1", "1.2"
91
+ ]
92
+
93
+ it_has_behavior "comparable_types", [
94
+ "0.1", { value: "1.0.0.pre.1", class: Mixlib::Versioning::Format::Rubygems },
95
+ "0.1", { value: "1.0.0-rc.1", class: Mixlib::Versioning::Format::OpscodeSemVer },
96
+ "1", { value: "1.0.1", class: Mixlib::Versioning::Format::Rubygems },
97
+ "1", { value: "1.0.1", class: Mixlib::Versioning::Format::SemVer },
98
+ "1", { value: "1.0.1", class: Mixlib::Versioning::Format::OpscodeSemVer },
99
+ "1", { value: "1.0.0-1-gdeadbee-1", class: Mixlib::Versioning::Format::GitDescribe },
100
+ "1", { value: "2.0.0", class: Mixlib::Versioning::Format::Rubygems },
101
+ "1", { value: "2.0.0", class: Mixlib::Versioning::Format::SemVer },
102
+ "1", { value: "2.0.0-rc.1", class: Mixlib::Versioning::Format::OpscodeSemVer },
103
+ "1", { value: "2.0.0-1-gdeadbee-1", class: Mixlib::Versioning::Format::GitDescribe },
104
+ "1", { value: "1.1.0", class: Mixlib::Versioning::Format::Rubygems },
105
+ "1", { value: "1.1.0", class: Mixlib::Versioning::Format::SemVer },
106
+ "1", { value: "1.1.0", class: Mixlib::Versioning::Format::OpscodeSemVer },
107
+ "1", { value: "1.1.0-1-gdeadbee-1", class: Mixlib::Versioning::Format::GitDescribe },
108
+ "1.1", { value: "1.1.1", class: Mixlib::Versioning::Format::Rubygems },
109
+ "1.1", { value: "1.1.1", class: Mixlib::Versioning::Format::SemVer },
110
+ "1.1", { value: "1.1.1", class: Mixlib::Versioning::Format::OpscodeSemVer },
111
+ "1.1", { value: "1.1.1-1-gdeadbee-1", class: Mixlib::Versioning::Format::GitDescribe },
112
+ "1.1", { value: "2.0.0", class: Mixlib::Versioning::Format::Rubygems },
113
+ "1.1", { value: "2.0.0", class: Mixlib::Versioning::Format::SemVer },
114
+ "1.1", { value: "2.0.0", class: Mixlib::Versioning::Format::OpscodeSemVer },
115
+ "1.1", { value: "2.0.0-1-gdeadbee-1", class: Mixlib::Versioning::Format::GitDescribe },
116
+ "1.1", { value: "1.2.0", class: Mixlib::Versioning::Format::Rubygems },
117
+ "1.1", { value: "1.2.0", class: Mixlib::Versioning::Format::SemVer },
118
+ "1.1", { value: "1.2.0", class: Mixlib::Versioning::Format::OpscodeSemVer },
119
+ "1.1", { value: "1.2.0-1-gdeadbee-1", class: Mixlib::Versioning::Format::GitDescribe }
120
+ ]
121
+ end # describe
@@ -16,15 +16,15 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'spec_helper'
19
+ require "spec_helper"
20
20
 
21
21
  describe Mixlib::Versioning::Format::Rubygems do
22
22
  subject { described_class.new(version_string) }
23
23
 
24
- it_should_behave_like 'Basic SemVer'
24
+ it_should_behave_like "Basic SemVer"
25
25
 
26
- it_has_behavior 'parses valid version strings', {
27
- '10.1.1' => {
26
+ it_has_behavior "parses valid version strings", {
27
+ "10.1.1" => {
28
28
  major: 10,
29
29
  minor: 1,
30
30
  patch: 1,
@@ -35,35 +35,35 @@ describe Mixlib::Versioning::Format::Rubygems do
35
35
  build?: false,
36
36
  release_build?: false,
37
37
  prerelease_build?: false,
38
- iteration: 0,
38
+ iteration: nil,
39
39
  },
40
- '10.1.1.alpha.1' => {
40
+ "10.1.1.alpha.1" => {
41
41
  major: 10,
42
42
  minor: 1,
43
43
  patch: 1,
44
- prerelease: 'alpha.1',
44
+ prerelease: "alpha.1",
45
45
  build: nil,
46
46
  release?: false,
47
47
  prerelease?: true,
48
48
  build?: false,
49
49
  release_build?: false,
50
50
  prerelease_build?: false,
51
- iteration: 0,
51
+ iteration: nil,
52
52
  },
53
- '11.0.8.rc.3' => {
53
+ "11.0.8.rc.3" => {
54
54
  major: 11,
55
55
  minor: 0,
56
56
  patch: 8,
57
- prerelease: 'rc.3',
57
+ prerelease: "rc.3",
58
58
  build: nil,
59
59
  release?: false,
60
60
  prerelease?: true,
61
61
  build?: false,
62
62
  release_build?: false,
63
63
  prerelease_build?: false,
64
- iteration: 0,
64
+ iteration: nil,
65
65
  },
66
- '11.0.8-33' => {
66
+ "11.0.8-33" => {
67
67
  major: 11,
68
68
  minor: 0,
69
69
  patch: 8,
@@ -76,11 +76,11 @@ describe Mixlib::Versioning::Format::Rubygems do
76
76
  prerelease_build?: false,
77
77
  iteration: 33,
78
78
  },
79
- '11.0.8.rc.3-1' => {
79
+ "11.0.8.rc.3-1" => {
80
80
  major: 11,
81
81
  minor: 0,
82
82
  patch: 8,
83
- prerelease: 'rc.3',
83
+ prerelease: "rc.3",
84
84
  build: nil,
85
85
  release?: false,
86
86
  prerelease?: true,
@@ -91,67 +91,67 @@ describe Mixlib::Versioning::Format::Rubygems do
91
91
  },
92
92
  }
93
93
 
94
- it_has_behavior 'rejects invalid version strings', {
95
- '1.1.1-rutro' => 'dash for pre-release delimeter',
94
+ it_has_behavior "rejects invalid version strings", {
95
+ "1.1.1-rutro" => "dash for pre-release delimeter",
96
96
  }
97
97
 
98
- it_has_behavior 'serializable', [
99
- '1.0.0',
100
- '1.0.0.alpha.1',
101
- '1.0.0.beta',
98
+ it_has_behavior "serializable", [
99
+ "1.0.0",
100
+ "1.0.0.alpha.1",
101
+ "1.0.0.beta",
102
102
  ]
103
103
 
104
- it_has_behavior 'sortable' do
104
+ it_has_behavior "sortable" do
105
105
  let(:unsorted_version_strings) do
106
- %w(
106
+ %w{
107
107
  1.0.0.beta.2
108
108
  1.3.7.alpha.0
109
109
  1.0.0.alpha
110
110
  1.0.0.rc.1
111
111
  1.0.0
112
- )
112
+ }
113
113
  end
114
114
  let(:sorted_version_strings) do
115
- %w(
115
+ %w{
116
116
  1.0.0.alpha
117
117
  1.0.0.beta.2
118
118
  1.0.0.rc.1
119
119
  1.0.0
120
120
  1.3.7.alpha.0
121
- )
121
+ }
122
122
  end
123
- let(:min) { '1.0.0.alpha' }
124
- let(:max) { '1.3.7.alpha.0' }
123
+ let(:min) { "1.0.0.alpha" }
124
+ let(:max) { "1.3.7.alpha.0" }
125
125
  end
126
126
 
127
127
  # The +Rubygems+ format only produces release and prerelease versions.
128
- it_has_behavior 'filterable' do
128
+ it_has_behavior "filterable" do
129
129
  let(:unsorted_version_strings) do
130
- %w(
130
+ %w{
131
131
  1.0.0.beta.2
132
132
  1.3.7.alpha.0
133
133
  1.0.0.alpha
134
134
  1.0.0.rc.1
135
135
  1.0.0
136
- )
136
+ }
137
137
  end
138
- let(:release_versions) { %w(1.0.0) }
138
+ let(:release_versions) { %w{1.0.0} }
139
139
  let(:prerelease_versions) do
140
- %w(
140
+ %w{
141
141
  1.0.0.beta.2
142
142
  1.3.7.alpha.0
143
143
  1.0.0.alpha
144
144
  1.0.0.rc.1
145
- )
145
+ }
146
146
  end
147
147
  end
148
148
 
149
- it_has_behavior 'comparable', [
150
- '0.1.0', '0.2.0',
151
- '1.0.0.alpha.1', '1.0.0',
152
- '1.2.3.alpha', '1.2.3.alpha.1',
153
- '2.4.5.alpha', '2.4.5.beta',
154
- '3.0.0.beta.1', '3.0.0.rc.1',
155
- '3.1.2.rc.42', '3.1.2'
149
+ it_has_behavior "comparable", [
150
+ "0.1.0", "0.2.0",
151
+ "1.0.0.alpha.1", "1.0.0",
152
+ "1.2.3.alpha", "1.2.3.alpha.1",
153
+ "2.4.5.alpha", "2.4.5.beta",
154
+ "3.0.0.beta.1", "3.0.0.rc.1",
155
+ "3.1.2.rc.42", "3.1.2"
156
156
  ]
157
157
  end
@@ -16,23 +16,23 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'spec_helper'
19
+ require "spec_helper"
20
20
 
21
21
  describe Mixlib::Versioning::Format::SemVer do
22
22
  subject { described_class.new(version_string) }
23
23
 
24
24
  it_should_behave_like Mixlib::Versioning::Format::SemVer
25
25
 
26
- it_has_behavior 'serializable', [
27
- '1.0.0',
28
- '1.0.0-alpha.1',
29
- '1.0.0-alpha.1+some.build.version',
30
- '1.0.0+build.build.build',
26
+ it_has_behavior "serializable", [
27
+ "1.0.0",
28
+ "1.0.0-alpha.1",
29
+ "1.0.0-alpha.1+some.build.version",
30
+ "1.0.0+build.build.build",
31
31
  ]
32
32
 
33
- it_has_behavior 'sortable' do
33
+ it_has_behavior "sortable" do
34
34
  let(:unsorted_version_strings) do
35
- %w(
35
+ %w{
36
36
  1.0.0-beta.2
37
37
  1.0.0-alpha
38
38
  1.0.0-alpha.july
@@ -45,10 +45,10 @@ describe Mixlib::Versioning::Format::SemVer do
45
45
  1.3.7+build.2.b8f12d7
46
46
  1.3.7+build.11.e0f985a
47
47
  1.3.7+build
48
- )
48
+ }
49
49
  end
50
50
  let(:sorted_version_strings) do
51
- %w(
51
+ %w{
52
52
  1.0.0-alpha
53
53
  1.0.0-alpha.1
54
54
  1.0.0-alpha.july
@@ -61,15 +61,15 @@ describe Mixlib::Versioning::Format::SemVer do
61
61
  1.3.7+build
62
62
  1.3.7+build.2.b8f12d7
63
63
  1.3.7+build.11.e0f985a
64
- )
64
+ }
65
65
  end
66
- let(:min) { '1.0.0-alpha' }
67
- let(:max) { '1.3.7+build.11.e0f985a' }
66
+ let(:min) { "1.0.0-alpha" }
67
+ let(:max) { "1.3.7+build.11.e0f985a" }
68
68
  end # it_has_behavior
69
69
 
70
- it_has_behavior 'filterable' do
70
+ it_has_behavior "filterable" do
71
71
  let(:unsorted_version_strings) do
72
- %w(
72
+ %w{
73
73
  1.0.0-beta.2
74
74
  1.0.0-alpha
75
75
  1.0.0-rc.1+build.1
@@ -81,48 +81,48 @@ describe Mixlib::Versioning::Format::SemVer do
81
81
  1.3.7+build.2.b8f12d7
82
82
  1.3.7+build.11.e0f985a
83
83
  1.3.7+build
84
- )
84
+ }
85
85
  end
86
86
  let(:release_versions) do
87
- %w(
88
- 1.0.0 )
87
+ %w{
88
+ 1.0.0 }
89
89
  end
90
90
  let(:prerelease_versions) do
91
- %w(
91
+ %w{
92
92
  1.0.0-beta.2
93
93
  1.0.0-alpha
94
94
  1.0.0-beta.11
95
95
  1.0.0-rc.1
96
96
  1.0.0-alpha.1
97
- )
97
+ }
98
98
  end
99
99
  let(:build_versions) do
100
- %w(
100
+ %w{
101
101
  1.0.0-rc.1+build.1
102
102
  1.0.0+0.3.7
103
103
  1.3.7+build.2.b8f12d7
104
104
  1.3.7+build.11.e0f985a
105
105
  1.3.7+build
106
- )
106
+ }
107
107
  end
108
108
  let(:release_build_versions) do
109
- %w(
109
+ %w{
110
110
  1.0.0+0.3.7
111
111
  1.3.7+build.2.b8f12d7
112
112
  1.3.7+build.11.e0f985a
113
113
  1.3.7+build
114
- )
114
+ }
115
115
  end
116
116
  let(:prerelease_build_versions) do
117
- %w(
118
- 1.0.0-rc.1+build.1 )
117
+ %w{
118
+ 1.0.0-rc.1+build.1 }
119
119
  end
120
120
  end # it_has_behavior
121
121
 
122
- it_has_behavior 'comparable', [
123
- '0.1.0', '0.2.0',
124
- '1.0.0-alpha.1', '1.0.0',
125
- '1.2.3', '1.2.3+build.123',
126
- '2.0.0-beta.1', '2.0.0-beta.1+build.123'
122
+ it_has_behavior "comparable", [
123
+ "0.1.0", "0.2.0",
124
+ "1.0.0-alpha.1", "1.0.0",
125
+ "1.2.3", "1.2.3+build.123",
126
+ "2.0.0-beta.1", "2.0.0-beta.1+build.123"
127
127
  ]
128
128
  end # describe
@@ -1,6 +1,8 @@
1
1
  #
2
2
  # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Author:: Ryan Hass (<rhass@chef.io>)
3
4
  # Copyright:: Copyright (c) 2013 Opscode, Inc.
5
+ # Copyright:: Copyright (c) 2017 Chef Software Inc.
4
6
  # License:: Apache License, Version 2.0
5
7
  #
6
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,42 +18,42 @@
16
18
  # limitations under the License.
17
19
  #
18
20
 
19
- require 'spec_helper'
21
+ require "spec_helper"
20
22
 
21
23
  describe Mixlib::Versioning::Format do
22
- describe '#initialize' do
24
+ describe "#initialize" do
23
25
  subject { described_class.new(version_string) }
24
- let(:version_string) { '11.0.0' }
26
+ let(:version_string) { "11.0.0" }
25
27
 
26
- it 'descendants must override #parse' do
27
- expect { subject }.to raise_error
28
+ it "descendants must override #parse" do
29
+ expect { subject }.to raise_error(StandardError)
28
30
  end
29
31
  end
30
32
 
31
- describe '.for' do
33
+ describe ".for" do
32
34
  subject { described_class }
33
35
 
34
36
  [
35
37
  :rubygems,
36
- 'rubygems',
38
+ "rubygems",
37
39
  Mixlib::Versioning::Format::Rubygems,
38
40
  ].each do |format_type|
39
41
  context 'format_type is a: #{format_type.class}' do
40
42
  let(:format_type) { format_type }
41
- it 'returns the correct format class' do
42
- subject.for(format_type).should eq Mixlib::Versioning::Format::Rubygems
43
+ it "returns the correct format class" do
44
+ expect(subject.for(format_type)).to eq Mixlib::Versioning::Format::Rubygems
43
45
  end # it
44
46
  end # context
45
47
  end # each
46
48
 
47
- describe 'unknown format_type' do
49
+ describe "unknown format_type" do
48
50
  [
49
51
  :poop,
50
- 'poop',
52
+ "poop",
51
53
  Mixlib::Versioning,
52
54
  ].each do |invalid_format_type|
53
55
  context 'format_type is a: #{invalid_format_type.class}' do
54
- it 'raises a Mixlib::Versioning::UnknownFormatError' do
56
+ it "raises a Mixlib::Versioning::UnknownFormatError" do
55
57
  expect { subject.for(invalid_format_type) }.to raise_error(Mixlib::Versioning::UnknownFormatError)
56
58
  end # it
57
59
  end # context
@@ -59,3 +61,28 @@ describe Mixlib::Versioning::Format do
59
61
  end # describe
60
62
  end # describe ".for"
61
63
  end # describe Mixlib::Versioning::Format
64
+
65
+ describe Mixlib::Versioning do
66
+ versions = [
67
+ "1", "1.0.0",
68
+ "1.2", "1.2.0"
69
+ ]
70
+
71
+ describe "#==" do
72
+ formats = described_class::DEFAULT_FORMATS.select do |klass|
73
+ unless klass.name == "Mixlib::Versioning::Format::PartialSemVer" || klass.name == "Mixlib::Versioning::Format::GitDescribe"
74
+ klass
75
+ end
76
+ end
77
+
78
+ formats.each do |format|
79
+ context "#{format}" do
80
+ versions.each_slice(2) do |a, b|
81
+ it "parsed value #{a} is equal to #{format} parsed value #{b}" do
82
+ expect(described_class.parse(a) == format.new(b)).to be true
83
+ end
84
+ end
85
+ end # context
86
+ end # formats.each
87
+ end # describe "#=="
88
+ end # describe Mixlib::Version