bake-modernize 0.55.0 → 0.56.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9939ca760f8cf47d60abb88db42503d28cc787c4782f30832aa5ae6884c8a28
4
- data.tar.gz: 626c314ed2994774e8cd67c066adb35d6097bb4573bc2709916c75ddb38999cf
3
+ metadata.gz: 72c826add1a85728f5a9e846ac141702751534c42a6da1bfb083329f227f6fb9
4
+ data.tar.gz: 03ac882a8eda8640a3d0bf7f61c1943da4a2d9554b2663ce1505700919ee7316
5
5
  SHA512:
6
- metadata.gz: 9c50dddf6c5fa71a5616c6e02db2872eb2999199b2218ecfb13c9bddefccbb10455af9d640d488c4eb3098eb47544efc52487d3e4a2235ad520c95a459382656
7
- data.tar.gz: ba7279eeb3a720ba13242e4d5e5215bcaf2a1a5a1bdd4a6f5d93586aa42defb3cd6a85271ebf5ab9ab7011a9e678c1935ffad9ff0fa5f3629b51ae9d816828e4
6
+ metadata.gz: 75a0682fec79638ef77d82d8bedda20846d8c58e81927a9ce4a0808f8247d017ca2e6011a49430ddce35532449e0b0817ab53f5df6d70e27fc24a083b62e4275
7
+ data.tar.gz: fef03584ff96fb319b7fa937d4deb641c20a8f79a56ed2bd1e7a8beb2d13720a1a1750818a155eb9fb2af286f3168c7199549a5a8e7e851a5480935e70b10c9d
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2025, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
  require "rugged"
8
8
  require "markly"
9
9
  require "build/files/system"
10
10
 
11
- def actions
12
- update(root: Dir.pwd)
11
+ def actions(root: Dir.pwd)
12
+ update(root: root)
13
13
  end
14
14
 
15
15
  def update(root:)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023-2024, by Samuel Williams.
4
+ # Copyright, 2023-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
  require "markly"
@@ -2,12 +2,12 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2025, by Copilot.
5
- # Copyright, 2025, by Samuel Williams.
5
+ # Copyright, 2025-2026, by Samuel Williams.
6
6
 
7
7
  require "bake/modernize"
8
8
 
9
- def copilot
10
- update(root: Dir.pwd)
9
+ def copilot(root: Dir.pwd)
10
+ update(root: root)
11
11
  end
12
12
 
13
13
  def update(root:)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2025-2026, by Samuel Williams.
4
+ # Copyright, 2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
 
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
 
8
- def editorconfig
9
- update(root: Dir.pwd)
8
+ def editorconfig(root: Dir.pwd)
9
+ update(root: root)
10
10
  end
11
11
 
12
12
  def update(root:)
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
 
8
- def gemfile
9
- update(root: Dir.pwd)
8
+ def gemfile(root: Dir.pwd)
9
+ update(root: root)
10
10
  end
11
11
 
12
12
  def update(root:)
@@ -3,6 +3,8 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
+ require "bake/modernize"
7
+
6
8
  # Rewrite the current gemspec.
7
9
  def gemspec
8
10
  path = default_gemspec_path
@@ -24,18 +26,16 @@ def update(path: default_gemspec_path, output: $stdout)
24
26
  root = File.dirname(path)
25
27
  version_path = version_path(root, spec.name)
26
28
 
27
- constant = File.read(version_path)
29
+ constant = File.read(File.join(root, version_path))
28
30
  .scan(/(?:class|module)\s+(.*?)$/)
29
31
  .flatten
30
32
  .join("::")
31
33
 
32
34
  normalize_homepage(spec)
33
35
 
34
- spec.metadata["funding_uri"] ||= detect_funding_uri(spec)
35
- spec.metadata["documentation_uri"] ||= detect_documentation_uri(spec)
36
- spec.metadata["source_code_uri"] ||= detect_source_code_uri(spec)
36
+ update_metadata(spec)
37
37
 
38
- spec.authors = sorted_authors(Dir.pwd)
38
+ spec.authors = sorted_authors(root)
39
39
 
40
40
  spec.metadata.delete_if{|_, value| value.nil?}
41
41
 
@@ -104,7 +104,7 @@ def update(path: default_gemspec_path, output: $stdout)
104
104
 
105
105
  # Try to move development dependencies to `gems.rb`:
106
106
  if spec.development_dependencies.any?
107
- unless move_development_dependencies(spec.development_dependencies)
107
+ unless move_development_dependencies(spec.development_dependencies, root)
108
108
  output.puts "\t"
109
109
  spec.development_dependencies.sort.each do |dependency|
110
110
  output.puts "\tspec.add_development_dependency #{format_dependency(dependency)}"
@@ -199,14 +199,51 @@ end
199
199
 
200
200
  GITHUB_PROJECT = /github.com\/(?<account>.*?)\/(?<project>.*?)(\/|\Z)/
201
201
 
202
+ def update_metadata(spec)
203
+ spec.metadata["bug_tracker_uri"] ||= detect_bug_tracker_uri(spec)
204
+ spec.metadata["changelog_uri"] ||= detect_changelog_uri(spec)
205
+ spec.metadata["documentation_uri"] ||= detect_documentation_uri(spec)
206
+ spec.metadata["funding_uri"] ||= detect_funding_uri(spec)
207
+ spec.metadata["source_code_uri"] ||= detect_source_code_uri(spec)
208
+ end
209
+
202
210
  def normalize_homepage(spec)
203
211
  if homepage = spec.homepage
204
212
  spec.homepage = homepage.chomp("/")
205
213
  end
206
214
  end
207
215
 
216
+ def github_project(spec)
217
+ if homepage = spec.homepage
218
+ homepage.match(GITHUB_PROJECT)
219
+ end
220
+ end
221
+
222
+ def detect_bug_tracker_uri(spec)
223
+ if match = github_project(spec)
224
+ account = match[:account]
225
+ project = match[:project]
226
+
227
+ return "https://github.com/#{account}/#{project}/issues"
228
+ end
229
+ end
230
+
231
+ def detect_changelog_uri(spec)
232
+ if match = github_project(spec)
233
+ account = match[:account]
234
+ project = match[:project]
235
+ root = File.dirname(spec.loaded_from)
236
+
237
+ if File.exist?(File.expand_path("releases.md", root))
238
+ branch = Bake::Modernize::Git.current_branch(root, default: "main")
239
+
240
+ return "https://github.com/#{account}/#{project}/blob/#{branch}/releases.md"
241
+ end
242
+ end
243
+ end
244
+
208
245
  def detect_funding_uri(spec)
209
- if match = spec.homepage&.match(GITHUB_PROJECT)
246
+ if match = github_project(spec)
210
247
  account = match[:account]
211
248
 
212
249
  funding_uri = "https://github.com/sponsors/#{account}/"
@@ -218,7 +255,7 @@ def detect_funding_uri(spec)
218
255
  end
219
256
 
220
257
  def detect_documentation_uri(spec)
221
- if match = spec.homepage.match(GITHUB_PROJECT)
258
+ if match = github_project(spec)
222
259
  account = match[:account]
223
260
  project = match[:project]
224
261
 
@@ -231,7 +268,7 @@ def detect_documentation_uri(spec)
231
268
  end
232
269
 
233
270
  def detect_source_code_uri(spec)
234
- if match = spec.homepage.match(GITHUB_PROJECT)
271
+ if match = github_project(spec)
235
272
  account = match[:account]
236
273
  project = match[:project]
237
274
 
@@ -250,8 +287,8 @@ IGNORE_GEMS = %w[
250
287
  bundler
251
288
  ].freeze
252
289
 
253
- def move_development_dependencies(dependencies)
254
- gemfile_path = File.expand_path("gems.rb")
290
+ def move_development_dependencies(dependencies, root = Dir.pwd)
291
+ gemfile_path = File.expand_path("gems.rb", root)
255
292
 
256
293
  if File.exist?(gemfile_path)
257
294
  File.open(gemfile_path, "a") do |file|
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2024, by Samuel Williams.
4
+ # Copyright, 2021-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
 
8
- def git
9
- update(root: Dir.pwd)
8
+ def git(root: Dir.pwd)
9
+ update(root: root)
10
10
  end
11
11
 
12
12
  def update(root:)
13
- if current_branch == "master"
13
+ if Bake::Modernize::Git.current_branch(root, default: nil) == "master"
14
14
  # https://github.com/github/renaming
15
15
  system("git", "branch", "-M", "main")
16
16
  system("git", "push", "-u", "origin", "main")
@@ -42,15 +42,3 @@ def current_gitignore_custom_lines(root)
42
42
  end
43
43
  end
44
44
  end
45
-
46
- def current_branch
47
- require "open3"
48
-
49
- output, status = Open3.capture2("git", "branch", "--show-current")
50
-
51
- unless status.success?
52
- raise "Could not get current branch!"
53
- end
54
-
55
- return output
56
- end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2024, by Samuel Williams.
4
+ # Copyright, 2022-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
  require "markly"
@@ -27,8 +27,8 @@ SOFTWARE.
27
27
  LICENSE
28
28
 
29
29
  # @parameter root [String] The root directory to scan for changes.
30
- def license
31
- update(root: Dir.pwd)
30
+ def license(root: Dir.pwd)
31
+ update(root: root)
32
32
  end
33
33
 
34
34
  def update(root:)
@@ -121,4 +121,3 @@ def remove_license(readme_path)
121
121
 
122
122
  File.write(readme_path, root.to_markdown(width: 0))
123
123
  end
124
-
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2025, by Samuel Williams.
4
+ # Copyright, 2022-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
  require "build/files/system"
8
8
 
9
- def readme
10
- update(root: Dir.pwd)
9
+ def readme(root: Dir.pwd)
10
+ update(root: root)
11
11
  end
12
12
 
13
13
  def update(root:)
@@ -39,7 +39,7 @@ def update_releases(readme_path)
39
39
  if node
40
40
  node.append_before(replacement)
41
41
  else
42
- root.append(replacement)
42
+ root.last_child.append_after(replacement)
43
43
  end
44
44
 
45
45
  File.write(readme_path, root.to_markdown(width: 0))
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024-2025, by Samuel Williams.
4
+ # Copyright, 2024-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
  require "build/files/system"
8
8
 
9
- def rubocop
10
- update(root: Dir.pwd)
9
+ def rubocop(root: Dir.pwd)
10
+ update(root: root)
11
11
  end
12
12
 
13
13
  def update(root:)
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2024, by Samuel Williams.
4
+ # Copyright, 2021-2026, by Samuel Williams.
5
5
 
6
6
  require "bake/modernize"
7
7
 
8
- def signing
9
- update(root: Dir.pwd)
8
+ def signing(root: Dir.pwd)
9
+ update(root: root)
10
10
  end
11
11
 
12
12
  def update(root:)
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2026, by Samuel Williams.
5
+
6
+ require "rugged"
7
+
8
+ module Bake
9
+ module Modernize
10
+ # Utilities for inspecting git repositories.
11
+ module Git
12
+ # The current branch name for the repository at the given root.
13
+ def self.current_branch(root = Dir.pwd, default: nil)
14
+ begin
15
+ repository = Rugged::Repository.discover(root)
16
+ head = repository.head
17
+
18
+ if head.branch?
19
+ return head.name.delete_prefix("refs/heads/")
20
+ end
21
+ rescue Rugged::ReferenceError, Rugged::RepositoryError
22
+ end
23
+
24
+ return default
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2025, by Samuel Williams.
4
+ # Copyright, 2022-2026, by Samuel Williams.
5
5
 
6
6
  require "rugged"
7
7
  require "yaml"
@@ -173,14 +173,20 @@ module Bake
173
173
  class Authorship
174
174
  # Represents a modification to a file.
175
175
  Modification = Struct.new(:author, :time, :path, :id) do
176
+ # The full name of the author who made the modification.
177
+ # @returns [String] The author's display name.
176
178
  def full_name
177
179
  author[:name]
178
180
  end
179
181
 
182
+ # The stable key used to group modifications by commit or contribution.
183
+ # @returns [String] The modification key.
180
184
  def key
181
185
  self.id || "#{self.author[:email]}:#{self.time.iso8601}"
182
186
  end
183
187
 
188
+ # Convert the modification to a serializable hash.
189
+ # @returns [Hash] The modification data.
184
190
  def to_h
185
191
  {
186
192
  id: id,
@@ -193,10 +199,15 @@ module Bake
193
199
 
194
200
  # Represents the copyright for an author.
195
201
  Copyright = Struct.new(:dates, :author) do
202
+ # Compare copyrights by their dates and author.
203
+ # @parameter other [Copyright] The other copyright to compare.
204
+ # @returns [Integer] The comparison result.
196
205
  def <=> other
197
206
  self.to_a <=> other.to_a
198
207
  end
199
208
 
209
+ # Generate the copyright statement for the author.
210
+ # @returns [String] The formatted copyright statement.
200
211
  def statement
201
212
  years = self.dates.map(&:year).uniq
202
213
  period = author.end_with?(".") ? "" : "."
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Modernize
8
- VERSION = "0.55.0"
8
+ VERSION = "0.56.0"
9
9
  end
10
10
  end
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2025, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
+ require_relative "modernize/git"
6
7
  require_relative "modernize/license"
7
8
  require_relative "modernize/version"
8
9
 
data/readme.md CHANGED
@@ -42,6 +42,22 @@ We welcome contributions to this project.
42
42
  4. Push to the branch (`git push origin my-new-feature`).
43
43
  5. Create new Pull Request.
44
44
 
45
+ ### Running Tests
46
+
47
+ To run the test suite:
48
+
49
+ ``` shell
50
+ bundle exec sus
51
+ ```
52
+
53
+ ### Making Releases
54
+
55
+ To make a new release:
56
+
57
+ ``` shell
58
+ bundle exec bake gem:release:patch # or minor or major
59
+ ```
60
+
45
61
  ### Developer Certificate of Origin
46
62
 
47
63
  In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
@@ -14,7 +14,7 @@ jobs:
14
14
  runs-on: ubuntu-latest
15
15
 
16
16
  steps:
17
- - uses: actions/checkout@v6
17
+ - uses: actions/checkout@v7
18
18
  - uses: ruby/setup-ruby@v1
19
19
  with:
20
20
  ruby-version: ruby
@@ -24,7 +24,7 @@ jobs:
24
24
  runs-on: ubuntu-latest
25
25
 
26
26
  steps:
27
- - uses: actions/checkout@v6
27
+ - uses: actions/checkout@v7
28
28
 
29
29
  - uses: ruby/setup-ruby@v1
30
30
  with:
@@ -39,7 +39,7 @@ jobs:
39
39
  run: bundle exec bake utopia:project:static --force no
40
40
 
41
41
  - name: Upload documentation artifact
42
- uses: actions/upload-pages-artifact@v4
42
+ uses: actions/upload-pages-artifact@v5
43
43
  with:
44
44
  path: docs
45
45
 
@@ -54,4 +54,4 @@ jobs:
54
54
  steps:
55
55
  - name: Deploy to GitHub Pages
56
56
  id: deployment
57
- uses: actions/deploy-pages@v4
57
+ uses: actions/deploy-pages@v5
@@ -23,7 +23,7 @@ jobs:
23
23
  - ruby
24
24
 
25
25
  steps:
26
- - uses: actions/checkout@v6
26
+ - uses: actions/checkout@v7
27
27
  - uses: ruby/setup-ruby@v1
28
28
  with:
29
29
  ruby-version: ${{matrix.ruby}}
@@ -33,7 +33,7 @@ jobs:
33
33
  timeout-minutes: 5
34
34
  run: bundle exec bake test
35
35
 
36
- - uses: actions/upload-artifact@v5
36
+ - uses: actions/upload-artifact@v7
37
37
  with:
38
38
  include-hidden-files: true
39
39
  if-no-files-found: error
@@ -45,13 +45,13 @@ jobs:
45
45
  runs-on: ubuntu-latest
46
46
 
47
47
  steps:
48
- - uses: actions/checkout@v6
48
+ - uses: actions/checkout@v7
49
49
  - uses: ruby/setup-ruby@v1
50
50
  with:
51
51
  ruby-version: ruby
52
52
  bundler-cache: true
53
53
 
54
- - uses: actions/download-artifact@v6
54
+ - uses: actions/download-artifact@v8
55
55
 
56
56
  - name: Validate coverage
57
57
  timeout-minutes: 5
@@ -22,7 +22,7 @@ jobs:
22
22
  - "4.0"
23
23
 
24
24
  steps:
25
- - uses: actions/checkout@v6
25
+ - uses: actions/checkout@v7
26
26
  - uses: ruby/setup-ruby@v1
27
27
  with:
28
28
  ruby-version: ${{matrix.ruby}}
@@ -36,7 +36,7 @@ jobs:
36
36
  experimental: true
37
37
 
38
38
  steps:
39
- - uses: actions/checkout@v6
39
+ - uses: actions/checkout@v7
40
40
  - uses: ruby/setup-ruby@v1
41
41
  with:
42
42
  ruby-version: ${{matrix.ruby}}
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2026, by Samuel Williams.
5
+
3
6
  source "https://rubygems.org"
4
7
 
5
8
  gemspec
@@ -10,7 +10,7 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
 
12
12
  steps:
13
- - uses: actions/checkout@v6
13
+ - uses: actions/checkout@v7
14
14
  - uses: ruby/setup-ruby@v1
15
15
  with:
16
16
  ruby-version: ruby
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.55.0
4
+ version: 0.56.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -144,6 +144,7 @@ files:
144
144
  - bake/modernize/rubocop.rb
145
145
  - bake/modernize/signing.rb
146
146
  - lib/bake/modernize.rb
147
+ - lib/bake/modernize/git.rb
147
148
  - lib/bake/modernize/license.rb
148
149
  - lib/bake/modernize/version.rb
149
150
  - license.md
@@ -167,6 +168,8 @@ homepage: https://github.com/ioquatix/bake-modernize
167
168
  licenses:
168
169
  - MIT
169
170
  metadata:
171
+ bug_tracker_uri: https://github.com/ioquatix/bake-modernize/issues
172
+ changelog_uri: https://github.com/ioquatix/bake-modernize/blob/main/releases.md
170
173
  documentation_uri: https://ioquatix.github.io/bake-modernize/
171
174
  funding_uri: https://github.com/sponsors/ioquatix/
172
175
  source_code_uri: https://github.com/ioquatix/bake-modernize.git
@@ -184,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
187
  - !ruby/object:Gem::Version
185
188
  version: '0'
186
189
  requirements: []
187
- rubygems_version: 4.0.6
190
+ rubygems_version: 4.0.10
188
191
  specification_version: 4
189
192
  summary: Automatically modernize parts of your project/gem.
190
193
  test_files: []
metadata.gz.sig CHANGED
Binary file