bake-modernize 0.19.3 → 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: 36a85f0270238bb56f8145a0e902b808c2fbce99d79bd0eecddf68c8270517ac
4
- data.tar.gz: '029fb7ad9f8c41e0e660f93b9b2e4dacf716e5870afc284ac5ba5f09c79d2d09'
3
+ metadata.gz: 7b4eaae979057c6dc2d0d0bb879bb9e5e3db8545526f7ffb8c375a2c7ac2914a
4
+ data.tar.gz: 797096a0d6dff79f1c4e305dccb90948fdad827ee026fd8cd06712ad5eb83a37
5
5
  SHA512:
6
- metadata.gz: 2b9d1a410a97732b0cb8db844e7f5be71bc7d8c1d4a95afcf7a1d6a9a92db64dd0c58b26f160331779473780d65489b0783aa415fb225b7ca83b817a309d83cc
7
- data.tar.gz: cc9876b273f3097712264b98eef66057977824c36e98372ec9926749dfa8dfe6bc70e5daf9979e36a04a4051694232a98b402a7b7ff9c4c7b3e991f0dabba995
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)
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2023, by Samuel Williams.
4
+ # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
6
  module Bake
7
7
  module Modernize
8
- VERSION = "0.19.3"
8
+ VERSION = "0.20.0"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2020-2023, by Samuel Williams.
3
+ Copyright, 2020-2024, by Samuel Williams.
4
4
  Copyright, 2021-2023, by Olle Jonsson.
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -5,9 +5,6 @@ on:
5
5
  branches:
6
6
  - main
7
7
 
8
- # Allows you to run this workflow manually from the Actions tab:
9
- workflow_dispatch:
10
-
11
8
  # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages:
12
9
  permissions:
13
10
  contents: read
data.tar.gz.sig CHANGED
@@ -1 +1,3 @@
1
- yh�]�91uI �Q_H�wqI� �ޕ�z �,��<L^�#+~UarO���C �~����8�*|gx��xdC��#]h�g���d�lO8e)෌�n&�"IR�����K��+<�{���W&��8X;�+@5Z.�%*�ƙ0V��(d�4*K[r 3L���"1H|�<�M������3�"B����*b�E�ɜ����/0�Li�&��܃�w����&��߅�T�ц�p�d�[��?�^k=�/�.�gc����-HL�=��2�U.�v�_��kg�䯦7�RM<�Q�50��VR�U�^�a֑��Bg��p��bE�z�� Q�s/�=>�fw�/c�Eݑ��9k�6Odb�_Z⒛d���n_�j���q����Fl,7*&�_0�ߟC+
1
+ T=@p-L��ނ��|kq��ؚܷڣ������2��5��B{t���5av��3
2
+ �>�p65�ʦzi��-Z����#���]0��+�t&5���O���]"?���54�s�����%[L�ߔ�!�����R3l��� 79n��)�!��|$3{�b��i��"� ?<�}��&]�wP|w�[�|�p�̊#����&
3
+ j&pk����%Z����vj��������s@@�*'^�i�SUN���9B���[��)�5/><i�K�e�L^�?���²��Q�m��څ�8�h�y�_�i�����x�X@�>�z9�$ịs��_Q���i��݋T �#�<� fS�"�RRzY��
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.3
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-03 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.4.22
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