sleeping_king_studios-tools 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/sleeping_king_studios/tools/semantic_version.rb +82 -82
- data/lib/sleeping_king_studios/tools/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d95961cf9c0f704e80358834b1f45de5e3cc2e93
|
|
4
|
+
data.tar.gz: 91bd9c25c66c817eb25b43c74218512848de860a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9801022cb106352a814ac6fe87a17a498b0be4fad587c995758942d3697666daff0c5c66defe842a6f912f781bdcc5d8c3b4f4c603ca2819da3ffb1288d5748
|
|
7
|
+
data.tar.gz: eb48ea7b3c4a1afa3a09c4f9497e63deec32a98bcebbbbb177914f2f6ce3086dd8fd593a8fe3ae65cc77804552294cac40decedabe1ff458a45373fda54c12d5
|
data/CHANGELOG.md
ADDED
|
@@ -1,36 +1,9 @@
|
|
|
1
1
|
# lib/sleeping_king_studios/tools/semantic_version.rb
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
# build parameters.
|
|
8
|
-
#
|
|
9
|
-
# @example
|
|
10
|
-
# module Version
|
|
11
|
-
# extend SleepingKingStudios::Tools::SemanticVersion
|
|
12
|
-
#
|
|
13
|
-
# MAJOR = 3
|
|
14
|
-
# MINOR = 1
|
|
15
|
-
# PATCH = 4
|
|
16
|
-
# PRERELEASE = 'beta'
|
|
17
|
-
# BUILD = 1
|
|
18
|
-
# end # module
|
|
19
|
-
#
|
|
20
|
-
# VERSION = Version.to_gem_version
|
|
21
|
-
#
|
|
22
|
-
# @see http://semver.org
|
|
23
|
-
module SemanticVersion
|
|
24
|
-
# @api private
|
|
25
|
-
FETCH_DEFAULT = Object.new.freeze
|
|
26
|
-
|
|
27
|
-
# Error class for handling missing constants in a version definition.
|
|
28
|
-
class InvalidVersionError < StandardError; end
|
|
29
|
-
|
|
30
|
-
# Concatenates the MAJOR, MINOR, and PATCH constant values with PRERELEASE
|
|
31
|
-
# and BUILD (if available) to generate a modified semantic version string
|
|
32
|
-
# compatible with Rubygems. The major, minor, patch, prerelease, and build
|
|
33
|
-
# values (if available) are separated by dots (.).
|
|
3
|
+
module SleepingKingStudios
|
|
4
|
+
module Tools
|
|
5
|
+
# Helper for generating semantic version strings with optional prerelease and
|
|
6
|
+
# build parameters.
|
|
34
7
|
#
|
|
35
8
|
# @example
|
|
36
9
|
# module Version
|
|
@@ -44,66 +17,93 @@ module SleepingKingStudios::Tools
|
|
|
44
17
|
# end # module
|
|
45
18
|
#
|
|
46
19
|
# VERSION = Version.to_gem_version
|
|
47
|
-
# #=> '3.1.4.beta.1'
|
|
48
20
|
#
|
|
49
|
-
# @
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
str = "#{const_fetch :MAJOR}.#{const_fetch :MINOR}.#{const_fetch :PATCH}"
|
|
21
|
+
# @see http://semver.org
|
|
22
|
+
module SemanticVersion
|
|
23
|
+
# @api private
|
|
24
|
+
FETCH_DEFAULT = Object.new.freeze
|
|
54
25
|
|
|
55
|
-
|
|
56
|
-
|
|
26
|
+
# Error class for handling missing constants in a version definition.
|
|
27
|
+
class InvalidVersionError < StandardError; end
|
|
57
28
|
|
|
58
|
-
|
|
59
|
-
|
|
29
|
+
# Concatenates the MAJOR, MINOR, and PATCH constant values with PRERELEASE
|
|
30
|
+
# and BUILD (if available) to generate a modified semantic version string
|
|
31
|
+
# compatible with Rubygems. The major, minor, patch, prerelease, and build
|
|
32
|
+
# values (if available) are separated by dots (.).
|
|
33
|
+
#
|
|
34
|
+
# @example
|
|
35
|
+
# module Version
|
|
36
|
+
# extend SleepingKingStudios::Tools::SemanticVersion
|
|
37
|
+
#
|
|
38
|
+
# MAJOR = 3
|
|
39
|
+
# MINOR = 1
|
|
40
|
+
# PATCH = 4
|
|
41
|
+
# PRERELEASE = 'beta'
|
|
42
|
+
# BUILD = 1
|
|
43
|
+
# end # module
|
|
44
|
+
#
|
|
45
|
+
# VERSION = Version.to_gem_version
|
|
46
|
+
# #=> '3.1.4.beta.1'
|
|
47
|
+
#
|
|
48
|
+
# @return [String] The modified semantic version string.
|
|
49
|
+
#
|
|
50
|
+
# @raise InvalidVersionError If MAJOR, MINOR, or PATCH is undefined.
|
|
51
|
+
def to_gem_version
|
|
52
|
+
str = "#{const_fetch :MAJOR}.#{const_fetch :MINOR}.#{const_fetch :PATCH}"
|
|
60
53
|
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
prerelease = const_fetch(:PRERELEASE, nil)
|
|
55
|
+
str << ".#{prerelease}" unless prerelease.nil? || prerelease.empty?
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
57
|
+
build = const_fetch(:BUILD, nil)
|
|
58
|
+
str << ".#{build}" unless build.nil? || build.empty?
|
|
59
|
+
|
|
60
|
+
str
|
|
61
|
+
end # method to_version
|
|
62
|
+
|
|
63
|
+
# Concatenates the MAJOR, MINOR, and PATCH constant values with PRERELEASE
|
|
64
|
+
# and BUILD (if available) to generate a semantic version string. The
|
|
65
|
+
# major, minor, and patch values are separated by dots (.), then the
|
|
66
|
+
# prerelease (if available) preceded by a hyphen (-), and the build (if
|
|
67
|
+
# available) preceded by a plus (+).
|
|
68
|
+
#
|
|
69
|
+
# @example
|
|
70
|
+
# module Version
|
|
71
|
+
# extend SleepingKingStudios::Tools::SemanticVersion
|
|
72
|
+
#
|
|
73
|
+
# MAJOR = 3
|
|
74
|
+
# MINOR = 1
|
|
75
|
+
# PATCH = 4
|
|
76
|
+
# PRERELEASE = 'beta'
|
|
77
|
+
# BUILD = 1
|
|
78
|
+
# end # module
|
|
79
|
+
#
|
|
80
|
+
# VERSION = Version.to_version
|
|
81
|
+
# #=> '3.1.4-beta+1'
|
|
82
|
+
#
|
|
83
|
+
# @return [String] The semantic version string.
|
|
84
|
+
#
|
|
85
|
+
# @raise InvalidVersionError If MAJOR, MINOR, or PATCH is undefined.
|
|
86
|
+
def to_version
|
|
87
|
+
str = "#{const_fetch :MAJOR}.#{const_fetch :MINOR}.#{const_fetch :PATCH}"
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
prerelease = const_fetch(:PRERELEASE, nil)
|
|
90
|
+
str << "-#{prerelease}" unless prerelease.nil? || prerelease.empty?
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
build = const_fetch(:BUILD, nil)
|
|
93
|
+
str << "+#{build}" unless build.nil? || build.empty?
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
str
|
|
96
|
+
end # method to_version
|
|
98
97
|
|
|
99
|
-
|
|
98
|
+
private
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
def const_fetch name, default = FETCH_DEFAULT
|
|
101
|
+
if self.const_defined?(name)
|
|
102
|
+
return self.const_get(name).to_s
|
|
103
|
+
elsif default == FETCH_DEFAULT
|
|
104
|
+
raise InvalidVersionError.new "undefined constant for #{name.downcase} version"
|
|
105
|
+
end # if-else
|
|
106
|
+
end # method const_fetch
|
|
107
|
+
end # module
|
|
108
108
|
end # module
|
|
109
109
|
end # module
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sleeping_king_studios-tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rob "Merlin" Smith
|
|
@@ -79,6 +79,7 @@ executables: []
|
|
|
79
79
|
extensions: []
|
|
80
80
|
extra_rdoc_files: []
|
|
81
81
|
files:
|
|
82
|
+
- CHANGELOG.md
|
|
82
83
|
- LICENSE
|
|
83
84
|
- README.md
|
|
84
85
|
- lib/sleeping_king_studios/tools.rb
|