bake-modernize 0.19.4 → 0.20.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: '090227967d7ffd1c1ba5dbc2b745e540c8a0d0a23f618714fb34bfbc1828cfbc'
4
- data.tar.gz: c8558fa61980e1e94195719f5f5187f31bf257d271dc130064bd87b2b03697ef
3
+ metadata.gz: 7b4eaae979057c6dc2d0d0bb879bb9e5e3db8545526f7ffb8c375a2c7ac2914a
4
+ data.tar.gz: 797096a0d6dff79f1c4e305dccb90948fdad827ee026fd8cd06712ad5eb83a37
5
5
  SHA512:
6
- metadata.gz: 4c8e52410842a30554ce66c7608a11462739223f413720191711aea72790f3dabfaac48fc28e9d8a5472656bcc7571cada3b022fae7ffb4ec21aae6737445079
7
- data.tar.gz: 55a756873973464dc566f9c35a2a55fe1232053b48f7e6ea1a7f8e3dbabac42f204d22edcfa5371be6d3f26b5c8b17edb230b02379ce24970657c7d366d7a636
6
+ metadata.gz: 397e4885a47e5a656c0462cfa4be745dd5d164c4e22efc40bc83503fcad60efc3e0aa714c46ca264ebf21438d60ec3c8eb6a59c440a79ae370b2a9292c2f5d99
7
+ data.tar.gz: 9453fbdd2718fe185d13a304e50ef39b3f92195d37405d31f417daf437587046e65c7b01fdc8e7a388eb4522742e7b2ed5d9e77074644b9e0a550d6b67ca3428
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ def initialize(context)
4
+ super
5
+
6
+ require 'bake/modernize/license'
7
+ end
8
+
9
+ # Extract changes from a repository and generate a list of contributors.
10
+ # @parameter root [String] The root directory of the repository.
11
+ # @parameter paths [Array(String)] The paths to extract changes from.
12
+ def extract(root:, paths:)
13
+ authorship = Bake::Modernize::License::Authorship.new
14
+
15
+ authorship.extract(root)
16
+
17
+ modifications = []
18
+
19
+ paths.each do |path|
20
+ authorship.paths[path].each do |modification|
21
+ modification = modification.to_h
22
+
23
+ if modification[:path] != path
24
+ modification[:original_path] = modification[:path]
25
+ modification[:path] = path
26
+ end
27
+
28
+ modifications << modification
29
+ end
30
+ end
31
+
32
+ modifications.sort_by!{|modification| modification[:time]}
33
+
34
+ return modifications
35
+ end
36
+
37
+ # Map the changes to a new path.
38
+ # @parameter input [Array(Hash)] The list of changes.
39
+ # @parameter original_path [String] The original path of the changes.
40
+ # @parameter path [String] The path that now contains the content of the original changes.
41
+ def map(original_path, path, input:)
42
+ input.each do |modification|
43
+ if modification[:path] == original_path
44
+ modification[:original_path] = modification[:path]
45
+ modification[:path] = path
46
+ end
47
+ end
48
+
49
+ return input
50
+ end
@@ -89,7 +89,8 @@ module Bake
89
89
  line.match(PATTERN)
90
90
  end
91
91
  end
92
-
92
+
93
+ # Extract contributors from a YAML file which can be generated from another repository.
93
94
  class Contributors
94
95
  # The default path is the root of the repository and for authors who have contributed to the entire repository or unspecified paths in the past.
95
96
  DEFAULT_PATH = '.'
@@ -110,15 +111,32 @@ module Bake
110
111
 
111
112
  def each(&block)
112
113
  @contributions.each do |contribution|
113
- yield (contribution[:path] || DEFAULT_PATH), contribution[:author], contribution[:time]
114
+ author = contribution[:author]
115
+ time = contribution[:time]
116
+
117
+ paths_for(contribution) do |path|
118
+ yield path, author, time
119
+ end
114
120
  end
115
121
  end
116
122
 
117
123
  def extract(path)
118
124
  @contributions.concat(
119
- YAML.load_file(path, aliases: true, symbolize_names: true, permitted_classes: [Date, Time])
125
+ YAML.load_file(path, aliases: true, symbolize_names: true, permitted_classes: [Symbol, Date, Time])
120
126
  )
121
127
  end
128
+
129
+ def paths_for(contribution)
130
+ if path = contribution[:path]
131
+ yield path
132
+ # elsif paths = contribution[:paths]
133
+ # paths.each do |path|
134
+ # yield path
135
+ # end
136
+ else
137
+ yield DEFAULT_PATH
138
+ end
139
+ end
122
140
  end
123
141
 
124
142
  class Authorship
@@ -130,6 +148,15 @@ module Bake
130
148
  def key
131
149
  self.id || "#{self.author[:email]}:#{self.time.iso8601}"
132
150
  end
151
+
152
+ def to_h
153
+ {
154
+ id: id,
155
+ time: time,
156
+ path: path,
157
+ author: author,
158
+ }
159
+ end
133
160
  end
134
161
 
135
162
  Copyright = Struct.new(:dates, :author) do
@@ -149,6 +176,7 @@ module Bake
149
176
  end
150
177
 
151
178
  attr :paths
179
+ attr :commits
152
180
 
153
181
  def add(path, author, time, id = nil)
154
182
  modification = Modification.new(author, time, path, id)
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Modernize
8
- VERSION = "0.19.4"
8
+ VERSION = "0.20.0"
9
9
  end
10
10
  end
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.19.4
4
+ version: 0.20.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: 2024-01-26 00:00:00.000000000 Z
41
+ date: 2024-03-10 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: async-http
@@ -119,6 +119,7 @@ files:
119
119
  - bake/modernize.rb
120
120
  - bake/modernize/actions.rb
121
121
  - bake/modernize/contributing.rb
122
+ - bake/modernize/contributors.rb
122
123
  - bake/modernize/editorconfig.rb
123
124
  - bake/modernize/frozen_string_literal.rb
124
125
  - bake/modernize/gemfile.rb
@@ -159,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
160
  - !ruby/object:Gem::Version
160
161
  version: '0'
161
162
  requirements: []
162
- rubygems_version: 3.5.5
163
+ rubygems_version: 3.5.3
163
164
  signing_key:
164
165
  specification_version: 4
165
166
  summary: Automatically modernize parts of your project/gem.
metadata.gz.sig CHANGED
Binary file