bake-modernize 0.13.0 → 0.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/modernize/actions.rb +2 -0
- data/bake/modernize/editorconfig.rb +3 -1
- data/bake/modernize/frozen_string_literal.rb +50 -0
- data/bake/modernize/gemfile.rb +3 -1
- data/bake/modernize/gemspec.rb +2 -0
- data/bake/modernize/git.rb +6 -1
- data/bake/modernize/license.rb +13 -1
- data/bake/modernize/readme.rb +2 -0
- data/bake/modernize/signing.rb +3 -1
- data/bake/modernize.rb +3 -1
- data/lib/bake/modernize/version.rb +3 -1
- data/lib/bake/modernize.rb +3 -1
- data/template/git/.gitignore +5 -0
- data.tar.gz.sig +0 -0
- metadata +3 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43ccc35944a73c49b82c67b6dfe17a0010f7653da8f3cf1c861915a4be1a5017
|
4
|
+
data.tar.gz: 885e420146d6319d69949d12da0ef15d6af06001e42b3cbfa8dcd5bdb038ee1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5835b74331b32293a53b771ebc0c92caa9e823b8fe90156aebaca98d10c876f060d3f60f82904256a0d11e2662c4cdfa791dffde13b845cced6e4ca3adbfc721
|
7
|
+
data.tar.gz: 432d156c7e168cf87a0038e7f2cb4e0d28a668414438d5a4ab1a14109294048a5e9e44ee31e90a7b9f5c8746bdfd7986ff6ab6d2e4f9ed02e1545cb667d0ce14
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bake/modernize/actions.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def frozen_string_literal
|
4
|
+
update(root: Dir.pwd)
|
5
|
+
end
|
6
|
+
|
7
|
+
def update(root:)
|
8
|
+
Dir.glob("**/*.rb", base: root).each do |path|
|
9
|
+
case path
|
10
|
+
when /\.rb$/
|
11
|
+
update_source_file(path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def update_source_file(path)
|
19
|
+
input = File.readlines(path)
|
20
|
+
output = []
|
21
|
+
|
22
|
+
# Skip the hash-bang line:
|
23
|
+
if input.first =~ /^\#!/
|
24
|
+
output.push input.shift
|
25
|
+
end
|
26
|
+
|
27
|
+
options = {}
|
28
|
+
|
29
|
+
while input.first =~ /^\#\s*(.*?):(.*)$/
|
30
|
+
options[$1.strip] = $2.strip
|
31
|
+
input.shift
|
32
|
+
end
|
33
|
+
|
34
|
+
options['frozen_string_literal'] ||= 'true'
|
35
|
+
|
36
|
+
options.each do |key, value|
|
37
|
+
output.push "# #{key}: #{value}"
|
38
|
+
end
|
39
|
+
|
40
|
+
unless input.first&.chomp&.empty?
|
41
|
+
output.push "\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
# Add the rest of the file:
|
45
|
+
output.push(*input)
|
46
|
+
|
47
|
+
File.open(path, "w") do |file|
|
48
|
+
file.puts(output)
|
49
|
+
end
|
50
|
+
end
|
data/bake/modernize/gemfile.rb
CHANGED
data/bake/modernize/gemspec.rb
CHANGED
data/bake/modernize/git.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Released under the MIT License.
|
2
|
-
# Copyright, 2021, by Samuel Williams.
|
4
|
+
# Copyright, 2021-2022, by Samuel Williams.
|
3
5
|
|
4
6
|
require 'bake/modernize'
|
5
7
|
|
@@ -13,6 +15,9 @@ def update(root:)
|
|
13
15
|
system("git", "branch", "-M", "main")
|
14
16
|
system("git", "push", "-u", "origin", "main")
|
15
17
|
end
|
18
|
+
|
19
|
+
template_root = Bake::Modernize.template_path_for('git')
|
20
|
+
Bake::Modernize.copy_template(template_root, root)
|
16
21
|
end
|
17
22
|
|
18
23
|
private
|
data/bake/modernize/license.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Released under the MIT License.
|
2
4
|
# Copyright, 2022, by Samuel Williams.
|
3
5
|
|
@@ -49,6 +51,8 @@ def update(root:)
|
|
49
51
|
end
|
50
52
|
|
51
53
|
paths.each do |path, authors|
|
54
|
+
next unless File.exist?(path)
|
55
|
+
|
52
56
|
case path
|
53
57
|
when /\.rb$/
|
54
58
|
self.update_source_file_authors(path, authors)
|
@@ -62,8 +66,16 @@ def update_source_file_authors(path, authors)
|
|
62
66
|
input = File.readlines(path)
|
63
67
|
output = []
|
64
68
|
|
65
|
-
if input =~ /^\#!/
|
69
|
+
if input.first =~ /^\#!/
|
70
|
+
output.push input.shift
|
71
|
+
end
|
72
|
+
|
73
|
+
if input.first =~ /^\#.*?\:/
|
66
74
|
output.push input.shift
|
75
|
+
if input.first.chomp.empty?
|
76
|
+
input.shift
|
77
|
+
end
|
78
|
+
output << "\n"
|
67
79
|
end
|
68
80
|
|
69
81
|
# Remove any existing license:
|
data/bake/modernize/readme.rb
CHANGED
data/bake/modernize/signing.rb
CHANGED
data/bake/modernize.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Released under the MIT License.
|
2
4
|
# Copyright, 2020-2022, by Samuel Williams.
|
3
5
|
|
4
6
|
def modernize
|
5
|
-
call('modernize:git', 'modernize:readme', 'modernize:actions', 'modernize:editorconfig', 'modernize:gemfile', 'modernize:signing', 'modernize:gemspec', 'modernize:license')
|
7
|
+
call('modernize:git', 'modernize:readme', 'modernize:actions', 'modernize:editorconfig', 'modernize:gemfile', 'modernize:signing', 'modernize:gemspec', 'modernize:license', 'modernize:frozen_string_literal')
|
6
8
|
end
|
data/lib/bake/modernize.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake-modernize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- bake/modernize.rb
|
134
134
|
- bake/modernize/actions.rb
|
135
135
|
- bake/modernize/editorconfig.rb
|
136
|
+
- bake/modernize/frozen_string_literal.rb
|
136
137
|
- bake/modernize/gemfile.rb
|
137
138
|
- bake/modernize/gemspec.rb
|
138
139
|
- bake/modernize/git.rb
|
@@ -148,6 +149,7 @@ files:
|
|
148
149
|
- template/actions/.github/workflows/test-external.yaml
|
149
150
|
- template/actions/.github/workflows/test.yaml
|
150
151
|
- template/editorconfig/.editorconfig
|
152
|
+
- template/git/.gitignore
|
151
153
|
- template/readme/README.md
|
152
154
|
homepage: https://github.com/ioquatix/bake-modernize
|
153
155
|
licenses:
|
metadata.gz.sig
CHANGED
Binary file
|