versionomy 0.0.1
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.
- data/History.txt +3 -0
- data/Manifest.txt +16 -0
- data/README.txt +134 -0
- data/Rakefile +49 -0
- data/lib/versionomy/errors.rb +107 -0
- data/lib/versionomy/format.rb +132 -0
- data/lib/versionomy/schema.rb +537 -0
- data/lib/versionomy/standard.rb +385 -0
- data/lib/versionomy/value.rb +291 -0
- data/lib/versionomy/version.rb +49 -0
- data/lib/versionomy.rb +46 -0
- data/tests/tc_standard_basic.rb +146 -0
- data/tests/tc_standard_bump.rb +170 -0
- data/tests/tc_standard_change.rb +97 -0
- data/tests/tc_standard_comparison.rb +77 -0
- data/tests/tc_standard_parse.rb +162 -0
- metadata +95 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Versionomy version
|
4
|
+
#
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# Copyright 2008 Daniel Azuma
|
7
|
+
#
|
8
|
+
# All rights reserved.
|
9
|
+
#
|
10
|
+
# Redistribution and use in source and binary forms, with or without
|
11
|
+
# modification, are permitted provided that the following conditions are met:
|
12
|
+
#
|
13
|
+
# * Redistributions of source code must retain the above copyright notice,
|
14
|
+
# this list of conditions and the following disclaimer.
|
15
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer in the documentation
|
17
|
+
# and/or other materials provided with the distribution.
|
18
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
+
# contributors to this software, may be used to endorse or promote products
|
20
|
+
# derived from this software without specific prior written permission.
|
21
|
+
#
|
22
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
# -----------------------------------------------------------------------------
|
34
|
+
;
|
35
|
+
|
36
|
+
|
37
|
+
module Versionomy
|
38
|
+
|
39
|
+
VERSION_STRING = '0.0.1'
|
40
|
+
VERSION = parse(VERSION_STRING)
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
module Blockenspiel # :nodoc:
|
46
|
+
|
47
|
+
VERSION = Versionomy.parse(VERSION_STRING)
|
48
|
+
|
49
|
+
end
|
data/lib/versionomy.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Versionomy entry point
|
4
|
+
#
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# Copyright 2008 Daniel Azuma
|
7
|
+
#
|
8
|
+
# All rights reserved.
|
9
|
+
#
|
10
|
+
# Redistribution and use in source and binary forms, with or without
|
11
|
+
# modification, are permitted provided that the following conditions are met:
|
12
|
+
#
|
13
|
+
# * Redistributions of source code must retain the above copyright notice,
|
14
|
+
# this list of conditions and the following disclaimer.
|
15
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer in the documentation
|
17
|
+
# and/or other materials provided with the distribution.
|
18
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
+
# contributors to this software, may be used to endorse or promote products
|
20
|
+
# derived from this software without specific prior written permission.
|
21
|
+
#
|
22
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
# -----------------------------------------------------------------------------
|
34
|
+
;
|
35
|
+
|
36
|
+
|
37
|
+
require 'rubygems'
|
38
|
+
require 'blockenspiel'
|
39
|
+
|
40
|
+
require File.expand_path("#{File.dirname(__FILE__)}/versionomy/errors.rb")
|
41
|
+
require File.expand_path("#{File.dirname(__FILE__)}/versionomy/schema.rb")
|
42
|
+
require File.expand_path("#{File.dirname(__FILE__)}/versionomy/value.rb")
|
43
|
+
require File.expand_path("#{File.dirname(__FILE__)}/versionomy/format.rb")
|
44
|
+
require File.expand_path("#{File.dirname(__FILE__)}/versionomy/standard.rb")
|
45
|
+
require File.expand_path("#{File.dirname(__FILE__)}/versionomy/interface.rb")
|
46
|
+
require File.expand_path("#{File.dirname(__FILE__)}/versionomy/version.rb")
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Versionomy basic tests on standard schema
|
4
|
+
#
|
5
|
+
# This file contains tests for the basic use cases on the standard schema
|
6
|
+
#
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
# Copyright 2008 Daniel Azuma
|
9
|
+
#
|
10
|
+
# All rights reserved.
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
|
+
#
|
15
|
+
# * Redistributions of source code must retain the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer.
|
17
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
18
|
+
# this list of conditions and the following disclaimer in the documentation
|
19
|
+
# and/or other materials provided with the distribution.
|
20
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
21
|
+
# contributors to this software, may be used to endorse or promote products
|
22
|
+
# derived from this software without specific prior written permission.
|
23
|
+
#
|
24
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
27
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
28
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
29
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
30
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
31
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
32
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
33
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
34
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
# -----------------------------------------------------------------------------
|
36
|
+
|
37
|
+
|
38
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../lib/versionomy.rb")
|
39
|
+
|
40
|
+
|
41
|
+
module Versionomy
|
42
|
+
module Tests # :nodoc:
|
43
|
+
|
44
|
+
class TestStandardBasic < Test::Unit::TestCase # :nodoc:
|
45
|
+
|
46
|
+
|
47
|
+
# Test the default version value.
|
48
|
+
|
49
|
+
def test_default_value
|
50
|
+
value_ = Versionomy.create
|
51
|
+
assert_equal(1, value_.major)
|
52
|
+
assert_equal(0, value_.minor)
|
53
|
+
assert_equal(0, value_.tiny)
|
54
|
+
assert_equal(0, value_.tiny2)
|
55
|
+
assert_equal(:release, value_.release_type)
|
56
|
+
assert_equal(0, value_.patchlevel)
|
57
|
+
assert_equal(0, value_.patchlevel_minor)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Test an arbitrary release value.
|
62
|
+
|
63
|
+
def test_release_value_1
|
64
|
+
value_ = Versionomy.create(:major => 1, :tiny => 4, :tiny2 => 2, :patchlevel => 5)
|
65
|
+
assert_equal(1, value_.major)
|
66
|
+
assert_equal(0, value_.minor)
|
67
|
+
assert_equal(4, value_.tiny)
|
68
|
+
assert_equal(2, value_.tiny2)
|
69
|
+
assert_equal(:release, value_.release_type)
|
70
|
+
assert_equal(5, value_.patchlevel)
|
71
|
+
assert_equal(0, value_.patchlevel_minor)
|
72
|
+
assert_equal(false, value_.has_field?(:prerelase_version))
|
73
|
+
assert_equal(false, value_.has_field?(:prerelase_minor))
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# Test an arbitrary release value.
|
78
|
+
|
79
|
+
def test_release_value_2
|
80
|
+
value_ = Versionomy.create(:major => 0, :minor => 3)
|
81
|
+
assert_equal(0, value_.major)
|
82
|
+
assert_equal(3, value_.minor)
|
83
|
+
assert_equal(0, value_.tiny)
|
84
|
+
assert_equal(0, value_.tiny2)
|
85
|
+
assert_equal(:release, value_.release_type)
|
86
|
+
assert_equal(0, value_.patchlevel)
|
87
|
+
assert_equal(0, value_.patchlevel_minor)
|
88
|
+
assert_equal(false, value_.has_field?(:prerelase_version))
|
89
|
+
assert_equal(false, value_.has_field?(:prerelase_minor))
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
# Test an arbitrary prerelease value.
|
94
|
+
|
95
|
+
def test_prerelease_value_1
|
96
|
+
value_ = Versionomy.create(:major => 2, :minor => 3, :release_type => :prerelease, :prerelease_version => 3)
|
97
|
+
assert_equal(2, value_.major)
|
98
|
+
assert_equal(3, value_.minor)
|
99
|
+
assert_equal(0, value_.tiny)
|
100
|
+
assert_equal(0, value_.tiny2)
|
101
|
+
assert_equal(:prerelease, value_.release_type)
|
102
|
+
assert_equal(3, value_.prerelease_version)
|
103
|
+
assert_equal(0, value_.prerelease_minor)
|
104
|
+
assert_equal(false, value_.has_field?(:patchlevel))
|
105
|
+
assert_equal(false, value_.has_field?(:patchlevel_minor))
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
# Test an arbitrary prerelease value.
|
110
|
+
|
111
|
+
def test_prerelease_value_2
|
112
|
+
value_ = Versionomy.create(:major => 2, :minor => 3, :release_type => :prerelease)
|
113
|
+
assert_equal(2, value_.major)
|
114
|
+
assert_equal(3, value_.minor)
|
115
|
+
assert_equal(0, value_.tiny)
|
116
|
+
assert_equal(0, value_.tiny2)
|
117
|
+
assert_equal(:prerelease, value_.release_type)
|
118
|
+
assert_equal(1, value_.prerelease_version)
|
119
|
+
assert_equal(0, value_.prerelease_minor)
|
120
|
+
assert_equal(false, value_.has_field?(:patchlevel))
|
121
|
+
assert_equal(false, value_.has_field?(:patchlevel_minor))
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
# Test an arbitrary beta value.
|
126
|
+
|
127
|
+
def test_beta_value
|
128
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
|
129
|
+
assert_equal(2, value_.major)
|
130
|
+
assert_equal(0, value_.minor)
|
131
|
+
assert_equal(1, value_.tiny)
|
132
|
+
assert_equal(0, value_.tiny2)
|
133
|
+
assert_equal(:beta, value_.release_type)
|
134
|
+
assert_equal(3, value_.beta_version)
|
135
|
+
assert_equal(0, value_.beta_minor)
|
136
|
+
assert_equal(false, value_.has_field?(:prerelase_version))
|
137
|
+
assert_equal(false, value_.has_field?(:prerelase_minor))
|
138
|
+
assert_equal(false, value_.has_field?(:patchlevel))
|
139
|
+
assert_equal(false, value_.has_field?(:patchlevel_minor))
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Versionomy bump tests on standard schema
|
4
|
+
#
|
5
|
+
# This file contains tests for the bump function on the standard schema
|
6
|
+
#
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
# Copyright 2008 Daniel Azuma
|
9
|
+
#
|
10
|
+
# All rights reserved.
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
|
+
#
|
15
|
+
# * Redistributions of source code must retain the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer.
|
17
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
18
|
+
# this list of conditions and the following disclaimer in the documentation
|
19
|
+
# and/or other materials provided with the distribution.
|
20
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
21
|
+
# contributors to this software, may be used to endorse or promote products
|
22
|
+
# derived from this software without specific prior written permission.
|
23
|
+
#
|
24
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
27
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
28
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
29
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
30
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
31
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
32
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
33
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
34
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
# -----------------------------------------------------------------------------
|
36
|
+
|
37
|
+
|
38
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../lib/versionomy.rb")
|
39
|
+
|
40
|
+
|
41
|
+
module Versionomy
|
42
|
+
module Tests # :nodoc:
|
43
|
+
|
44
|
+
class TestStandardBump < Test::Unit::TestCase # :nodoc:
|
45
|
+
|
46
|
+
|
47
|
+
# Test bumping a minor patchlevel.
|
48
|
+
|
49
|
+
def test_bump_patchlevel_minor
|
50
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :patchlevel => 3, :patchlevel_minor => 0)
|
51
|
+
value_ = value_.bump(:patchlevel_minor)
|
52
|
+
assert_equal(2, value_.major)
|
53
|
+
assert_equal(0, value_.minor)
|
54
|
+
assert_equal(1, value_.tiny)
|
55
|
+
assert_equal(0, value_.tiny2)
|
56
|
+
assert_equal(:release, value_.release_type)
|
57
|
+
assert_equal(3, value_.patchlevel)
|
58
|
+
assert_equal(1, value_.patchlevel_minor)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Test bumping a major patchlevel.
|
63
|
+
|
64
|
+
def test_bump_patchlevel
|
65
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :patchlevel => 3, :patchlevel_minor => 1)
|
66
|
+
value_ = value_.bump(:patchlevel)
|
67
|
+
assert_equal(2, value_.major)
|
68
|
+
assert_equal(0, value_.minor)
|
69
|
+
assert_equal(1, value_.tiny)
|
70
|
+
assert_equal(0, value_.tiny2)
|
71
|
+
assert_equal(:release, value_.release_type)
|
72
|
+
assert_equal(4, value_.patchlevel)
|
73
|
+
assert_equal(0, value_.patchlevel_minor)
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# Test bumping release type prerelease.
|
78
|
+
|
79
|
+
def test_bump_prerelease_to_release
|
80
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :prerelease)
|
81
|
+
value_ = value_.bump(:release_type)
|
82
|
+
assert_equal(2, value_.major)
|
83
|
+
assert_equal(0, value_.minor)
|
84
|
+
assert_equal(1, value_.tiny)
|
85
|
+
assert_equal(0, value_.tiny2)
|
86
|
+
assert_equal(:release, value_.release_type)
|
87
|
+
assert_equal(0, value_.patchlevel)
|
88
|
+
assert_equal(0, value_.patchlevel_minor)
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
# Test bumping release type development.
|
93
|
+
|
94
|
+
def test_bump_development_to_alpha
|
95
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :development, :development_version => 7)
|
96
|
+
value_ = value_.bump(:release_type)
|
97
|
+
assert_equal(2, value_.major)
|
98
|
+
assert_equal(0, value_.minor)
|
99
|
+
assert_equal(1, value_.tiny)
|
100
|
+
assert_equal(0, value_.tiny2)
|
101
|
+
assert_equal(:alpha, value_.release_type)
|
102
|
+
assert_equal(1, value_.alpha_version)
|
103
|
+
assert_equal(0, value_.alpha_minor)
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
# Test bumping release type alpha.
|
108
|
+
|
109
|
+
def test_bump_alpha_to_beta
|
110
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :alpha)
|
111
|
+
value_ = value_.bump(:release_type)
|
112
|
+
assert_equal(2, value_.major)
|
113
|
+
assert_equal(0, value_.minor)
|
114
|
+
assert_equal(1, value_.tiny)
|
115
|
+
assert_equal(0, value_.tiny2)
|
116
|
+
assert_equal(:beta, value_.release_type)
|
117
|
+
assert_equal(1, value_.beta_version)
|
118
|
+
assert_equal(0, value_.beta_minor)
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
# Test bumping release type release_candidate.
|
123
|
+
|
124
|
+
def test_bump_release_candidate_to_release
|
125
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :release_candidate, :release_candidate_version => 2)
|
126
|
+
value_ = value_.bump(:release_type)
|
127
|
+
assert_equal(2, value_.major)
|
128
|
+
assert_equal(0, value_.minor)
|
129
|
+
assert_equal(1, value_.tiny)
|
130
|
+
assert_equal(0, value_.tiny2)
|
131
|
+
assert_equal(:release, value_.release_type)
|
132
|
+
assert_equal(0, value_.patchlevel)
|
133
|
+
assert_equal(0, value_.patchlevel_minor)
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
# Test bumping tiny.
|
138
|
+
|
139
|
+
def test_bump_tiny
|
140
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
141
|
+
value_ = value_.bump(:tiny)
|
142
|
+
assert_equal(2, value_.major)
|
143
|
+
assert_equal(0, value_.minor)
|
144
|
+
assert_equal(2, value_.tiny)
|
145
|
+
assert_equal(0, value_.tiny2)
|
146
|
+
assert_equal(:release, value_.release_type)
|
147
|
+
assert_equal(0, value_.patchlevel)
|
148
|
+
assert_equal(0, value_.patchlevel_minor)
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
# Test bumping major.
|
153
|
+
|
154
|
+
def test_bump_major
|
155
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
156
|
+
value_ = value_.bump(:major)
|
157
|
+
assert_equal(3, value_.major)
|
158
|
+
assert_equal(0, value_.minor)
|
159
|
+
assert_equal(0, value_.tiny)
|
160
|
+
assert_equal(0, value_.tiny2)
|
161
|
+
assert_equal(:release, value_.release_type)
|
162
|
+
assert_equal(0, value_.patchlevel)
|
163
|
+
assert_equal(0, value_.patchlevel_minor)
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Versionomy change tests on standard schema
|
4
|
+
#
|
5
|
+
# This file contains tests for the change function on the standard schema
|
6
|
+
#
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
# Copyright 2008 Daniel Azuma
|
9
|
+
#
|
10
|
+
# All rights reserved.
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
|
+
#
|
15
|
+
# * Redistributions of source code must retain the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer.
|
17
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
18
|
+
# this list of conditions and the following disclaimer in the documentation
|
19
|
+
# and/or other materials provided with the distribution.
|
20
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
21
|
+
# contributors to this software, may be used to endorse or promote products
|
22
|
+
# derived from this software without specific prior written permission.
|
23
|
+
#
|
24
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
27
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
28
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
29
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
30
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
31
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
32
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
33
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
34
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
# -----------------------------------------------------------------------------
|
36
|
+
|
37
|
+
|
38
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../lib/versionomy.rb")
|
39
|
+
|
40
|
+
|
41
|
+
module Versionomy
|
42
|
+
module Tests # :nodoc:
|
43
|
+
|
44
|
+
class TestStandardChange < Test::Unit::TestCase # :nodoc:
|
45
|
+
|
46
|
+
|
47
|
+
# Test with a changed tiny
|
48
|
+
|
49
|
+
def test_change_tiny
|
50
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
51
|
+
value_ = value_.change(:tiny => 4)
|
52
|
+
assert_equal(2, value_.major)
|
53
|
+
assert_equal(0, value_.minor)
|
54
|
+
assert_equal(4, value_.tiny)
|
55
|
+
assert_equal(3, value_.tiny2)
|
56
|
+
assert_equal(:release_candidate, value_.release_type)
|
57
|
+
assert_equal(2, value_.release_candidate_version)
|
58
|
+
assert_equal(0, value_.release_candidate_minor)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Test with several changed fields
|
63
|
+
|
64
|
+
def test_change_several
|
65
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
66
|
+
value_ = value_.change(:tiny => 4, :release_candidate_version => 5)
|
67
|
+
assert_equal(2, value_.major)
|
68
|
+
assert_equal(0, value_.minor)
|
69
|
+
assert_equal(4, value_.tiny)
|
70
|
+
assert_equal(3, value_.tiny2)
|
71
|
+
assert_equal(:release_candidate, value_.release_type)
|
72
|
+
assert_equal(5, value_.release_candidate_version)
|
73
|
+
assert_equal(0, value_.release_candidate_minor)
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# Test with a changed release type
|
78
|
+
|
79
|
+
def test_change_release_type
|
80
|
+
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
81
|
+
value_ = value_.change(:release_type => :beta)
|
82
|
+
assert_equal(2, value_.major)
|
83
|
+
assert_equal(0, value_.minor)
|
84
|
+
assert_equal(1, value_.tiny)
|
85
|
+
assert_equal(3, value_.tiny2)
|
86
|
+
assert_equal(:beta, value_.release_type)
|
87
|
+
assert_equal(1, value_.beta_version)
|
88
|
+
assert_equal(0, value_.beta_minor)
|
89
|
+
assert_equal(false, value_.has_field?(:release_candidate_version))
|
90
|
+
assert_equal(false, value_.has_field?(:release_candidate_minor))
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Versionomy comparison tests on standard schema
|
4
|
+
#
|
5
|
+
# This file contains tests for comparisons on the standard schema
|
6
|
+
#
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
# Copyright 2008 Daniel Azuma
|
9
|
+
#
|
10
|
+
# All rights reserved.
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
|
+
#
|
15
|
+
# * Redistributions of source code must retain the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer.
|
17
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
18
|
+
# this list of conditions and the following disclaimer in the documentation
|
19
|
+
# and/or other materials provided with the distribution.
|
20
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
21
|
+
# contributors to this software, may be used to endorse or promote products
|
22
|
+
# derived from this software without specific prior written permission.
|
23
|
+
#
|
24
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
27
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
28
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
29
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
30
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
31
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
32
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
33
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
34
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
# -----------------------------------------------------------------------------
|
36
|
+
|
37
|
+
|
38
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../lib/versionomy.rb")
|
39
|
+
|
40
|
+
|
41
|
+
module Versionomy
|
42
|
+
module Tests # :nodoc:
|
43
|
+
|
44
|
+
class TestStandardComparison < Test::Unit::TestCase # :nodoc:
|
45
|
+
|
46
|
+
|
47
|
+
# Test comparisons with difference in major.
|
48
|
+
|
49
|
+
def test_comparison_major
|
50
|
+
value1_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
51
|
+
value2_ = Versionomy.create(:major => 3, :release_type => :alpha)
|
52
|
+
assert(value2_ > value1_)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
# Test comparisons with difference in minor.
|
57
|
+
|
58
|
+
def test_comparison_minor
|
59
|
+
value1_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
60
|
+
value2_ = Versionomy.create(:major => 2, :minor => 1, :release_type => :alpha)
|
61
|
+
assert(value2_ > value1_)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# Test comparisons with difference in release type.
|
66
|
+
|
67
|
+
def test_comparison_release_type
|
68
|
+
value1_ = Versionomy.create(:major => 2, :release_type => :alpha, :alpha_version => 5)
|
69
|
+
value2_ = Versionomy.create(:major => 2, :release_type => :release_candidate, :release_candidate_version => 2)
|
70
|
+
assert(value2_ > value1_)
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|