app_version 0.1.7 → 0.2.8
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/README.md +11 -6
- data/Rakefile +1 -0
- data/lib/app_version/app_version.rb +82 -37
- data/lib/app_version/railtie.rb +8 -2
- data/lib/app_version/templates/version.yml +1 -0
- data/lib/app_version/templates/version.yml.erb +1 -0
- data/lib/app_version/version.rb +3 -0
- data/lib/app_version.rb +1 -0
- data/test/app_version_test.rb +86 -29
- data/test/test_helper.rb +7 -0
- data/test/version.yml +1 -0
- metadata +25 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e278cd0e97562bf190ea867c15dd11e1d949378315c15a7a39a2ca54891d66a5
|
4
|
+
data.tar.gz: 8027d10a7f08738916becd53305b1cc7cee04d33850b7d2b05fc85552a560e29
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa361fd6d1e55257264123a51427486c7173eb20eae6d3fed907e6cf2419b98653cf78d227cd03a88ed41f0fc18b07113b76ffd6cffa3aae2a5bede7850b753b
|
7
|
+
data.tar.gz: 4cd09a190b8ff1569e1ffc836931c83fde49b5f5233a829601a8942c90b65ee46897ca413aef26bedcf6c3b73d44335506506322f77dd5dc6876c71e0d25752d
|
data/README.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
## App Version
|
2
2
|
|
3
|
-
[](https://circleci.com/gh/mort666/app_version)
|
4
4
|
|
5
|
-
This is a simple plugin that makes it easy to manage the version number of your Rails application. The version numbers supported by this plugin look like '2.0.1 M4 (600) of branch by coder on 2008-10-27'.
|
5
|
+
This is a simple plugin that makes it easy to manage the version number of your Rails application. The version numbers supported by this plugin look like '2.0.0-rc.1 M4 (600) of branch by coder on 2008-10-27'.
|
6
6
|
|
7
7
|
The components of the version number are:
|
8
8
|
|
9
9
|
2 => major
|
10
10
|
0 => minor
|
11
|
-
|
11
|
+
0 => patch
|
12
|
+
rc.1 => meta information (as defined by Semantic Versioning)
|
12
13
|
M4 => milestone
|
13
14
|
(600) => build number (usually Subversion revision)
|
14
15
|
branch => the name of the branch this version is from.
|
@@ -34,7 +35,7 @@ To include the version information into your running application create an initi
|
|
34
35
|
This will load a constant called APP_VERSION That includes the version information. This can then be rendered within the application using
|
35
36
|
|
36
37
|
APP_VERSION.to_s
|
37
|
-
|
38
|
+
|
38
39
|
Use this within your application view or helper methods, more detail on other version meta data in the usage section.
|
39
40
|
|
40
41
|
### Usage
|
@@ -45,6 +46,7 @@ following format:
|
|
45
46
|
major: 2
|
46
47
|
minor: 0
|
47
48
|
patch: 1
|
49
|
+
meta: rc.1
|
48
50
|
milestone: 4
|
49
51
|
build: git-revcount
|
50
52
|
branch: master
|
@@ -57,9 +59,12 @@ If you use the special string it will query the source control system and output
|
|
57
59
|
|
58
60
|
Using 'svn' for the build number will cause the plugin to query Subversion for the current revision number. Since Git doesn't have a numbered revision we have to fake it. 'git-revcount' will count the number of commits to the repository and use that as the build number whereas 'git-hash' will use the first 6 digits of the current HEAD's hash.
|
59
61
|
|
60
|
-
The plugin creates a constant `APP_VERSION` that contains the version number of the application. Calling the `to_s` method on APP_VERSION will result in a properly formatted version number.
|
62
|
+
The plugin creates a constant `APP_VERSION` that contains the version number of the application. Calling the `to_s` method on APP_VERSION will result in a properly formatted version number.
|
63
|
+
|
64
|
+
APP_VERSION also has `major`, `minor`, `patch`, `meta`, `milestone`, `build`,`branch`, `committer`, and `build_date` methods to retrieve the individual components of the version number.
|
65
|
+
|
66
|
+
There is a default format and a "semantic versioning" format to use. The semantic versioning format follows: http://semver.org/ as guidelines.
|
61
67
|
|
62
|
-
APP_VERSION also has `major`, `minor`, `patch`, `milestone`, `build`, `branch`, `committer`, and `build_date` methods to retrieve the individual components of the version number.
|
63
68
|
|
64
69
|
### Capistrano Usage
|
65
70
|
|
data/Rakefile
CHANGED
@@ -1,34 +1,54 @@
|
|
1
|
-
require 'active_support/core_ext/object'
|
1
|
+
require 'active_support/core_ext/object'
|
2
2
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
+
#
|
6
|
+
# App::Version Namespace
|
7
|
+
#
|
5
8
|
module App
|
9
|
+
#
|
10
|
+
# Application Version main class
|
11
|
+
#
|
12
|
+
# @attr [String] major Major Version number
|
13
|
+
# @attr [String] minor Minor Version number
|
14
|
+
# @attr [String] patch Patch number
|
15
|
+
# @attr [String] milestone Milestone information
|
16
|
+
# @attr [String] build Build number
|
17
|
+
# @attr [String] branch Git Branch information
|
18
|
+
# @attr [String] meta Semantic version meta info
|
19
|
+
# @attr [String] commiter Git Commiter information
|
20
|
+
# @attr [String] build_date Build Date
|
21
|
+
# @attr [String] format Format information
|
22
|
+
#
|
6
23
|
class Version
|
7
24
|
include Comparable
|
8
25
|
|
9
|
-
attr_accessor :major, :minor, :patch, :milestone, :build
|
26
|
+
attr_accessor :major, :minor, :patch, :milestone, :build
|
27
|
+
attr_accessor :branch, :meta, :committer, :build_date, :format
|
10
28
|
|
11
|
-
[:major, :minor, :patch, :milestone, :build, :branch, :committer, :format].each do |attr|
|
29
|
+
[:major, :minor, :patch, :milestone, :build, :branch, :committer, :meta, :format].each do |attr|
|
12
30
|
define_method "#{attr}=".to_sym do |value|
|
13
31
|
instance_variable_set("@#{attr}".to_sym, value.blank? ? nil : value.to_s)
|
14
32
|
end
|
15
33
|
end
|
16
34
|
|
35
|
+
|
17
36
|
# Creates a new instance of the Version class using information in the passed
|
18
37
|
# Hash to construct the version number.
|
19
38
|
#
|
20
39
|
# Version.new(:major => 1, :minor => 0) #=> "1.0"
|
21
40
|
def initialize(args = nil)
|
22
41
|
if args && args.is_a?(Hash)
|
23
|
-
args.keys.reject {|key| key.is_a?(Symbol) }.each {|key| args[key.to_sym] = args.delete(key) }
|
42
|
+
args.keys.reject { |key| key.is_a?(Symbol) }.each { |key| args[key.to_sym] = args.delete(key) }
|
24
43
|
|
25
44
|
[:major, :minor].each do |param|
|
26
|
-
|
45
|
+
fail ArgumentError.new("The #{param} parameter is required") if args[param].blank?
|
27
46
|
end
|
28
47
|
|
29
48
|
@major = args[:major].to_s
|
30
49
|
@minor = args[:minor].to_s
|
31
50
|
@patch = args[:patch].to_s unless args[:patch].blank?
|
51
|
+
@meta = args[:meta].to_s unless args[:meta].blank?
|
32
52
|
@milestone = args[:milestone].to_s unless args[:milestone].blank?
|
33
53
|
@build = args[:build].to_s unless args[:build].blank?
|
34
54
|
@branch = args[:branch].to_s unless args[:branch].blank?
|
@@ -37,11 +57,11 @@ module App
|
|
37
57
|
|
38
58
|
unless args[:build_date].blank?
|
39
59
|
b_date = case args[:build_date]
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
60
|
+
when 'git-revdate'
|
61
|
+
get_revdate_from_git
|
62
|
+
else
|
63
|
+
args[:build_date].to_s
|
64
|
+
end
|
45
65
|
@build_date = Date.parse(b_date)
|
46
66
|
end
|
47
67
|
|
@@ -61,54 +81,81 @@ module App
|
|
61
81
|
end
|
62
82
|
|
63
83
|
# Parses a version string to create an instance of the Version class.
|
84
|
+
#
|
85
|
+
# @param version [String] Version Number String to parse and initialize object with
|
86
|
+
# @raise [ArguementError] In the event string not parsable
|
87
|
+
# @return [App:Version] Returns populated Version object
|
64
88
|
def self.parse(version)
|
65
|
-
m = version.match(/(\d+)\.(\d+)(?:\.(\d+))?(?:\sM(\d+))?(?:\s\((\d+)\))?(?:\sof\s(\w+))?(?:\sby\s(\w+))?(?:\son\s(\S+))?/)
|
89
|
+
m = version.match(/(\d+)\.(\d+)(?:\.(\d+))?(?:-([\w.\d]+))?(?:\sM(\d+))?(?:\s\((\d+)\))?(?:\sof\s(\w+))?(?:\sby\s(\w+))?(?:\son\s(\S+))?/)
|
66
90
|
|
67
|
-
|
91
|
+
fail ArgumentError.new("The version '#{version}' is unparsable") if m.nil?
|
68
92
|
|
69
|
-
version = App::Version.new :
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
93
|
+
version = App::Version.new major: m[1],
|
94
|
+
minor: m[2],
|
95
|
+
patch: m[3],
|
96
|
+
meta: m[4],
|
97
|
+
milestone: m[5],
|
98
|
+
build: m[6],
|
99
|
+
branch: m[7],
|
100
|
+
committer: m[8]
|
76
101
|
|
77
|
-
if
|
78
|
-
date = Date.parse(m[
|
102
|
+
if m[9] && m[9] != ''
|
103
|
+
date = Date.parse(m[9])
|
79
104
|
version.build_date = date
|
80
105
|
end
|
81
106
|
|
82
|
-
|
107
|
+
version
|
83
108
|
end
|
84
109
|
|
85
110
|
# Loads the version information from a YAML file.
|
111
|
+
#
|
112
|
+
# @param path [String] Yaml file name to load
|
86
113
|
def self.load(path)
|
87
|
-
App::Version.new YAML
|
114
|
+
App::Version.new YAML.load(File.open(path))
|
88
115
|
end
|
89
116
|
|
117
|
+
#
|
118
|
+
# Combined Compare operator for version
|
119
|
+
#
|
120
|
+
# @param other [App::Version] Version object to compare against
|
121
|
+
# @return [Integer] returns -1 if (a <=> b)
|
122
|
+
#
|
90
123
|
def <=>(other)
|
91
124
|
# if !self.build.nil? && !other.build.nil?
|
92
125
|
# return self.build <=> other.build
|
93
126
|
# end
|
94
127
|
|
95
|
-
%w(build major minor patch milestone branch committer build_date).each do |meth|
|
96
|
-
rhs =
|
128
|
+
%w(build major minor patch milestone branch meta committer build_date).each do |meth|
|
129
|
+
rhs = send(meth) || -1
|
97
130
|
lhs = other.send(meth) || -1
|
98
131
|
|
99
132
|
ret = lhs <=> rhs
|
100
133
|
return ret unless ret == 0
|
101
134
|
end
|
102
135
|
|
103
|
-
|
136
|
+
0
|
137
|
+
end
|
138
|
+
|
139
|
+
def sem_ver_format
|
140
|
+
@@sem_ver_format = "#{major}.#{minor}"
|
141
|
+
@@sem_ver_format << ".#{patch}" unless patch.blank?
|
142
|
+
@@sem_ver_format << "-#{meta}" unless meta.blank?
|
143
|
+
@@sem_ver_format << "+#{build}" unless build.blank?
|
144
|
+
@@sem_ver_format
|
104
145
|
end
|
105
146
|
|
147
|
+
#
|
148
|
+
# Generate version string
|
149
|
+
#
|
150
|
+
# @return [String] Returns App Version string
|
151
|
+
#
|
106
152
|
def to_s
|
107
|
-
if @format
|
153
|
+
if defined? @format
|
108
154
|
str = eval(@format.to_s.inspect)
|
109
155
|
else
|
110
156
|
str = "#{major}.#{minor}"
|
111
157
|
str << ".#{patch}" unless patch.blank?
|
158
|
+
str << "-#{meta}" unless meta.blank?
|
112
159
|
str << " M#{milestone}" unless milestone.blank?
|
113
160
|
str << " (#{build})" unless build.blank?
|
114
161
|
str << " of #{branch}" unless branch.blank?
|
@@ -118,30 +165,28 @@ module App
|
|
118
165
|
str
|
119
166
|
end
|
120
167
|
|
121
|
-
|
168
|
+
private
|
122
169
|
|
123
170
|
def get_build_from_subversion
|
124
|
-
if File.
|
125
|
-
#YAML.parse(`svn info`)['Revision'].value
|
171
|
+
if File.exist?('.svn')
|
172
|
+
# YAML.parse(`svn info`)['Revision'].value
|
126
173
|
match = /(?:\d+:)?(\d+)M?S?/.match(`svnversion . -c`)
|
127
174
|
match && match[1]
|
128
175
|
end
|
129
176
|
end
|
130
177
|
|
131
178
|
def get_revcount_from_git
|
132
|
-
if File.
|
133
|
-
`git rev-list --count HEAD`.strip
|
134
|
-
end
|
179
|
+
`git rev-list --count HEAD`.strip if File.exist?('.git')
|
135
180
|
end
|
136
|
-
|
181
|
+
|
137
182
|
def get_revdate_from_git
|
138
|
-
if File.
|
183
|
+
if File.exist?('.git')
|
139
184
|
`git show --date=short --pretty=format:%cd|head -n1`.strip
|
140
185
|
end
|
141
186
|
end
|
142
|
-
|
187
|
+
|
143
188
|
def get_hash_from_git
|
144
|
-
if File.
|
189
|
+
if File.exist?('.git')
|
145
190
|
`git show --pretty=format:%H|head -n1|cut -c 1-6`.strip
|
146
191
|
end
|
147
192
|
end
|
data/lib/app_version/railtie.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
require 'app_version/app_version'
|
2
|
-
require 'rails'
|
2
|
+
require 'rails'
|
3
3
|
|
4
|
+
#
|
5
|
+
# Add App::Version Rake tasks
|
6
|
+
#
|
4
7
|
module AppVersion
|
8
|
+
#
|
9
|
+
# Add App::Version Rake tasks
|
10
|
+
#
|
5
11
|
class Railtie < Rails::Railtie
|
6
12
|
railtie_name :app_version
|
7
13
|
|
@@ -9,4 +15,4 @@ module AppVersion
|
|
9
15
|
load "tasks/app_version_tasks.rake"
|
10
16
|
end
|
11
17
|
end
|
12
|
-
end
|
18
|
+
end
|
data/lib/app_version.rb
CHANGED
data/test/app_version_test.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
require '
|
2
|
-
require 'active_support'
|
3
|
-
require 'app_version'
|
1
|
+
require 'test_helper'
|
4
2
|
|
5
|
-
class AppVersionTest < Test
|
3
|
+
class AppVersionTest < MiniTest::Test
|
6
4
|
|
7
5
|
def setup
|
8
6
|
@version = App::Version.new
|
9
7
|
@version.major = '1'
|
10
8
|
@version.minor = '2'
|
11
9
|
@version.patch = '3'
|
10
|
+
@version.meta = 'rc.1'
|
12
11
|
@version.milestone = '4'
|
13
12
|
@version.build = '500'
|
14
13
|
@version.branch = 'master'
|
@@ -22,16 +21,16 @@ class AppVersionTest < Test::Unit::TestCase
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def test_create_from_string
|
25
|
-
version = App::Version.parse '1.2.3 M4 (500) of master by coder on 2008-10-27'
|
24
|
+
version = App::Version.parse '1.2.3-rc.1 M4 (500) of master by coder on 2008-10-27'
|
26
25
|
assert_equal @version, version
|
27
26
|
|
28
|
-
version = App::Version.parse '1.2.3 M4 (500)'
|
27
|
+
version = App::Version.parse '1.2.3-rc.1 M4 (500)'
|
29
28
|
@version.branch = nil
|
30
29
|
@version.committer = nil
|
31
30
|
@version.build_date = nil
|
32
31
|
assert_equal @version, version
|
33
32
|
|
34
|
-
version = App::Version.parse '1.2.3 (500)'
|
33
|
+
version = App::Version.parse '1.2.3-rc.1 (500)'
|
35
34
|
@version.milestone = nil
|
36
35
|
@version.branch = nil
|
37
36
|
@version.committer = nil
|
@@ -40,6 +39,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
40
39
|
|
41
40
|
version = App::Version.parse '1.2 (500)'
|
42
41
|
@version.patch = nil
|
42
|
+
@version.meta = nil
|
43
43
|
@version.branch = nil
|
44
44
|
@version.committer = nil
|
45
45
|
@version.build_date = nil
|
@@ -48,6 +48,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
48
48
|
version = App::Version.parse '1.2'
|
49
49
|
@version.milestone = nil
|
50
50
|
@version.build = nil
|
51
|
+
@version.meta = nil
|
51
52
|
@version.branch = nil
|
52
53
|
@version.committer = nil
|
53
54
|
@version.build_date = nil
|
@@ -55,6 +56,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
55
56
|
|
56
57
|
version = App::Version.parse '1.2.1'
|
57
58
|
@version.patch = 1
|
59
|
+
@version.meta = nil
|
58
60
|
@version.branch = nil
|
59
61
|
@version.committer = nil
|
60
62
|
@version.build_date = nil
|
@@ -68,6 +70,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
68
70
|
@version.build = 6
|
69
71
|
@version.branch = 'branch'
|
70
72
|
@version.committer = 'coder'
|
73
|
+
@version.meta = nil
|
71
74
|
@version.build_date = Date.civil(2008, 10, 31)
|
72
75
|
assert_raises(ArgumentError) { App::Version.parse 'This is not a valid version' }
|
73
76
|
end
|
@@ -76,6 +79,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
76
79
|
version = App::Version.new :major => 1,
|
77
80
|
:minor => 2,
|
78
81
|
:patch => 3,
|
82
|
+
:meta => "rc.1",
|
79
83
|
:milestone => 4,
|
80
84
|
:build => 500,
|
81
85
|
:branch => 'master',
|
@@ -88,6 +92,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
88
92
|
version = App::Version.new 'major' => 1,
|
89
93
|
'minor' => 2,
|
90
94
|
'patch' => 3,
|
95
|
+
'meta' => "rc.1",
|
91
96
|
'milestone' => 4,
|
92
97
|
'build' => 500,
|
93
98
|
'branch' => 'master',
|
@@ -100,6 +105,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
100
105
|
version = App::Version.new :major => '1',
|
101
106
|
:minor => '2',
|
102
107
|
:patch => '3',
|
108
|
+
:meta => 'rc.1',
|
103
109
|
:milestone => '4',
|
104
110
|
:build => '500',
|
105
111
|
:branch => 'master',
|
@@ -112,6 +118,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
112
118
|
version = App::Version.new 'major' => '1',
|
113
119
|
'minor' => '2',
|
114
120
|
'patch' => '3',
|
121
|
+
'meta' => 'rc.1',
|
115
122
|
'milestone' => '4',
|
116
123
|
'build' => '500',
|
117
124
|
'branch' => 'master',
|
@@ -125,12 +132,13 @@ class AppVersionTest < Test::Unit::TestCase
|
|
125
132
|
version = App::Version.new :major => '1',
|
126
133
|
:minor => '2',
|
127
134
|
:patch => '3',
|
135
|
+
:meta => 'rc.1',
|
128
136
|
:milestone => '4',
|
129
137
|
:build => '500',
|
130
138
|
:branch => 'master',
|
131
139
|
:committer => 'coder',
|
132
140
|
:build_date => '12wtf34'
|
133
|
-
|
141
|
+
assert @version != version
|
134
142
|
end
|
135
143
|
|
136
144
|
def test_should_raise_when_major_is_missing
|
@@ -152,6 +160,7 @@ class AppVersionTest < Test::Unit::TestCase
|
|
152
160
|
@version.milestone = nil
|
153
161
|
@version.build = nil
|
154
162
|
@version.branch = nil
|
163
|
+
@version.meta = nil
|
155
164
|
@version.committer = nil
|
156
165
|
@version.build_date = nil
|
157
166
|
assert_equal @version, version
|
@@ -178,11 +187,11 @@ class AppVersionTest < Test::Unit::TestCase
|
|
178
187
|
:committer => nil,
|
179
188
|
:build_date => nil
|
180
189
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
190
|
+
assert_nil nil, version.patch
|
191
|
+
assert_nil nil, version.milestone
|
192
|
+
assert_nil nil, version.branch
|
193
|
+
assert_nil nil, version.committer
|
194
|
+
assert_nil nil, version.build_date
|
186
195
|
end
|
187
196
|
|
188
197
|
def test_create_with_empty_string
|
@@ -195,70 +204,70 @@ class AppVersionTest < Test::Unit::TestCase
|
|
195
204
|
:committer => '',
|
196
205
|
:build_date => ''
|
197
206
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
207
|
+
assert_nil nil, version.patch
|
208
|
+
assert_nil nil, version.milestone
|
209
|
+
assert_nil nil, version.branch
|
210
|
+
assert_nil nil, version.committer
|
211
|
+
assert_nil nil, version.build_date
|
203
212
|
end
|
204
213
|
|
205
214
|
def test_to_s
|
206
|
-
assert_equal '1.2.3 M4 (500) of master by coder on 2008-10-27', @version.to_s
|
215
|
+
assert_equal '1.2.3-rc.1 M4 (500) of master by coder on 2008-10-27', @version.to_s
|
207
216
|
end
|
208
217
|
|
209
218
|
def test_to_s_with_no_milestone
|
210
219
|
@version.milestone = nil
|
211
|
-
assert_equal '1.2.3 (500) of master by coder on 2008-10-27', @version.to_s
|
220
|
+
assert_equal '1.2.3-rc.1 (500) of master by coder on 2008-10-27', @version.to_s
|
212
221
|
end
|
213
222
|
|
214
223
|
def test_to_s_with_no_build
|
215
224
|
@version.build = nil
|
216
|
-
assert_equal '1.2.3 M4 of master by coder on 2008-10-27', @version.to_s
|
225
|
+
assert_equal '1.2.3-rc.1 M4 of master by coder on 2008-10-27', @version.to_s
|
217
226
|
end
|
218
227
|
|
219
228
|
def test_to_s_with_no_patch
|
220
229
|
@version.patch = nil
|
221
|
-
assert_equal '1.2 M4 (500) of master by coder on 2008-10-27', @version.to_s
|
230
|
+
assert_equal '1.2-rc.1 M4 (500) of master by coder on 2008-10-27', @version.to_s
|
222
231
|
end
|
223
232
|
|
224
233
|
def test_to_s_with_no_build_or_milestone
|
225
234
|
@version.milestone = nil
|
226
235
|
@version.build = nil
|
227
|
-
assert_equal '1.2.3 of master by coder on 2008-10-27', @version.to_s
|
236
|
+
assert_equal '1.2.3-rc.1 of master by coder on 2008-10-27', @version.to_s
|
228
237
|
end
|
229
238
|
|
230
239
|
def test_to_s_with_no_branch
|
231
240
|
@version.branch = nil
|
232
|
-
assert_equal '1.2.3 M4 (500) by coder on 2008-10-27', @version.to_s
|
241
|
+
assert_equal '1.2.3-rc.1 M4 (500) by coder on 2008-10-27', @version.to_s
|
233
242
|
end
|
234
243
|
|
235
244
|
def test_to_s_with_no_committer
|
236
245
|
@version.committer = nil
|
237
|
-
assert_equal '1.2.3 M4 (500) of master on 2008-10-27', @version.to_s
|
246
|
+
assert_equal '1.2.3-rc.1 M4 (500) of master on 2008-10-27', @version.to_s
|
238
247
|
end
|
239
248
|
|
240
249
|
def test_to_s_with_no_build_date
|
241
250
|
@version.build_date = nil
|
242
|
-
assert_equal '1.2.3 M4 (500) of master by coder', @version.to_s
|
251
|
+
assert_equal '1.2.3-rc.1 M4 (500) of master by coder', @version.to_s
|
243
252
|
end
|
244
253
|
|
245
254
|
def test_to_s_with_no_branch_or_committer
|
246
255
|
@version.branch = nil
|
247
256
|
@version.committer = nil
|
248
|
-
assert_equal '1.2.3 M4 (500) on 2008-10-27', @version.to_s
|
257
|
+
assert_equal '1.2.3-rc.1 M4 (500) on 2008-10-27', @version.to_s
|
249
258
|
end
|
250
259
|
|
251
260
|
def test_to_s_with_no_committer_or_build_date
|
252
261
|
@version.committer = nil
|
253
262
|
@version.build_date = nil
|
254
|
-
assert_equal '1.2.3 M4 (500) of master', @version.to_s
|
263
|
+
assert_equal '1.2.3-rc.1 M4 (500) of master', @version.to_s
|
255
264
|
end
|
256
265
|
|
257
266
|
def test_to_s_with_no_build_date_or_committer_or_build_date
|
258
267
|
@version.branch = nil
|
259
268
|
@version.committer = nil
|
260
269
|
@version.build_date = nil
|
261
|
-
assert_equal '1.2.3 M4 (500)', @version.to_s
|
270
|
+
assert_equal '1.2.3-rc.1 M4 (500)', @version.to_s
|
262
271
|
end
|
263
272
|
|
264
273
|
def test_version_with_leading_zeros
|
@@ -272,4 +281,52 @@ class AppVersionTest < Test::Unit::TestCase
|
|
272
281
|
assert_equal '4a', version.minor
|
273
282
|
assert_equal '2010.4a', version.to_s
|
274
283
|
end
|
284
|
+
|
285
|
+
# see http://semver.org/ for specification
|
286
|
+
|
287
|
+
def test_semver_format
|
288
|
+
App::Version.respond_to? :sem_ver_format
|
289
|
+
end
|
290
|
+
|
291
|
+
# see http://semver.org/#spec-item-2
|
292
|
+
def test_to_s_with_semver_format_with_no_build_or_milestone_or_meta
|
293
|
+
@version.milestone = nil
|
294
|
+
@version.build = nil
|
295
|
+
@version.meta = nil
|
296
|
+
@version.format = @version.sem_ver_format
|
297
|
+
assert(@version.major.to_i >= 0)
|
298
|
+
assert(@version.minor.to_i >= 0)
|
299
|
+
assert(@version.patch.to_i >= 0) if defined? @version.patch
|
300
|
+
|
301
|
+
assert_equal '1.2.3', @version.to_s
|
302
|
+
end
|
303
|
+
|
304
|
+
# see http://semver.org/#spec-item-9
|
305
|
+
def test_to_s_with_semver_format_with_no_build_or_milestone
|
306
|
+
@version.milestone = nil
|
307
|
+
@version.build = nil
|
308
|
+
@version.meta = 'rc.1'
|
309
|
+
@version.format = @version.sem_ver_format
|
310
|
+
assert(@version.major.to_i >= 0)
|
311
|
+
assert(@version.minor.to_i >= 0)
|
312
|
+
assert(@version.patch.to_i >= 0) if defined? @version.patch
|
313
|
+
assert(/[[:alnum:]\-.]*/ =~ @version.meta) if defined? @version.meta
|
314
|
+
|
315
|
+
assert_equal '1.2.3-rc.1', @version.to_s
|
316
|
+
end
|
317
|
+
|
318
|
+
# see http://semver.org/#spec-item-10
|
319
|
+
def test_to_s_with_semver_format_with_no_milestone_or_meta
|
320
|
+
@version.milestone = nil
|
321
|
+
@version.build = '20161231'
|
322
|
+
@version.format = @version.sem_ver_format
|
323
|
+
assert(@version.major.to_i >= 0)
|
324
|
+
assert(@version.minor.to_i >= 0)
|
325
|
+
assert(@version.patch.to_i >= 0) if defined? @version.patch
|
326
|
+
assert(/[[:alnum:]\-.]*/ =~ @version.build) if defined? @version.build
|
327
|
+
|
328
|
+
assert_equal '1.2.3-rc.1+20161231', @version.to_s
|
329
|
+
end
|
330
|
+
|
331
|
+
|
275
332
|
end
|
data/test/test_helper.rb
ADDED
data/test/version.yml
CHANGED
metadata
CHANGED
@@ -1,78 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_version
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
7
|
+
- Scott Curry
|
8
8
|
- Stephen Kapp
|
9
9
|
- Phillip Toland
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-04-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
18
|
requirements:
|
20
|
-
- -
|
19
|
+
- - ">="
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
21
|
+
version: 5.2.4.5
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
25
|
requirements:
|
28
|
-
- -
|
26
|
+
- - ">="
|
29
27
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
28
|
+
version: 5.2.4.5
|
31
29
|
description: App Version Gem originally App Version Rails Plugin from https://github.com/toland/app_version,
|
32
|
-
updated to
|
30
|
+
updated to run in CI server and with later rails versions as a gem, currently supports
|
31
|
+
Rails 5.2+
|
33
32
|
email:
|
33
|
+
- coder.scottcurry.com
|
34
34
|
- mort666@virus.org
|
35
35
|
- phil.toland@gmail.com
|
36
36
|
executables: []
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/app_version.rb
|
40
43
|
- lib/app_version/app_version.rb
|
41
44
|
- lib/app_version/railtie.rb
|
42
45
|
- lib/app_version/templates/version.yml
|
43
46
|
- lib/app_version/templates/version.yml.erb
|
44
|
-
- lib/app_version.rb
|
47
|
+
- lib/app_version/version.rb
|
45
48
|
- lib/install.rb
|
46
49
|
- lib/tasks/app_version_tasks.rake
|
47
50
|
- lib/uninstall.rb
|
48
|
-
- Rakefile
|
49
|
-
- README.md
|
50
51
|
- test/app_version_test.rb
|
52
|
+
- test/test_helper.rb
|
51
53
|
- test/version.yml
|
52
54
|
homepage: https://github.com/mort666/app_version
|
53
55
|
licenses: []
|
54
|
-
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
55
58
|
rdoc_options: []
|
56
59
|
require_paths:
|
57
60
|
- lib
|
58
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
62
|
requirements:
|
61
|
-
- -
|
63
|
+
- - ">="
|
62
64
|
- !ruby/object:Gem::Version
|
63
65
|
version: '0'
|
64
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
67
|
requirements:
|
67
|
-
- -
|
68
|
+
- - ">="
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: '0'
|
70
71
|
requirements: []
|
71
|
-
rubyforge_project:
|
72
|
-
rubygems_version:
|
73
|
-
signing_key:
|
74
|
-
specification_version:
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.7.10
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
75
76
|
summary: Rails App Version Gem
|
76
77
|
test_files:
|
77
78
|
- test/app_version_test.rb
|
79
|
+
- test/test_helper.rb
|
78
80
|
- test/version.yml
|