Class: Raketeer::BumpVer
Overview
Constant Summary
Constants inherited
from SemVer
SemVer::REGEX, SemVer::STRICT_REGEX
Instance Attribute Summary
Attributes inherited from SemVer
#build_meta, #major, #minor, #patch, #prerelease, #version
Instance Method Summary
collapse
Methods inherited from SemVer
#empty?, #initialize_copy, parse, parse_line, regex, #to_s
Constructor Details
#initialize(version: nil, major: nil, minor: nil, patch: nil, prerelease: nil, build_meta: nil) ⇒ BumpVer
Returns a new instance of BumpVer.
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/raketeer/bump_ver.rb', line 22
def initialize(version: nil,major: nil,minor: nil,patch: nil,prerelease: nil,build_meta: nil)
super()
self.build_meta = build_meta
self.major = major
self.minor = minor
self.patch = patch
self.prerelease = prerelease
self.version = version
end
|
Instance Method Details
133
134
135
|
# File 'lib/raketeer/bump_ver.rb', line 133
def build_meta=(build_meta)
super(init_str(build_meta))
end
|
#bump!(sem_ver) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/raketeer/bump_ver.rb', line 47
def bump!(sem_ver)
if !@version.nil?
sem_ver.version = @version
else
if !@major.nil?
if @major.is_a?(Integer)
sem_ver.major = @major
elsif @major.empty?
sem_ver.major = 0 else
sem_ver.major = 0 if sem_ver.major.nil?
old_major = sem_ver.major
sem_ver.major += @major.to_i
if sem_ver.major != old_major
sem_ver.minor = 0
sem_ver.patch = 0
end
end
end
if !@minor.nil?
if @minor.is_a?(Integer)
sem_ver.minor = @minor
elsif @minor.empty?
sem_ver.minor = nil
else
sem_ver.minor = 0 if sem_ver.minor.nil?
old_minor = sem_ver.minor
sem_ver.minor += @minor.to_i
if sem_ver.minor != old_minor
sem_ver.patch = 0
end
end
end
if !@patch.nil?
if @patch.is_a?(Integer)
sem_ver.patch = @patch
elsif @patch.empty?
sem_ver.patch = nil
else
sem_ver.patch = 0 if sem_ver.patch.nil?
sem_ver.patch += @patch.to_i
end
end
if !@prerelease.nil?
if @prerelease.empty?
sem_ver.prerelease = nil
else
sem_ver.prerelease = @prerelease
end
end
if !@build_meta.nil?
if @build_meta.empty?
sem_ver.build_meta = nil
else
sem_ver.build_meta = @build_meta
end
end
end
return sem_ver
end
|
#bump_line!(line, sem_ver, strict: false) ⇒ Object
127
128
129
130
131
|
# File 'lib/raketeer/bump_ver.rb', line 127
def bump_line!(line,sem_ver,strict: false)
line.sub!(self.class.regex(strict),bump!(sem_ver).to_s)
return line
end
|
#init_int_or_str(obj) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/raketeer/bump_ver.rb', line 33
def init_int_or_str(obj)
return nil if obj.nil?
return obj if obj.is_a?(Integer)
obj = obj.to_s.strip
return obj if obj.empty? || obj[0] == '+'
return obj.to_i
end
|
#init_str(obj) ⇒ Object
43
44
45
|
# File 'lib/raketeer/bump_ver.rb', line 43
def init_str(obj)
return obj.nil? ? nil : obj.to_s.strip
end
|
#major=(major) ⇒ Object
137
138
139
|
# File 'lib/raketeer/bump_ver.rb', line 137
def major=(major)
super(init_int_or_str(major))
end
|
#minor=(minor) ⇒ Object
141
142
143
|
# File 'lib/raketeer/bump_ver.rb', line 141
def minor=(minor)
super(init_int_or_str(minor))
end
|
#patch=(patch) ⇒ Object
145
146
147
|
# File 'lib/raketeer/bump_ver.rb', line 145
def patch=(patch)
super(init_int_or_str(patch))
end
|
#prerelease=(prerelease) ⇒ Object
149
150
151
|
# File 'lib/raketeer/bump_ver.rb', line 149
def prerelease=(prerelease)
super(init_str(prerelease))
end
|
#version=(version) ⇒ Object
153
154
155
|
# File 'lib/raketeer/bump_ver.rb', line 153
def version=(version)
super(init_str(version))
end
|