bake-modernize 0.19.4 → 0.21.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: 97619ecf26d612765128d5d230c2ef3eaf1206672924340fc4d39b954fb9b57a
4
+ data.tar.gz: 6902a97b42d283fdd766bf9ed1da7fcc9d48b5a5aa99ccadb4b258ac4c3bcc97
5
5
  SHA512:
6
- metadata.gz: 4c8e52410842a30554ce66c7608a11462739223f413720191711aea72790f3dabfaac48fc28e9d8a5472656bcc7571cada3b022fae7ffb4ec21aae6737445079
7
- data.tar.gz: 55a756873973464dc566f9c35a2a55fe1232053b48f7e6ea1a7f8e3dbabac42f204d22edcfa5371be6d3f26b5c8b17edb230b02379ce24970657c7d366d7a636
6
+ metadata.gz: 0d40bb9823d62852a886c663d501b3834eadce9b81535a090d5b5641e59d9a8dab76896f38256bcd1afefdb20287428b616a402c4a3cc07da0e4dc333c3d3e38
7
+ data.tar.gz: 6a8e1e291023423f566ec76147f93aab94a63587f1596e2e44a6758458f092eb14663c11384f98deeaf5532d3a608d9248be782a1a8f5e519e996d9ed62bcbe8
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ def initialize(context)
7
+ super
8
+
9
+ require 'bake/modernize/license'
10
+ end
11
+
12
+ # Extract changes from a repository and generate a list of contributors.
13
+ # @parameter root [String] The root directory of the repository.
14
+ # @parameter paths [Array(String)] The paths to extract changes from.
15
+ def extract(root:, paths:)
16
+ authorship = Bake::Modernize::License::Authorship.new
17
+
18
+ authorship.extract(root)
19
+
20
+ modifications = []
21
+
22
+ paths.each do |path|
23
+ authorship.paths[path].each do |modification|
24
+ modification = modification.to_h
25
+
26
+ if modification[:path] != path
27
+ modification[:original_path] = modification[:path]
28
+ modification[:path] = path
29
+ end
30
+
31
+ modifications << modification
32
+ end
33
+ end
34
+
35
+ modifications.sort_by!{|modification| modification[:time]}
36
+
37
+ return modifications
38
+ end
39
+
40
+ # Map the changes to a new path.
41
+ # @parameter input [Array(Hash)] The list of changes.
42
+ # @parameter original_path [String] The original path of the changes.
43
+ # @parameter path [String] The path that now contains the content of the original changes.
44
+ def map(original_path, path, input:)
45
+ input.each do |modification|
46
+ if modification[:path] == original_path
47
+ modification[:original_path] = modification[:path]
48
+ modification[:path] = path
49
+ end
50
+ end
51
+
52
+ return input
53
+ end
@@ -14,7 +14,7 @@ def gemspec
14
14
  end
15
15
 
16
16
  # The latest end-of-life Ruby version.
17
- MINIMUM_RUBY_VERSION = ::Gem::Requirement.new(">= 3.0")
17
+ MINIMUM_RUBY_VERSION = ::Gem::Requirement.new(">= 3.1")
18
18
 
19
19
  # Rewrite the specified gemspec.
20
20
  # @param
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
5
 
6
6
  require 'rugged'
7
7
  require 'yaml'
@@ -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.21.0"
9
9
  end
10
10
  end
@@ -20,7 +20,6 @@ jobs:
20
20
  - macos
21
21
 
22
22
  ruby:
23
- - "3.0"
24
23
  - "3.1"
25
24
  - "3.2"
26
25
  - "3.3"
@@ -21,7 +21,6 @@ jobs:
21
21
  - macos
22
22
 
23
23
  ruby:
24
- - "3.0"
25
24
  - "3.1"
26
25
  - "3.2"
27
26
  - "3.3"
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.21.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-04-01 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
@@ -152,14 +153,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
153
  requirements:
153
154
  - - ">="
154
155
  - !ruby/object:Gem::Version
155
- version: '3.0'
156
+ version: '3.1'
156
157
  required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  requirements:
158
159
  - - ">="
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