raketeer 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/lib/raketeer/bump_task.rb +47 -23
- data/lib/raketeer/bump_ver.rb +2 -2
- data/lib/raketeer/files_bumper.rb +18 -8
- data/lib/raketeer/sem_ver.rb +7 -2
- data/lib/raketeer/version.rb +1 -1
- data/raketeer.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ea4a060cb8e00095e9df956fa2ee5f82b62f54062a5e9a304902a82e8aed1eb
|
4
|
+
data.tar.gz: cf7681b3872489a4f6a2c7b7faad9103613c6966ddc978e3e4d151da33ee1e0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c59023bccceb084fc6ee5aeee2de32482c5ba77c8bb7995371161dabff2e0755a572b0b676e6b4b6a1bb690d3ddb90047b79a9701712492bdbc20009dc1e629
|
7
|
+
data.tar.gz: 735a8192cdc76bb8bc9dfa9b019980a789f45bb365800725b5a482e4b212e6c5d8d5080b526c6f1969c7fc8100c6a044ad43b120a6b3b1e8d82d0b9187c75db7
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,14 @@
|
|
2
2
|
|
3
3
|
Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
4
4
|
|
5
|
-
## [[Unreleased]](https://github.com/esotericpig/raketeer/compare/v0.2.
|
5
|
+
## [[Unreleased]](https://github.com/esotericpig/raketeer/compare/v0.2.5...master)
|
6
|
+
|
7
|
+
## [v0.2.5] - 2019-08-02
|
8
|
+
### Added
|
9
|
+
- Added a strict mode (regex) to BumpTask, BumpVer, FilesBumper, & SemVer
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- Fixed the 'Nothing written (up-to-date)' feature in BumpTask (minor)
|
6
13
|
|
7
14
|
## [v0.2.4] - 2019-08-02
|
8
15
|
### Added
|
data/lib/raketeer/bump_task.rb
CHANGED
@@ -46,9 +46,11 @@ module Raketeer
|
|
46
46
|
attr_accessor :name
|
47
47
|
attr_accessor :ruby_files # Looks for {ruby_var}
|
48
48
|
attr_accessor :ruby_var
|
49
|
+
attr_accessor :strict
|
49
50
|
|
50
51
|
alias_method :bump_bundle?,:bump_bundle
|
51
52
|
alias_method :dry_run?,:dry_run
|
53
|
+
alias_method :strict?,:strict
|
52
54
|
|
53
55
|
def initialize(name=:bump)
|
54
56
|
super()
|
@@ -62,6 +64,7 @@ module Raketeer
|
|
62
64
|
@name = name
|
63
65
|
@ruby_files = Rake::FileList[File.join('lib','**','version.rb')]
|
64
66
|
@ruby_var = 'VERSION'
|
67
|
+
@strict = false
|
65
68
|
|
66
69
|
yield self if block_given?()
|
67
70
|
define()
|
@@ -165,12 +168,15 @@ module Raketeer
|
|
165
168
|
end
|
166
169
|
|
167
170
|
def bump_bump_files(bump_ver)
|
168
|
-
|
171
|
+
return nil if @bump_files.empty?()
|
172
|
+
|
173
|
+
bumper = FilesBumper.new(@bump_files,bump_ver,@dry_run,@strict)
|
169
174
|
|
170
175
|
bumper.bump_files() do
|
171
|
-
next if bumper.changes > 0 || bumper.
|
176
|
+
next if bumper.changes > 0 || !bumper.sem_ver.nil?()
|
177
|
+
next if bumper.line !~ SemVer.regex(@strict)
|
172
178
|
|
173
|
-
break if bumper.bump_line!() && bumper.bump_ver_empty?()
|
179
|
+
break if bumper.bump_line!() != :no_ver && bumper.bump_ver_empty?()
|
174
180
|
end
|
175
181
|
|
176
182
|
return bumper.version
|
@@ -192,28 +198,27 @@ module Raketeer
|
|
192
198
|
|
193
199
|
# @see https://keepachangelog.com/en/1.0.0/
|
194
200
|
def bump_changelogs(bump_ver)
|
195
|
-
|
201
|
+
return nil if @changelogs.empty?()
|
202
|
+
|
203
|
+
bumper = FilesBumper.new(@changelogs,bump_ver,@dry_run,@strict) do
|
196
204
|
@header_bumped = false
|
197
205
|
@unreleased_bumped = false
|
198
206
|
end
|
199
207
|
|
200
|
-
header_regex = /\A(\s*##\s*\[+\D*)(#{SemVer
|
208
|
+
header_regex = /\A(\s*##\s*\[+\D*)(#{SemVer.regex(@strict)})(.*)\z/m
|
201
209
|
unreleased_regex = /\A.*Unreleased.*http.*\.{3}/
|
202
210
|
|
203
211
|
bumper.bump_files() do
|
204
212
|
if @header_bumped && @unreleased_bumped
|
205
|
-
if bumper.bump_ver_empty?()
|
206
|
-
|
207
|
-
else
|
208
|
-
next
|
209
|
-
end
|
213
|
+
break if bumper.bump_ver_empty?()
|
214
|
+
next
|
210
215
|
end
|
211
216
|
|
212
217
|
if bumper.line =~ unreleased_regex
|
213
218
|
next if @unreleased_bumped
|
214
219
|
|
215
220
|
# Match from the end, in case the URL has a number (like '%20')
|
216
|
-
match = bumper.line.match(/(#{SemVer
|
221
|
+
match = bumper.line.match(/(#{SemVer.regex(@strict)})(\.{3}.*)\z/m)
|
217
222
|
|
218
223
|
next if match.nil?() || match.length < 3 || (i = match.begin(0)) < 1
|
219
224
|
|
@@ -224,12 +229,18 @@ module Raketeer
|
|
224
229
|
orig_line = bumper.line.dup()
|
225
230
|
bumper.line = match[1]
|
226
231
|
|
227
|
-
if bumper.bump_line!(add_change: false)
|
232
|
+
if (result = bumper.bump_line!(add_change: false)) != :no_ver
|
233
|
+
@unreleased_bumped = true
|
234
|
+
|
235
|
+
if result == :same_ver
|
236
|
+
bumper.line = orig_line
|
237
|
+
|
238
|
+
next
|
239
|
+
end
|
240
|
+
|
228
241
|
bumper.line = match[0] << bumper.line << match[2]
|
229
242
|
|
230
243
|
bumper.add_change(bumper.line,push: false)
|
231
|
-
|
232
|
-
@unreleased_bumped = true
|
233
244
|
else
|
234
245
|
bumper.line = orig_line
|
235
246
|
end
|
@@ -243,7 +254,15 @@ module Raketeer
|
|
243
254
|
orig_line = bumper.line.dup()
|
244
255
|
bumper.line = match[1]
|
245
256
|
|
246
|
-
if bumper.bump_line!(add_change: false)
|
257
|
+
if (result = bumper.bump_line!(add_change: false)) != :no_ver
|
258
|
+
@header_bumped = true
|
259
|
+
|
260
|
+
if result == :same_ver
|
261
|
+
bumper.line = orig_line
|
262
|
+
|
263
|
+
next
|
264
|
+
end
|
265
|
+
|
247
266
|
bumper.line = match[0] << bumper.line
|
248
267
|
|
249
268
|
# Replace the date with today's date for the new Markdown header, if it exists
|
@@ -252,8 +271,6 @@ module Raketeer
|
|
252
271
|
|
253
272
|
bumper.add_change(bumper.line,push: true)
|
254
273
|
bumper.line << "\n" # Don't print this newline to the console
|
255
|
-
|
256
|
-
@header_bumped = true
|
257
274
|
end
|
258
275
|
|
259
276
|
# We are adding a new Markdown header, so always set the line back to its original value
|
@@ -265,11 +282,13 @@ module Raketeer
|
|
265
282
|
end
|
266
283
|
|
267
284
|
def bump_ruby_files(bump_ver)
|
268
|
-
|
269
|
-
|
285
|
+
return nil if @ruby_files.empty?()
|
286
|
+
|
287
|
+
bumper = FilesBumper.new(@ruby_files,bump_ver,@dry_run,@strict)
|
288
|
+
version_var_regex = /\A(\s*#{Regexp.quote(@ruby_var)}\s*=\D*)(#{SemVer.regex(@strict)})(.*)\z/m
|
270
289
|
|
271
290
|
bumper.bump_files() do
|
272
|
-
next if bumper.changes > 0
|
291
|
+
next if bumper.changes > 0 || !bumper.sem_ver.nil?()
|
273
292
|
next if (match = bumper.line.match(version_var_regex)).nil?()
|
274
293
|
next if match.length < 4
|
275
294
|
next if match[1..2].any?() {|m| m.nil?() || m.strip().empty?()}
|
@@ -277,13 +296,18 @@ module Raketeer
|
|
277
296
|
orig_line = bumper.line.dup()
|
278
297
|
bumper.line = match[2]
|
279
298
|
|
280
|
-
if bumper.bump_line!(add_change: false)
|
299
|
+
if (result = bumper.bump_line!(add_change: false)) != :no_ver
|
300
|
+
if result == :same_ver
|
301
|
+
bumper.line = orig_line
|
302
|
+
|
303
|
+
break if bumper.bump_ver_empty?()
|
304
|
+
next
|
305
|
+
end
|
306
|
+
|
281
307
|
bumper.line = match[1] << bumper.line
|
282
308
|
bumper.line << match[-1] unless match[-1].nil?()
|
283
309
|
|
284
310
|
bumper.add_change(bumper.line,push: false)
|
285
|
-
|
286
|
-
break if bumper.bump_ver_empty?()
|
287
311
|
else
|
288
312
|
bumper.line = orig_line
|
289
313
|
end
|
data/lib/raketeer/bump_ver.rb
CHANGED
@@ -111,8 +111,8 @@ module Raketeer
|
|
111
111
|
return sem_ver
|
112
112
|
end
|
113
113
|
|
114
|
-
def bump_line!(line,sem_ver)
|
115
|
-
line.sub!(
|
114
|
+
def bump_line!(line,sem_ver,strict: false)
|
115
|
+
line.sub!(self.class.regex(strict),bump!(sem_ver).to_s())
|
116
116
|
|
117
117
|
return line
|
118
118
|
end
|
@@ -39,20 +39,23 @@ module Raketeer
|
|
39
39
|
attr_accessor :line
|
40
40
|
attr_accessor :lines
|
41
41
|
attr_accessor :sem_ver
|
42
|
+
attr_accessor :strict
|
42
43
|
attr_accessor :version
|
43
44
|
attr_accessor :version_bumped # Was the version actually bumped?
|
44
45
|
|
45
46
|
alias_method :bump_ver_empty?,:bump_ver_empty
|
46
47
|
alias_method :dry_run?,:dry_run
|
48
|
+
alias_method :strict?,:strict
|
47
49
|
alias_method :version_bumped?,:version_bumped
|
48
50
|
|
49
|
-
def initialize(files,bump_ver,dry_run,&init_per_file)
|
51
|
+
def initialize(files,bump_ver,dry_run,strict,&init_per_file)
|
50
52
|
@bump_ver = bump_ver
|
51
53
|
@bump_ver_empty = bump_ver.empty?()
|
52
54
|
@dry_run = dry_run
|
53
55
|
@files = files.to_a()
|
54
56
|
@init_per_file = init_per_file
|
55
57
|
@sem_ver = nil
|
58
|
+
@strict = strict
|
56
59
|
@version = nil
|
57
60
|
@version_bumped = false
|
58
61
|
end
|
@@ -108,22 +111,25 @@ module Raketeer
|
|
108
111
|
end
|
109
112
|
end
|
110
113
|
|
114
|
+
# @return [:no_ver,:same_ver,:bumped_ver]
|
111
115
|
def bump_line!(add_change: true)
|
112
|
-
@sem_ver = SemVer.parse_line(@line)
|
116
|
+
@sem_ver = SemVer.parse_line(@line,strict: @strict)
|
113
117
|
|
114
|
-
return
|
118
|
+
return :no_ver if @sem_ver.nil?()
|
115
119
|
|
116
120
|
@version = @sem_ver if @version.nil?()
|
117
121
|
|
118
122
|
if bump_ver_empty?()
|
119
123
|
puts "= #{@sem_ver}"
|
120
124
|
|
121
|
-
return
|
125
|
+
return :same_ver
|
122
126
|
else
|
123
127
|
orig_line = @line.dup()
|
124
|
-
@
|
128
|
+
orig_sem_ver = @sem_ver.dup()
|
125
129
|
|
126
|
-
|
130
|
+
@bump_ver.bump_line!(@line,@sem_ver,strict: @strict)
|
131
|
+
|
132
|
+
if @sem_ver.to_s() != orig_sem_ver.to_s()
|
127
133
|
if !@version_bumped
|
128
134
|
@version = @sem_ver
|
129
135
|
@version_bumped = true
|
@@ -131,11 +137,15 @@ module Raketeer
|
|
131
137
|
|
132
138
|
self.add_change(@line,push: false) if add_change
|
133
139
|
|
134
|
-
return
|
140
|
+
return :bumped_ver
|
141
|
+
else
|
142
|
+
@line = orig_line
|
143
|
+
|
144
|
+
return :same_ver
|
135
145
|
end
|
136
146
|
end
|
137
147
|
|
138
|
-
return
|
148
|
+
return :no_ver
|
139
149
|
end
|
140
150
|
end
|
141
151
|
end
|
data/lib/raketeer/sem_ver.rb
CHANGED
@@ -33,6 +33,7 @@ module Raketeer
|
|
33
33
|
###
|
34
34
|
class SemVer
|
35
35
|
REGEX = /\d+(\.\d+)?(\.\d+)?(\-[0-9A-Za-z\-\.]+)?(\+[0-9A-Za-z\-\.]+)?/
|
36
|
+
STRICT_REGEX = /\d+\.\d+\.\d+(\-[0-9A-Za-z\-\.]+)?(\+[0-9A-Za-z\-\.]+)?/
|
36
37
|
|
37
38
|
attr_accessor :build_meta
|
38
39
|
attr_accessor :major
|
@@ -95,8 +96,8 @@ module Raketeer
|
|
95
96
|
return sem_ver
|
96
97
|
end
|
97
98
|
|
98
|
-
def self.parse_line(line)
|
99
|
-
str = line[
|
99
|
+
def self.parse_line(line,strict: false)
|
100
|
+
str = line[regex(strict)]
|
100
101
|
|
101
102
|
return nil if str.nil?() || (str = str.strip()).empty?()
|
102
103
|
return parse(str)
|
@@ -111,6 +112,10 @@ module Raketeer
|
|
111
112
|
@version.nil?()
|
112
113
|
end
|
113
114
|
|
115
|
+
def self.regex(strict=false)
|
116
|
+
return strict ? STRICT_REGEX : REGEX
|
117
|
+
end
|
118
|
+
|
114
119
|
def to_s()
|
115
120
|
s = ''.dup()
|
116
121
|
|
data/lib/raketeer/version.rb
CHANGED
data/raketeer.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new() do |spec|
|
|
33
33
|
spec.licenses = ['LGPL-3.0-or-later']
|
34
34
|
spec.homepage = 'https://github.com/esotericpig/raketeer'
|
35
35
|
spec.summary = 'Extra Ruby Rake Tasks.'
|
36
|
-
spec.description = 'Extra Ruby Rake Tasks for IRB, Nokogiri, running, etc.'
|
36
|
+
spec.description = 'Extra Ruby Rake Tasks for IRB, Nokogiri, running, bumping the version, etc.'
|
37
37
|
|
38
38
|
spec.metadata = {
|
39
39
|
'bug_tracker_uri' => 'https://github.com/esotericpig/raketeer/issues',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raketeer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Bradley Whited (@esotericpig)
|
@@ -66,7 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.9'
|
69
|
-
description: Extra Ruby Rake Tasks for IRB, Nokogiri, running,
|
69
|
+
description: Extra Ruby Rake Tasks for IRB, Nokogiri, running, bumping the version,
|
70
|
+
etc.
|
70
71
|
email:
|
71
72
|
- bradley@esotericpig.com
|
72
73
|
executables: []
|