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.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/lib/mixlib/versioning.rb +41 -37
  3. data/lib/mixlib/versioning/exceptions.rb +2 -2
  4. data/lib/mixlib/versioning/format.rb +42 -38
  5. data/lib/mixlib/versioning/format/git_describe.rb +5 -7
  6. data/lib/mixlib/versioning/format/opscode_semver.rb +8 -19
  7. data/lib/mixlib/versioning/format/partial_semver.rb +62 -0
  8. data/lib/mixlib/versioning/format/rubygems.rb +14 -10
  9. data/lib/mixlib/versioning/format/semver.rb +9 -11
  10. data/lib/mixlib/versioning/version.rb +3 -3
  11. metadata +15 -87
  12. data/.gitignore +0 -18
  13. data/.yardopts +0 -7
  14. data/CHANGELOG.md +0 -3
  15. data/CONTRIBUTING.md +0 -188
  16. data/Gemfile +0 -9
  17. data/README.md +0 -364
  18. data/Rakefile +0 -6
  19. data/mixlib-versioning.gemspec +0 -22
  20. data/spec/mixlib/versioning/format/git_describe_spec.rb +0 -178
  21. data/spec/mixlib/versioning/format/opscode_semver_spec.rb +0 -113
  22. data/spec/mixlib/versioning/format/rubygems_spec.rb +0 -142
  23. data/spec/mixlib/versioning/format/semver_spec.rb +0 -107
  24. data/spec/mixlib/versioning/format_spec.rb +0 -69
  25. data/spec/mixlib/versioning/versioning_spec.rb +0 -259
  26. data/spec/spec_helper.rb +0 -43
  27. data/spec/support/shared_examples/basic_semver.rb +0 -42
  28. data/spec/support/shared_examples/behaviors/filterable.rb +0 -66
  29. data/spec/support/shared_examples/behaviors/parses_valid_version_strings.rb +0 -32
  30. data/spec/support/shared_examples/behaviors/rejects_invalid_version_strings.rb +0 -32
  31. data/spec/support/shared_examples/behaviors/serializable.rb +0 -51
  32. data/spec/support/shared_examples/behaviors/sortable.rb +0 -45
  33. data/spec/support/shared_examples/semver.rb +0 -105
@@ -1,43 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'mixlib/versioning'
20
-
21
- # load all shared examples and shared contexts
22
- Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |file|
23
- require(file)
24
- end
25
-
26
- RSpec.configure do |config|
27
- # a little syntactic sugar
28
- config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
29
-
30
- # Use color in STDOUT
31
- config.color_enabled = true
32
-
33
- # Use color not only in STDOUT but also in pagers and files
34
- config.tty = true
35
-
36
- # run the examples in random order
37
- config.order = :rand
38
-
39
- # specify metadata with symobls only (ie no '=> true' required)
40
- config.treat_symbols_as_metadata_keys_with_true_values = true
41
- config.filter_run :focus => true
42
- config.run_all_when_everything_filtered = true
43
- end
@@ -1,42 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- shared_examples "Basic SemVer" do
20
-
21
- it_has_behavior "parses valid version strings", {
22
- "1.2.3" => {
23
- :major => 1,
24
- :minor => 2,
25
- :patch => 3,
26
- :prerelease => nil,
27
- :build => nil,
28
- :release? => true,
29
- :prerelease? => false,
30
- :build? => false,
31
- :release_build? => false,
32
- :prerelease_build? => false
33
- }
34
- }
35
-
36
- it_has_behavior "rejects invalid version strings", {
37
- "a.1.1" => "non-numeric MAJOR",
38
- "1.a.1" => "non-numeric MINOR",
39
- "1.1.a" => "non-numeric PATCH"
40
- }
41
-
42
- end
@@ -1,66 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- shared_examples "filterable" do
20
-
21
- let(:unsorted_versions) do
22
- unsorted_version_strings.map{ |v| described_class.new(v) }
23
- end
24
-
25
- # this should/will be overriden by calling spec
26
- let(:release_versions){[]}
27
- let(:prerelease_versions){[]}
28
- let(:build_versions){[]}
29
- let(:release_build_versions){[]}
30
- let(:prerelease_build_versions){[]}
31
-
32
- it "filters by release versions only" do
33
- unsorted_versions.select(&:release?).should eq(release_versions.map{|v|
34
- described_class.new(v)
35
- })
36
- end # it
37
-
38
- it "filters by pre-release versions only" do
39
- filtered = unsorted_versions.select(&:prerelease?)
40
- filtered.should eq(prerelease_versions.map{|v|
41
- described_class.new(v)
42
- })
43
- end # it
44
-
45
- it "filters by build versions only" do
46
- filtered = unsorted_versions.select(&:build?)
47
- filtered.should eq(build_versions.map{|v|
48
- described_class.new(v)
49
- })
50
- end # it
51
-
52
- it "filters by release build versions only" do
53
- filtered = unsorted_versions.select(&:release_build?)
54
- filtered.should eq(release_build_versions.map{|v|
55
- described_class.new(v)
56
- })
57
- end # it
58
-
59
- it "filters by pre-release build versions only" do
60
- filtered = unsorted_versions.select(&:prerelease_build?)
61
- filtered.should eq(prerelease_build_versions.map{|v|
62
- described_class.new(v)
63
- })
64
- end # it
65
-
66
- end # shared_examples
@@ -1,32 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- shared_examples "parses valid version strings" do |valid_examples|
20
-
21
- valid_examples.each do |version, options|
22
-
23
- context version do
24
- let(:version_string){ version }
25
-
26
- options.each_pair do |name, value|
27
- its(name){ should eq value}
28
- end
29
-
30
- end # context
31
- end # valid_examples
32
- end # shared_examples
@@ -1,32 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- shared_examples "rejects invalid version strings" do |invalid_examples|
20
-
21
- invalid_examples.each_pair do |version, reason|
22
-
23
- context version do
24
- let(:version_string){ version }
25
-
26
- it "fails because: #{reason}" do
27
- expect { subject }.to raise_error(Mixlib::Versioning::ParseError)
28
- end
29
-
30
- end # context
31
- end # invalid_examples
32
- end # shared_examples
@@ -1,51 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- shared_examples "serializable" do |version_strings|
20
-
21
- describe "#to_s" do
22
- version_strings.each do |v|
23
- it "reconstructs the initial input for #{v}" do
24
- described_class.new(v).to_s.should == v
25
- end # it
26
- end # version_strings
27
- end # describe
28
-
29
- describe "#to_semver_string" do
30
- version_strings.each do |v|
31
- it "generates a semver version string for #{v}" do
32
- subject = described_class.new(v)
33
- string = subject.to_semver_string
34
- semver = Mixlib::Versioning::Format::SemVer.new(string)
35
- string.should eq semver.to_s
36
- end # it
37
- end # version_strings
38
- end # describe
39
-
40
- describe "#to_rubygems_string" do
41
- version_strings.each do |v|
42
- it "generates a rubygems version string for #{v}" do
43
- subject = described_class.new(v)
44
- string = subject.to_rubygems_string
45
- rubygems = Mixlib::Versioning::Format::Rubygems.new(string)
46
- string.should eq rubygems.to_s
47
- end # it
48
- end # version_strings
49
- end # describe
50
-
51
- end # shared_examples
@@ -1,45 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- shared_examples "sortable" do
20
-
21
- let(:unsorted_versions) do
22
- unsorted_version_strings.map{ |v| described_class.new(v) }
23
- end
24
-
25
- let(:sorted_versions) do
26
- sorted_version_strings.map{ |v| described_class.new(v) }
27
- end
28
-
29
- it 'responds to <=>' do
30
- described_class.should respond_to(:<=>)
31
- end
32
-
33
- it "sorts all properly" do
34
- unsorted_versions.sort.should eq sorted_versions
35
- end
36
-
37
- it "finds the min" do
38
- unsorted_versions.min.should eq described_class.new(min)
39
- end
40
-
41
- it "finds the max" do
42
- unsorted_versions.max.should eq described_class.new(max)
43
- end
44
-
45
- end # shared_examples
@@ -1,105 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'mixlib/versioning'
20
-
21
- shared_examples Mixlib::Versioning::Format::SemVer do
22
-
23
- it_should_behave_like "Basic SemVer"
24
-
25
- it_has_behavior "parses valid version strings", {
26
- "1.0.0-alpha.1" => {
27
- :major => 1,
28
- :minor => 0,
29
- :patch => 0,
30
- :prerelease => "alpha.1",
31
- :build => nil,
32
- :release? => false,
33
- :prerelease? => true,
34
- :build? => false,
35
- :release_build? => false,
36
- :prerelease_build? => false
37
- },
38
- "1.0.0+20130308110833" => {
39
- :major => 1,
40
- :minor => 0,
41
- :patch => 0,
42
- :prerelease => nil,
43
- :build => "20130308110833",
44
- :release? => false,
45
- :prerelease? => false,
46
- :build? => true,
47
- :release_build? => true,
48
- :prerelease_build? => false
49
- },
50
- "1.0.0-beta.3+20130308110833" => {
51
- :major => 1,
52
- :minor => 0,
53
- :patch => 0,
54
- :prerelease => "beta.3",
55
- :build => "20130308110833",
56
- :release? => false,
57
- :prerelease? => false,
58
- :build? => true,
59
- :release_build? => false,
60
- :prerelease_build? => true
61
- }
62
- }
63
-
64
- it_has_behavior "rejects invalid version strings", {
65
- "8.8.8.8" => "too many segments: MAJOR.MINOR.PATCH.EXTRA"
66
- }
67
-
68
- describe "build qualification" do
69
- context "release version" do
70
- let(:version_string){"1.0.0"}
71
- its(:release?){ should be_true }
72
- its(:prerelease?){ should be_false }
73
- its(:build?){ should be_false }
74
- its(:release_build?){ should be_false }
75
- its(:prerelease_build?){ should be_false }
76
- end
77
-
78
- context "pre-release version" do
79
- let(:version_string){"1.0.0-alpha.1"}
80
- its(:release?){ should be_false }
81
- its(:prerelease?){ should be_true }
82
- its(:build?){ should be_false }
83
- its(:release_build?){ should be_false }
84
- its(:prerelease_build?){ should be_false }
85
- end
86
-
87
- context "pre-release build version" do
88
- let(:version_string){"1.0.0-alpha.1+20130308110833"}
89
- its(:release?){ should be_false }
90
- its(:prerelease?){ should be_false }
91
- its(:build?){ should be_true }
92
- its(:release_build?){ should be_false }
93
- its(:prerelease_build?){ should be_true }
94
- end
95
-
96
- context "release build version" do
97
- let(:version_string){"1.0.0+20130308110833"}
98
- its(:release?){ should be_false }
99
- its(:prerelease?){ should be_false }
100
- its(:build?){ should be_true }
101
- its(:release_build?){ should be_true }
102
- its(:prerelease_build?){ should be_false }
103
- end
104
- end
105
- end