mixlib-versioning 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +22 -0
  4. data/.travis.yml +24 -0
  5. data/CHANGELOG.md +16 -1
  6. data/Gemfile +3 -4
  7. data/README.md +9 -15
  8. data/Rakefile +15 -3
  9. data/lib/mixlib/versioning.rb +32 -29
  10. data/lib/mixlib/versioning/exceptions.rb +1 -1
  11. data/lib/mixlib/versioning/format.rb +33 -31
  12. data/lib/mixlib/versioning/format/git_describe.rb +5 -7
  13. data/lib/mixlib/versioning/format/opscode_semver.rb +6 -17
  14. data/lib/mixlib/versioning/format/rubygems.rb +6 -8
  15. data/lib/mixlib/versioning/format/semver.rb +9 -11
  16. data/lib/mixlib/versioning/version.rb +2 -2
  17. data/mixlib-versioning.gemspec +20 -14
  18. data/spec/mixlib/versioning/format/git_describe_spec.rb +143 -131
  19. data/spec/mixlib/versioning/format/opscode_semver_spec.rb +106 -81
  20. data/spec/mixlib/versioning/format/rubygems_spec.rb +119 -104
  21. data/spec/mixlib/versioning/format/semver_spec.rb +98 -77
  22. data/spec/mixlib/versioning/format_spec.rb +17 -25
  23. data/spec/mixlib/versioning/versioning_spec.rb +163 -141
  24. data/spec/spec_helper.rb +2 -2
  25. data/spec/support/shared_examples/basic_semver.rb +19 -21
  26. data/spec/support/shared_examples/behaviors/comparable.rb +80 -0
  27. data/spec/support/shared_examples/behaviors/filterable.rb +19 -31
  28. data/spec/support/shared_examples/behaviors/parses_valid_version_strings.rb +4 -7
  29. data/spec/support/shared_examples/behaviors/rejects_invalid_version_strings.rb +3 -6
  30. data/spec/support/shared_examples/behaviors/serializable.rb +5 -7
  31. data/spec/support/shared_examples/behaviors/sortable.rb +7 -9
  32. data/spec/support/shared_examples/semver.rb +81 -69
  33. metadata +51 -26
  34. data/.yardopts +0 -7
  35. data/CONTRIBUTING.md +0 -188
@@ -1,5 +1,5 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
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
  #
@@ -19,95 +19,120 @@
19
19
  require 'spec_helper'
20
20
 
21
21
  describe Mixlib::Versioning::Format::OpscodeSemVer do
22
-
23
- subject{ described_class.new(version_string) }
22
+ subject { described_class.new(version_string) }
24
23
 
25
24
  it_should_behave_like Mixlib::Versioning::Format::SemVer
26
25
 
27
- it_has_behavior "rejects invalid version strings", {
28
- "1.0.0-poop.0" => "non-valid pre-release type",
29
- "1.0.0+2010AA08010101" => "a malformed timestamp",
30
- "1.0.0+cvs.33.e0f985a" => "a malformed git describe: no git string",
31
- "1.0.0+git.AA.e0f985a" => "a malformed git describe: non-numeric COMMITS_SINCE",
32
- "1.0.0+git.33.z0f985a" => "a malformed git describe: invalid SHA1"
26
+ it_has_behavior 'rejects invalid version strings', {
27
+ '1.0.0-poop.0' => 'non-valid pre-release type',
28
+ '1.0.0+2010AA08010101' => 'a malformed timestamp',
29
+ '1.0.0+cvs.33.e0f985a' => 'a malformed git describe: no git string',
30
+ '1.0.0+git.AA.e0f985a' => 'a malformed git describe: non-numeric COMMITS_SINCE',
31
+ '1.0.0+git.33.z0f985a' => 'a malformed git describe: invalid SHA1',
32
+ '11.0.08-rc.1+20130308110833' => 'leading zero invalid',
33
+ '01.0.8-alpha.2+20130308110833.git.2.94a1dde' => 'leading zero invalid',
34
+ '11.02.8-rc.1+20130308110833' => 'leading zero invalid',
35
+ '0008.1.4' => 'leading zero invalid',
36
+ '11.00000000002.8-rc.1+20130308110833' => 'leading zero invalid',
37
+ '4.67.00012+build.20131219' => 'leading zero invalid',
38
+ '3.6.7-rc.007' => 'leading zero invalid',
33
39
  }
34
40
 
35
- it_has_behavior "serializable", [
36
- "1.0.0",
37
- "1.0.0-alpha.1",
38
- "1.0.0-alpha.1+20130308110833",
39
- "1.0.0+20130308110833.git.2.94a1dde"
41
+ it_has_behavior 'serializable', [
42
+ '1.0.0',
43
+ '1.0.0-alpha.1',
44
+ '1.0.0-alpha.1+20130308110833',
45
+ '1.0.0+20130308110833.git.2.94a1dde',
40
46
  ]
41
47
 
42
- it_has_behavior "sortable" do
43
- let(:unsorted_version_strings){%w{
44
- 1.0.0-beta.2
45
- 1.0.0-alpha
46
- 1.0.0-rc.1+20130309074433
47
- 1.0.0
48
- 1.0.0-beta.11
49
- 1.0.0+20121009074433
50
- 1.0.0-rc.1
51
- 1.0.0-alpha.1
52
- 1.3.7+20131009104433.git.2.94a1dde
53
- 1.3.7+20131009104433
54
- 1.3.7+20131009074433
55
- }}
56
- let(:sorted_version_strings){%w{
57
- 1.0.0-alpha
58
- 1.0.0-alpha.1
59
- 1.0.0-beta.2
60
- 1.0.0-beta.11
61
- 1.0.0-rc.1
62
- 1.0.0-rc.1+20130309074433
63
- 1.0.0
64
- 1.0.0+20121009074433
65
- 1.3.7+20131009074433
66
- 1.3.7+20131009104433
67
- 1.3.7+20131009104433.git.2.94a1dde
68
- }}
69
- let(:min){ "1.0.0-alpha" }
70
- let(:max){ "1.3.7+20131009104433.git.2.94a1dde" }
48
+ it_has_behavior 'sortable' do
49
+ let(:unsorted_version_strings) do
50
+ %w(
51
+ 1.0.0-beta.2
52
+ 1.0.0-alpha
53
+ 1.0.0-rc.1+20130309074433
54
+ 1.0.0
55
+ 1.0.0-beta.11
56
+ 1.0.0+20121009074433
57
+ 1.0.0-rc.1
58
+ 1.0.0-alpha.1
59
+ 1.3.7+20131009104433.git.2.94a1dde
60
+ 1.3.7+20131009104433
61
+ 1.3.7+20131009074433
62
+ )
63
+ end
64
+ let(:sorted_version_strings) do
65
+ %w(
66
+ 1.0.0-alpha
67
+ 1.0.0-alpha.1
68
+ 1.0.0-beta.2
69
+ 1.0.0-beta.11
70
+ 1.0.0-rc.1
71
+ 1.0.0-rc.1+20130309074433
72
+ 1.0.0
73
+ 1.0.0+20121009074433
74
+ 1.3.7+20131009074433
75
+ 1.3.7+20131009104433
76
+ 1.3.7+20131009104433.git.2.94a1dde
77
+ )
78
+ end
79
+ let(:min) { '1.0.0-alpha' }
80
+ let(:max) { '1.3.7+20131009104433.git.2.94a1dde' }
71
81
  end # it_has_behavior
72
82
 
73
- it_has_behavior "filterable" do
74
- let(:unsorted_version_strings){%w{
75
- 1.0.0-beta.2
76
- 1.0.0-alpha
77
- 1.0.0-rc.1+20130309074433
78
- 1.0.0
79
- 1.0.0-beta.11
80
- 1.0.0+20121009074433
81
- 1.0.0-rc.1
82
- 1.0.0-alpha.1
83
- 1.3.7+20131009104433.git.2.94a1dde
84
- 1.3.7+20131009104433
85
- 1.3.7+20131009074433
86
- }}
87
- let(:release_versions){%w{ 1.0.0 }}
88
- let(:prerelease_versions){%w{
89
- 1.0.0-beta.2
90
- 1.0.0-alpha
91
- 1.0.0-beta.11
92
- 1.0.0-rc.1
93
- 1.0.0-alpha.1
94
- }}
95
- let(:build_versions){%w{
96
- 1.0.0-rc.1+20130309074433
97
- 1.0.0+20121009074433
98
- 1.3.7+20131009104433.git.2.94a1dde
99
- 1.3.7+20131009104433
100
- 1.3.7+20131009074433
101
- }}
102
- let(:release_build_versions){%w{
103
- 1.0.0+20121009074433
104
- 1.3.7+20131009104433.git.2.94a1dde
105
- 1.3.7+20131009104433
106
- 1.3.7+20131009074433
107
- }}
108
- let(:prerelease_build_versions){%w{
109
- 1.0.0-rc.1+20130309074433
110
- }}
83
+ it_has_behavior 'filterable' do
84
+ let(:unsorted_version_strings) do
85
+ %w(
86
+ 1.0.0-beta.2
87
+ 1.0.0-alpha
88
+ 1.0.0-rc.1+20130309074433
89
+ 1.0.0
90
+ 1.0.0-beta.11
91
+ 1.0.0+20121009074433
92
+ 1.0.0-rc.1
93
+ 1.0.0-alpha.1
94
+ 1.3.7+20131009104433.git.2.94a1dde
95
+ 1.3.7+20131009104433
96
+ 1.3.7+20131009074433
97
+ )
98
+ end
99
+ let(:release_versions) { %w(1.0.0) }
100
+ let(:prerelease_versions) do
101
+ %w(
102
+ 1.0.0-beta.2
103
+ 1.0.0-alpha
104
+ 1.0.0-beta.11
105
+ 1.0.0-rc.1
106
+ 1.0.0-alpha.1
107
+ )
108
+ end
109
+ let(:build_versions) do
110
+ %w(
111
+ 1.0.0-rc.1+20130309074433
112
+ 1.0.0+20121009074433
113
+ 1.3.7+20131009104433.git.2.94a1dde
114
+ 1.3.7+20131009104433
115
+ 1.3.7+20131009074433
116
+ )
117
+ end
118
+ let(:release_build_versions) do
119
+ %w(
120
+ 1.0.0+20121009074433
121
+ 1.3.7+20131009104433.git.2.94a1dde
122
+ 1.3.7+20131009104433
123
+ 1.3.7+20131009074433
124
+ )
125
+ end
126
+ let(:prerelease_build_versions) do
127
+ %w(
128
+ 1.0.0-rc.1+20130309074433 )
129
+ end
111
130
  end # it_has_behavior
112
131
 
132
+ it_has_behavior 'comparable', [
133
+ '0.1.0', '0.2.0',
134
+ '1.0.0-alpha.1', '1.0.0',
135
+ '1.2.3', '1.2.3+20121009074433',
136
+ '2.0.0-beta.1', '2.0.0+20131009104433.git.2.94a1dde'
137
+ ]
113
138
  end # describe
@@ -1,5 +1,5 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
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
  #
@@ -19,124 +19,139 @@
19
19
  require 'spec_helper'
20
20
 
21
21
  describe Mixlib::Versioning::Format::Rubygems do
22
+ subject { described_class.new(version_string) }
22
23
 
23
- subject{ described_class.new(version_string) }
24
+ it_should_behave_like 'Basic SemVer'
24
25
 
25
- it_should_behave_like "Basic SemVer"
26
-
27
- it_has_behavior "parses valid version strings", {
28
- "10.1.1" => {
29
- :major => 10,
30
- :minor => 1,
31
- :patch => 1,
32
- :prerelease => nil,
33
- :build => nil,
34
- :release? => true,
35
- :prerelease? => false,
36
- :build? => false,
37
- :release_build? => false,
38
- :prerelease_build? => false,
39
- :iteration => 0
26
+ it_has_behavior 'parses valid version strings', {
27
+ '10.1.1' => {
28
+ major: 10,
29
+ minor: 1,
30
+ patch: 1,
31
+ prerelease: nil,
32
+ build: nil,
33
+ release?: true,
34
+ prerelease?: false,
35
+ build?: false,
36
+ release_build?: false,
37
+ prerelease_build?: false,
38
+ iteration: 0,
39
+ },
40
+ '10.1.1.alpha.1' => {
41
+ major: 10,
42
+ minor: 1,
43
+ patch: 1,
44
+ prerelease: 'alpha.1',
45
+ build: nil,
46
+ release?: false,
47
+ prerelease?: true,
48
+ build?: false,
49
+ release_build?: false,
50
+ prerelease_build?: false,
51
+ iteration: 0,
40
52
  },
41
- "10.1.1.alpha.1" => {
42
- :major => 10,
43
- :minor => 1,
44
- :patch => 1,
45
- :prerelease => "alpha.1",
46
- :build => nil,
47
- :release? => false,
48
- :prerelease? => true,
49
- :build? => false,
50
- :release_build? => false,
51
- :prerelease_build? => false,
52
- :iteration => 0
53
+ '11.0.8.rc.3' => {
54
+ major: 11,
55
+ minor: 0,
56
+ patch: 8,
57
+ prerelease: 'rc.3',
58
+ build: nil,
59
+ release?: false,
60
+ prerelease?: true,
61
+ build?: false,
62
+ release_build?: false,
63
+ prerelease_build?: false,
64
+ iteration: 0,
53
65
  },
54
- "11.0.8.rc.3" => {
55
- :major => 11,
56
- :minor => 0,
57
- :patch => 8,
58
- :prerelease => "rc.3",
59
- :build => nil,
60
- :release? => false,
61
- :prerelease? => true,
62
- :build? => false,
63
- :release_build? => false,
64
- :prerelease_build? => false,
65
- :iteration => 0
66
+ '11.0.8-33' => {
67
+ major: 11,
68
+ minor: 0,
69
+ patch: 8,
70
+ prerelease: nil,
71
+ build: nil,
72
+ release?: true,
73
+ prerelease?: false,
74
+ build?: false,
75
+ release_build?: false,
76
+ prerelease_build?: false,
77
+ iteration: 33,
66
78
  },
67
- "11.0.8-33" => {
68
- :major => 11,
69
- :minor => 0,
70
- :patch => 8,
71
- :prerelease => nil,
72
- :build => nil,
73
- :release? => true,
74
- :prerelease? => false,
75
- :build? => false,
76
- :release_build? => false,
77
- :prerelease_build? => false,
78
- :iteration => 33
79
+ '11.0.8.rc.3-1' => {
80
+ major: 11,
81
+ minor: 0,
82
+ patch: 8,
83
+ prerelease: 'rc.3',
84
+ build: nil,
85
+ release?: false,
86
+ prerelease?: true,
87
+ build?: false,
88
+ release_build?: false,
89
+ prerelease_build?: false,
90
+ iteration: 1,
79
91
  },
80
- "11.0.8.rc.3-1" => {
81
- :major => 11,
82
- :minor => 0,
83
- :patch => 8,
84
- :prerelease => "rc.3",
85
- :build => nil,
86
- :release? => false,
87
- :prerelease? => true,
88
- :build? => false,
89
- :release_build? => false,
90
- :prerelease_build? => false,
91
- :iteration => 1
92
- }
93
92
  }
94
93
 
95
- it_has_behavior "rejects invalid version strings", {
96
- "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',
97
96
  }
98
97
 
99
- it_has_behavior "serializable", [
100
- "1.0.0",
101
- "1.0.0.alpha.1",
102
- "1.0.0.beta"
98
+ it_has_behavior 'serializable', [
99
+ '1.0.0',
100
+ '1.0.0.alpha.1',
101
+ '1.0.0.beta',
103
102
  ]
104
103
 
105
- it_has_behavior "sortable" do
106
- let(:unsorted_version_strings){%w{
107
- 1.0.0.beta.2
108
- 1.3.7.alpha.0
109
- 1.0.0.alpha
110
- 1.0.0.rc.1
111
- 1.0.0
112
- }}
113
- let(:sorted_version_strings){%w{
114
- 1.0.0.alpha
115
- 1.0.0.beta.2
116
- 1.0.0.rc.1
117
- 1.0.0
118
- 1.3.7.alpha.0
119
- }}
120
- let(:min){ "1.0.0.alpha" }
121
- let(:max){ "1.3.7.alpha.0" }
104
+ it_has_behavior 'sortable' do
105
+ let(:unsorted_version_strings) do
106
+ %w(
107
+ 1.0.0.beta.2
108
+ 1.3.7.alpha.0
109
+ 1.0.0.alpha
110
+ 1.0.0.rc.1
111
+ 1.0.0
112
+ )
113
+ end
114
+ let(:sorted_version_strings) do
115
+ %w(
116
+ 1.0.0.alpha
117
+ 1.0.0.beta.2
118
+ 1.0.0.rc.1
119
+ 1.0.0
120
+ 1.3.7.alpha.0
121
+ )
122
+ end
123
+ let(:min) { '1.0.0.alpha' }
124
+ let(:max) { '1.3.7.alpha.0' }
122
125
  end
123
126
 
124
127
  # The +Rubygems+ format only produces release and prerelease versions.
125
- it_has_behavior "filterable" do
126
- let(:unsorted_version_strings){%w{
127
- 1.0.0.beta.2
128
- 1.3.7.alpha.0
129
- 1.0.0.alpha
130
- 1.0.0.rc.1
131
- 1.0.0
132
- }}
133
- let(:release_versions){%w{ 1.0.0 }}
134
- let(:prerelease_versions){%w{
135
- 1.0.0.beta.2
136
- 1.3.7.alpha.0
137
- 1.0.0.alpha
138
- 1.0.0.rc.1
139
- }}
128
+ it_has_behavior 'filterable' do
129
+ let(:unsorted_version_strings) do
130
+ %w(
131
+ 1.0.0.beta.2
132
+ 1.3.7.alpha.0
133
+ 1.0.0.alpha
134
+ 1.0.0.rc.1
135
+ 1.0.0
136
+ )
137
+ end
138
+ let(:release_versions) { %w(1.0.0) }
139
+ let(:prerelease_versions) do
140
+ %w(
141
+ 1.0.0.beta.2
142
+ 1.3.7.alpha.0
143
+ 1.0.0.alpha
144
+ 1.0.0.rc.1
145
+ )
146
+ end
140
147
  end
141
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'
156
+ ]
142
157
  end