bake-modernize 0.12.2 → 0.13.0

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: 8708852628f7fe5a80eb8a171632b94365fb5e69d6055ae1030fa592f063f2ba
4
- data.tar.gz: ab6f411c37a31334ac3a1782cfa984b71ffece573872db866f46958d42eb9bb2
3
+ metadata.gz: 507d880a18b755b2e592bc82796792b377f68bd30d4484642649be42c35d8d78
4
+ data.tar.gz: 15ce7824eba5fe510de11b18debe80ebc216d5c3a744629345c799725768f3cd
5
5
  SHA512:
6
- metadata.gz: 1ad1b00641f494861f974cfda466c02d6b09ccdf388f3082751d90778ee950d8c4ab6a1b9f75c858d90d1445939701a2ceac3734b4fd4b5fe905ef4d29e44123
7
- data.tar.gz: 9ba24cbe9ae2a669c60397e98c147e4583c8c701bb2b33512aebba951e82bb1e3144e3fa2095215be561088708495aaedae21f478cc62036fd9cdd5dc0657ce3
6
+ metadata.gz: 77db80d99def59dd5b9c84232a466bc22f44b2c150df7817258bfa1c7304fb44e92678fe7079dddef6a17b276873bc41cdb7fd341d0641149c65182ef541c79c
7
+ data.tar.gz: 8396c9466c40041b44b71f1a00da695c006084fd5b86d75ccd1491872dd7160a2e34c6b36da9d62d2339397f7632fbe47f639306d60a8cdbbff97802cd62b6ca
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2020-2022, by Samuel Williams.
1
3
 
2
4
  require 'bake/modernize'
3
5
  require 'rugged'
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2020, by Samuel Williams.
1
3
 
2
4
  require 'bake/modernize'
3
5
 
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2020, by Samuel Williams.
1
3
 
2
4
  require 'bake/modernize'
3
5
 
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2020-2022, by Samuel Williams.
1
3
 
2
4
  # Rewrite the current gemspec.
3
5
  def gemspec
@@ -127,9 +129,9 @@ def directory_glob_for(spec, paths = spec.files)
127
129
  end
128
130
 
129
131
  if dotfiles
130
- return "Dir.glob('{#{directories.keys.join(',')}}/**/*', File::FNM_DOTMATCH, base: __dir__)"
132
+ return "Dir.glob(['{#{directories.keys.join(',')}}/**/*', '*.md'], File::FNM_DOTMATCH, base: __dir__)"
131
133
  else
132
- return "Dir['{#{directories.keys.join(',')}}/**/*', base: __dir__]"
134
+ return "Dir['{#{directories.keys.join(',')}}/**/*', '*.md', base: __dir__]"
133
135
  end
134
136
  end
135
137
 
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2021, by Samuel Williams.
1
3
 
2
4
  require 'bake/modernize'
3
5
 
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2022, by Samuel Williams.
1
3
 
2
4
  require 'console'
3
5
 
@@ -27,7 +29,7 @@ def license
27
29
  end
28
30
 
29
31
  def update(root:)
30
- authors = self.authors(root)
32
+ authors, paths = self.authors(root)
31
33
 
32
34
  buffer = StringIO.new
33
35
  buffer.puts "# MIT License"
@@ -45,51 +47,103 @@ def update(root:)
45
47
  File.open("license.md", "w") do |file|
46
48
  file.write(buffer.string)
47
49
  end
50
+
51
+ paths.each do |path, authors|
52
+ case path
53
+ when /\.rb$/
54
+ self.update_source_file_authors(path, authors)
55
+ end
56
+ end
48
57
  end
49
58
 
50
59
  private
51
60
 
61
+ def update_source_file_authors(path, authors)
62
+ input = File.readlines(path)
63
+ output = []
64
+
65
+ if input =~ /^\#!/
66
+ output.push input.shift
67
+ end
68
+
69
+ # Remove any existing license:
70
+ while input.first =~ /^#.*$/
71
+ input.shift
72
+ end
73
+
74
+ # Remove any empty lines:
75
+ while input.first.chomp.empty?
76
+ input.shift
77
+ end
78
+
79
+ output << "# Released under the MIT License.\n"
80
+
81
+ authors.each do |author, dates|
82
+ years = dates.map(&:year).uniq
83
+
84
+ output << "# Copyright, #{years.join('-')}, by #{author}.\n"
85
+ end
86
+
87
+ output << "\n"
88
+
89
+ output.concat(input)
90
+
91
+ File.open(path, "w") do |file|
92
+ file.puts(output)
93
+ end
94
+ end
95
+
52
96
  def authors(root)
53
97
  paths = {}
54
98
  authors = {}
55
-
99
+
56
100
  total = `git rev-list --count HEAD`.to_i
57
-
101
+
58
102
  input, output = IO.pipe
59
103
  pid = Process.spawn("git", "log", "--name-only", "--pretty=format:%ad\t%an", out: output, chdir: root)
60
-
104
+
61
105
  output.close
62
-
106
+
63
107
  progress = Console.logger.progress(self, total)
64
-
108
+
65
109
  while header = (input.readline.chomp rescue nil)
66
110
  break if header.empty?
67
111
  progress.increment
68
-
112
+
69
113
  date, author = header.split("\t", 2)
70
114
  date = Date.parse(date)
71
-
115
+
72
116
  while path = (input.readline.chomp rescue nil)
73
117
  break if path.empty?
74
-
118
+
75
119
  paths[path] ||= {}
76
120
  paths[path][author] ||= []
77
121
  paths[path][author] << date
78
-
122
+
79
123
  authors[author] ||= []
80
124
  authors[author] << date
81
125
  end
82
126
  end
83
-
127
+
84
128
  input.close
85
129
  Process.wait2(pid)
86
-
130
+
87
131
  paths.each do |path, authors|
88
132
  authors.transform_values! do |dates|
89
133
  dates.minmax
90
134
  end
91
135
  end
92
-
136
+
137
+ paths.transform_values! do |authors|
138
+ authors.transform_values! do |dates|
139
+ dates.minmax
140
+ end
141
+
142
+ authors.sort_by do |author, dates|
143
+ dates
144
+ end
145
+ end
146
+
93
147
  authors.transform_values! do |dates|
94
148
  dates.minmax
95
149
  end
@@ -99,6 +153,6 @@ def authors(root)
99
153
  authors.sort_by! do |author, dates|
100
154
  dates
101
155
  end
102
-
103
- return authors
156
+
157
+ return authors, paths
104
158
  end
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2022, by Samuel Williams.
1
3
 
2
4
  require 'bake/modernize'
3
5
  require 'build/files/system'
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2021, by Samuel Williams.
1
3
 
2
4
  require 'bake/modernize'
3
5
 
data/bake/modernize.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2020-2022, by Samuel Williams.
1
3
 
2
4
  def modernize
3
5
  call('modernize:git', 'modernize:readme', 'modernize:actions', 'modernize:editorconfig', 'modernize:gemfile', 'modernize:signing', 'modernize:gemspec', 'modernize:license')
@@ -1,25 +1,8 @@
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
+ # Released under the MIT License.
2
+ # Copyright, 2020-2022, by Samuel Williams.
20
3
 
21
4
  module Bake
22
5
  module Modernize
23
- VERSION = "0.12.2"
6
+ VERSION = "0.13.0"
24
7
  end
25
8
  end
@@ -1,22 +1,5 @@
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
+ # Released under the MIT License.
2
+ # Copyright, 2020, by Samuel Williams.
20
3
 
21
4
  require "bake/modernize/version"
22
5
  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.12.2
4
+ version: 0.13.0
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,6 +141,8 @@ 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
metadata.gz.sig CHANGED
Binary file