bake-modernize 0.12.2 → 0.13.2
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 +4 -0
- data/bake/modernize/editorconfig.rb +4 -0
- data/bake/modernize/frozen_string_literal.rb +50 -0
- data/bake/modernize/gemfile.rb +4 -0
- data/bake/modernize/gemspec.rb +6 -2
- data/bake/modernize/git.rb +7 -0
- data/bake/modernize/license.rb +81 -15
- data/bake/modernize/readme.rb +4 -0
- data/bake/modernize/signing.rb +4 -0
- data/bake/modernize.rb +5 -1
- data/lib/bake/modernize/version.rb +5 -20
- data/lib/bake/modernize.rb +4 -19
- data/license.md +22 -0
- data/readme.md +23 -0
- data/template/git/.gitignore +5 -0
- data.tar.gz.sig +0 -0
- metadata +6 -2
- 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: bbf86cb6271ebbf9ed15d1909a86717bbbf62e8841c418a6f969899bece3ca76
|
4
|
+
data.tar.gz: 84836cfd97548092a8fe01144b94f7ffaff0c8aec0b81ecee02a8e23602c4d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb461c262b102a09ef679c786d2eb4aa219d4a1fd02f8c5c62ad6e28b405a8732322f08ee9276a95ec794a7afbba1ec48965d7407e93199385bfdee7664348c
|
7
|
+
data.tar.gz: 17fcdc0fb3d60ab8c71858c8f9b98732562bcb18842495426304f4a31fd6b518db86c0d98a8fa221ac35224f20442afae5b412392d2af81c9d5ef214c08b0350
|
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
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2020-2022, by Samuel Williams.
|
1
5
|
|
2
6
|
# Rewrite the current gemspec.
|
3
7
|
def gemspec
|
@@ -127,9 +131,9 @@ def directory_glob_for(spec, paths = spec.files)
|
|
127
131
|
end
|
128
132
|
|
129
133
|
if dotfiles
|
130
|
-
return "Dir.glob('{#{directories.keys.join(',')}}/**/*', File::FNM_DOTMATCH, base: __dir__)"
|
134
|
+
return "Dir.glob(['{#{directories.keys.join(',')}}/**/*', '*.md'], File::FNM_DOTMATCH, base: __dir__)"
|
131
135
|
else
|
132
|
-
return "Dir['{#{directories.keys.join(',')}}/**/*', base: __dir__]"
|
136
|
+
return "Dir['{#{directories.keys.join(',')}}/**/*', '*.md', base: __dir__]"
|
133
137
|
end
|
134
138
|
end
|
135
139
|
|
data/bake/modernize/git.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2021-2022, by Samuel Williams.
|
1
5
|
|
2
6
|
require 'bake/modernize'
|
3
7
|
|
@@ -11,6 +15,9 @@ def update(root:)
|
|
11
15
|
system("git", "branch", "-M", "main")
|
12
16
|
system("git", "push", "-u", "origin", "main")
|
13
17
|
end
|
18
|
+
|
19
|
+
template_root = Bake::Modernize.template_path_for('git')
|
20
|
+
Bake::Modernize.copy_template(template_root, root)
|
14
21
|
end
|
15
22
|
|
16
23
|
private
|
data/bake/modernize/license.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2022, by Samuel Williams.
|
1
5
|
|
2
6
|
require 'console'
|
3
7
|
|
@@ -27,7 +31,7 @@ def license
|
|
27
31
|
end
|
28
32
|
|
29
33
|
def update(root:)
|
30
|
-
authors = self.authors(root)
|
34
|
+
authors, paths = self.authors(root)
|
31
35
|
|
32
36
|
buffer = StringIO.new
|
33
37
|
buffer.puts "# MIT License"
|
@@ -45,51 +49,113 @@ def update(root:)
|
|
45
49
|
File.open("license.md", "w") do |file|
|
46
50
|
file.write(buffer.string)
|
47
51
|
end
|
52
|
+
|
53
|
+
paths.each do |path, authors|
|
54
|
+
next unless File.exist?(path)
|
55
|
+
|
56
|
+
case path
|
57
|
+
when /\.rb$/
|
58
|
+
self.update_source_file_authors(path, authors)
|
59
|
+
end
|
60
|
+
end
|
48
61
|
end
|
49
62
|
|
50
63
|
private
|
51
64
|
|
65
|
+
def update_source_file_authors(path, authors)
|
66
|
+
input = File.readlines(path)
|
67
|
+
output = []
|
68
|
+
|
69
|
+
if input.first =~ /^\#!/
|
70
|
+
output.push input.shift
|
71
|
+
end
|
72
|
+
|
73
|
+
if input.first =~ /^\#.*?\:/
|
74
|
+
output.push input.shift
|
75
|
+
if input.first.chomp.empty?
|
76
|
+
input.shift
|
77
|
+
end
|
78
|
+
output << "\n"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Remove any existing license:
|
82
|
+
while input.first =~ /^#.*$/
|
83
|
+
input.shift
|
84
|
+
end
|
85
|
+
|
86
|
+
# Remove any empty lines:
|
87
|
+
while input.first.chomp.empty?
|
88
|
+
input.shift
|
89
|
+
end
|
90
|
+
|
91
|
+
output << "# Released under the MIT License.\n"
|
92
|
+
|
93
|
+
authors.each do |author, dates|
|
94
|
+
years = dates.map(&:year).uniq
|
95
|
+
|
96
|
+
output << "# Copyright, #{years.join('-')}, by #{author}.\n"
|
97
|
+
end
|
98
|
+
|
99
|
+
output << "\n"
|
100
|
+
|
101
|
+
output.concat(input)
|
102
|
+
|
103
|
+
File.open(path, "w") do |file|
|
104
|
+
file.puts(output)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
52
108
|
def authors(root)
|
53
109
|
paths = {}
|
54
110
|
authors = {}
|
55
|
-
|
111
|
+
|
56
112
|
total = `git rev-list --count HEAD`.to_i
|
57
|
-
|
113
|
+
|
58
114
|
input, output = IO.pipe
|
59
115
|
pid = Process.spawn("git", "log", "--name-only", "--pretty=format:%ad\t%an", out: output, chdir: root)
|
60
|
-
|
116
|
+
|
61
117
|
output.close
|
62
|
-
|
118
|
+
|
63
119
|
progress = Console.logger.progress(self, total)
|
64
|
-
|
120
|
+
|
65
121
|
while header = (input.readline.chomp rescue nil)
|
66
122
|
break if header.empty?
|
67
123
|
progress.increment
|
68
|
-
|
124
|
+
|
69
125
|
date, author = header.split("\t", 2)
|
70
126
|
date = Date.parse(date)
|
71
|
-
|
127
|
+
|
72
128
|
while path = (input.readline.chomp rescue nil)
|
73
129
|
break if path.empty?
|
74
|
-
|
130
|
+
|
75
131
|
paths[path] ||= {}
|
76
132
|
paths[path][author] ||= []
|
77
133
|
paths[path][author] << date
|
78
|
-
|
134
|
+
|
79
135
|
authors[author] ||= []
|
80
136
|
authors[author] << date
|
81
137
|
end
|
82
138
|
end
|
83
|
-
|
139
|
+
|
84
140
|
input.close
|
85
141
|
Process.wait2(pid)
|
86
|
-
|
142
|
+
|
87
143
|
paths.each do |path, authors|
|
88
144
|
authors.transform_values! do |dates|
|
89
145
|
dates.minmax
|
90
146
|
end
|
91
147
|
end
|
92
|
-
|
148
|
+
|
149
|
+
paths.transform_values! do |authors|
|
150
|
+
authors.transform_values! do |dates|
|
151
|
+
dates.minmax
|
152
|
+
end
|
153
|
+
|
154
|
+
authors.sort_by do |author, dates|
|
155
|
+
dates
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
93
159
|
authors.transform_values! do |dates|
|
94
160
|
dates.minmax
|
95
161
|
end
|
@@ -99,6 +165,6 @@ def authors(root)
|
|
99
165
|
authors.sort_by! do |author, dates|
|
100
166
|
dates
|
101
167
|
end
|
102
|
-
|
103
|
-
return authors
|
168
|
+
|
169
|
+
return authors, paths
|
104
170
|
end
|
data/bake/modernize/readme.rb
CHANGED
data/bake/modernize/signing.rb
CHANGED
data/bake/modernize.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2020-2022, by Samuel Williams.
|
1
5
|
|
2
6
|
def modernize
|
3
|
-
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')
|
4
8
|
end
|
@@ -1,25 +1,10 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2020-2022, by Samuel Williams.
|
20
5
|
|
21
6
|
module Bake
|
22
7
|
module Modernize
|
23
|
-
VERSION = "0.
|
8
|
+
VERSION = "0.13.2"
|
24
9
|
end
|
25
10
|
end
|
data/lib/bake/modernize.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2020-2022, by Samuel Williams.
|
20
5
|
|
21
6
|
require "bake/modernize/version"
|
22
7
|
require 'build/files/glob'
|
data/license.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2020-2022, by Samuel Williams.
|
4
|
+
Copyright, 2021-2022, by Olle Jonsson.
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Bake Modernize
|
2
|
+
|
3
|
+
A gem for modernizing files in your Ruby project.
|
4
|
+
|
5
|
+
[![Development Status](https://github.com/ioquatix/bake-modernize/workflows/Test/badge.svg)](https://github.com/ioquatix/bake-modernize/actions?workflow=Test)
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Ensure your project is backed up (e.g. using git).
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
$ bake modernize
|
13
|
+
```
|
14
|
+
|
15
|
+
It will modernize your project.
|
16
|
+
|
17
|
+
## Contributing
|
18
|
+
|
19
|
+
1. Fork it
|
20
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
21
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
22
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
23
|
+
5. Create new Pull Request
|
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.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
40
|
-----END CERTIFICATE-----
|
41
|
-
date: 2022-08-
|
41
|
+
date: 2022-08-25 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: async-http
|
@@ -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
|
@@ -141,11 +142,14 @@ files:
|
|
141
142
|
- bake/modernize/signing.rb
|
142
143
|
- lib/bake/modernize.rb
|
143
144
|
- lib/bake/modernize/version.rb
|
145
|
+
- license.md
|
146
|
+
- readme.md
|
144
147
|
- template/actions/.github/workflows/coverage.yaml
|
145
148
|
- template/actions/.github/workflows/documentation.yaml
|
146
149
|
- template/actions/.github/workflows/test-external.yaml
|
147
150
|
- template/actions/.github/workflows/test.yaml
|
148
151
|
- template/editorconfig/.editorconfig
|
152
|
+
- template/git/.gitignore
|
149
153
|
- template/readme/README.md
|
150
154
|
homepage: https://github.com/ioquatix/bake-modernize
|
151
155
|
licenses:
|
metadata.gz.sig
CHANGED
Binary file
|