bake-modernize 0.12.1 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da1f2384e6892b579a2eae081c45d20b3492909f430342ddccd22438561caa6d
4
- data.tar.gz: 7be7efceea7445e1eea88c67cc01793d1774630845278eeb86530bf4b9a6fbed
3
+ metadata.gz: a5383d60aadbc5f2385c81dd7a03fba4f571baee7f4286d9dfedca1eee1497a9
4
+ data.tar.gz: cc5e62ac4f60879e04d4f73530ca47cac892fd7baa05f31e4d8783ee5df6d0e0
5
5
  SHA512:
6
- metadata.gz: ec479b10faff649e5701e03f00bd398380836984557e1862348b7dc591fb2b94e546133218f12dfc8cd7be983b8d47014d2c31ca540c392d9cb060d95554dbc5
7
- data.tar.gz: 5c576a97c8491a1889468ff068d662a1b3f0effd0eb13a09a5a973b236fce1721fe3a94cd96511698b44c9f80fa8357dd8c3a43b08099d42effbc4b26be0d521
6
+ metadata.gz: 76f7fec9e1bae6e30ece5a08fbb88dc10904f8507d81eb86a45ff8b32d755b9ac6f44b3076662f450cfc724351b0146255648e68df7107fce560e3a284c88835
7
+ data.tar.gz: 869556c76b862400d67420e808b2ba94a85a78b3caf0924e6eb79bb883ecefb6e57ca2ce6f7ee8a79b1c9807107aaff059a9d70f8fb7430e19bb89da09f6dde3
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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
  require 'bake/modernize'
3
7
  require 'rugged'
@@ -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
  require 'bake/modernize'
3
7
 
@@ -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
  require 'bake/modernize'
3
7
 
@@ -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
 
@@ -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
@@ -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"
@@ -36,7 +40,7 @@ def update(root:)
36
40
  authors.map do |author, dates|
37
41
  years = dates.map(&:year).uniq
38
42
 
39
- buffer.puts "Copyright, #{years.join('-')}, by #{author}."
43
+ buffer.puts "Copyright, #{years.join('-')}, by #{author}. "
40
44
  end
41
45
 
42
46
  buffer.puts
@@ -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
@@ -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 'bake/modernize'
3
7
  require 'build/files/system'
@@ -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
 
data/bake/modernize.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
  def modernize
3
7
  call('modernize:git', 'modernize:readme', 'modernize:actions', 'modernize:editorconfig', 'modernize:gemfile', 'modernize:signing', 'modernize:gemspec', 'modernize:license')
@@ -1,25 +1,10 @@
1
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
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.12.1"
8
+ VERSION = "0.13.1"
24
9
  end
25
10
  end
@@ -1,22 +1,7 @@
1
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
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
@@ -0,0 +1,5 @@
1
+ /.bundle/
2
+ /pkg/
3
+ /gems.locked
4
+ /.covered.db
5
+ /external
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.12.1
4
+ version: 0.13.1
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-18 00:00:00.000000000 Z
41
+ date: 2022-08-25 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: async-http
@@ -141,11 +141,14 @@ files:
141
141
  - bake/modernize/signing.rb
142
142
  - lib/bake/modernize.rb
143
143
  - lib/bake/modernize/version.rb
144
+ - license.md
145
+ - readme.md
144
146
  - template/actions/.github/workflows/coverage.yaml
145
147
  - template/actions/.github/workflows/documentation.yaml
146
148
  - template/actions/.github/workflows/test-external.yaml
147
149
  - template/actions/.github/workflows/test.yaml
148
150
  - template/editorconfig/.editorconfig
151
+ - template/git/.gitignore
149
152
  - template/readme/README.md
150
153
  homepage: https://github.com/ioquatix/bake-modernize
151
154
  licenses:
metadata.gz.sig CHANGED
Binary file