bake-modernize 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -1
- data/bake/modernize/license.rb +1 -44
- data/lib/bake/modernize/license.rb +49 -0
- data/lib/bake/modernize/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -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: f1285a821430d0892953c2d45e86f8e5d11fe8d27d8212614ddb87914599370c
|
|
4
|
+
data.tar.gz: f1c4f3edb34b0bbecc4b5cada2286f2572173db3d168d21aa0fd8193dcb60b79
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f75c658d10774d709155f72b2933bcd818cad028d2cff2c80071b1b09f46e9caa3fccc82e3503d988d29d410dd08027887d4bba51d6ace5a5abd4931d2b08434
|
|
7
|
+
data.tar.gz: 35962d24b690a376da309acf3608817cee9340e1d330cf11a589153c445387e1a4e9e390d6b0836b021e5bb9f212878c7eb4a60bcdeedacb28fdce7ca23b0252
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'O�v���Ej6ޗZjR�XKy���ښK�ݖr���b4�$_op�2��&m^՝B����y�)�&~W�9y߭�x+�
|
|
2
|
+
�����������1�^a�u)�]��C�c�O'�)%�>����F7��߈�����H.��MU2�vri��}S⃯M�B����m0T��˦.���`���z�"�q��V1_5���B�?�g��!�3{���~��+�Q
|
|
3
|
+
d_��f1�#}u�j�T藯�����2 ���V�\m���
|
|
4
|
+
9G4֎P1ݨ�cL���B��;$휕B��_8�v_�������E���S@|�o��h�Ir��)����
|
data/bake/modernize/license.rb
CHANGED
|
@@ -66,50 +66,7 @@ private
|
|
|
66
66
|
|
|
67
67
|
def update_source_file_authors(authorship, path, modifications)
|
|
68
68
|
copyrights = authorship.copyrights_for_modifications(modifications)
|
|
69
|
-
|
|
70
|
-
input = File.readlines(path)
|
|
71
|
-
output = []
|
|
72
|
-
|
|
73
|
-
if input.first =~ /^\#!/
|
|
74
|
-
output.push input.shift
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Drop any old copyright statements.
|
|
78
|
-
while input.first =~ /Copyright/i
|
|
79
|
-
input.shift
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
if input.first =~ /^\#.*?\:/
|
|
83
|
-
output.push input.shift
|
|
84
|
-
if input.first.chomp.empty?
|
|
85
|
-
input.shift
|
|
86
|
-
end
|
|
87
|
-
output << "\n"
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Remove any existing license:
|
|
91
|
-
while input.first =~ /^#.*$/
|
|
92
|
-
input.shift
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# Remove any empty lines:
|
|
96
|
-
while input.first&.chomp&.empty?
|
|
97
|
-
input.shift
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
output << "# Released under the MIT License.\n"
|
|
101
|
-
|
|
102
|
-
copyrights.each do |copyright|
|
|
103
|
-
output << "# #{copyright.statement}\n"
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
output << "\n"
|
|
107
|
-
|
|
108
|
-
output.concat(input)
|
|
109
|
-
|
|
110
|
-
File.open(path, "w") do |file|
|
|
111
|
-
file.puts(output)
|
|
112
|
-
end
|
|
69
|
+
Bake::Modernize::License::SourceFile.update(path, copyrights: copyrights.map(&:statement))
|
|
113
70
|
end
|
|
114
71
|
|
|
115
72
|
def remove_license(readme_path)
|
|
@@ -12,6 +12,55 @@ module Bake
|
|
|
12
12
|
module License
|
|
13
13
|
GIT_BLAME_IGNORE_REVS = ".git-blame-ignore-revs"
|
|
14
14
|
|
|
15
|
+
# Updates Ruby source headers without removing documentation comments.
|
|
16
|
+
class SourceFile
|
|
17
|
+
MAGIC_COMMENT = /\A#\s*(?:-\*-\s*)?(?:coding|encoding|frozen_string_literal|warn_indent|shareable_constant_value)\s*[:=]/i
|
|
18
|
+
LICENSE_COMMENT = /\A#\s*(?:Released under\b|Copyright\b|SPDX-License-Identifier:)/i
|
|
19
|
+
|
|
20
|
+
# Replace the license and copyright header for a Ruby source file.
|
|
21
|
+
# @parameter path [String] The source file path.
|
|
22
|
+
# @parameter copyrights [Array(String)] The copyright statements to write.
|
|
23
|
+
def self.update(path, copyrights:)
|
|
24
|
+
input = File.readlines(path)
|
|
25
|
+
prefix = []
|
|
26
|
+
|
|
27
|
+
prefix << input.shift if input.first&.start_with?("#!")
|
|
28
|
+
while input.first&.match?(MAGIC_COMMENT)
|
|
29
|
+
prefix << input.shift
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Keep the complete leading comment block, removing only known license metadata.
|
|
33
|
+
documentation = []
|
|
34
|
+
while line = input.first
|
|
35
|
+
break unless line.match?(/\A\s*#/) || line.strip.empty?
|
|
36
|
+
|
|
37
|
+
input.shift
|
|
38
|
+
next if line.match?(LICENSE_COMMENT)
|
|
39
|
+
|
|
40
|
+
documentation << line
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
while documentation.first&.strip&.empty?
|
|
44
|
+
documentation.shift
|
|
45
|
+
end
|
|
46
|
+
while documentation.last&.strip&.empty?
|
|
47
|
+
documentation.pop
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
output = prefix.dup
|
|
51
|
+
output << "\n" if output.any?
|
|
52
|
+
output << "# Released under the MIT License.\n"
|
|
53
|
+
copyrights.each do |copyright|
|
|
54
|
+
output << "# #{copyright}\n"
|
|
55
|
+
end
|
|
56
|
+
output << "\n"
|
|
57
|
+
output.concat(documentation)
|
|
58
|
+
output.concat(input)
|
|
59
|
+
|
|
60
|
+
File.write(path, output.join)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
15
64
|
# Represents revisions to skip when analyzing authorship.
|
|
16
65
|
class SkipList
|
|
17
66
|
# Load the skip list from a directory.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|