kettle-dev 1.2.0 → 1.2.1

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.
@@ -9,8 +9,6 @@ module Kettle
9
9
  module Dev
10
10
  # Helpers shared by kettle:dev Rake tasks for templating and file ops.
11
11
  module TemplateHelpers
12
- require "kettle/dev/appraisals_ast_merger"
13
-
14
12
  # Track results of templating actions across a single process run.
15
13
  # Keys: absolute destination paths (String)
16
14
  # Values: Hash with keys: :action (Symbol, one of :create, :replace, :skip, :dir_create, :dir_replace), :timestamp (Time)
@@ -21,7 +19,7 @@ module Kettle
21
19
  MIN_SETUP_RUBY = Gem::Version.create("2.3")
22
20
 
23
21
  TEMPLATE_MANIFEST_PATH = File.expand_path("../../..", __dir__) + "/template_manifest.yml"
24
- RUBY_BASENAMES = %w[Gemfile Rakefile Appraisals Appraisal.root.gemfile].freeze
22
+ RUBY_BASENAMES = %w[Gemfile Rakefile Appraisals Appraisal.root.gemfile .simplecov].freeze
25
23
  RUBY_SUFFIXES = %w[.gemspec .gemfile].freeze
26
24
  RUBY_EXTENSIONS = %w[.rb .rake].freeze
27
25
  @@manifestation = nil
@@ -279,13 +277,14 @@ module Kettle
279
277
 
280
278
  content = File.read(src_path)
281
279
  content = yield(content) if block_given?
282
- # Final global replacements that must occur AFTER normal replacements
280
+ # Replace the explicit template token with the literal "kettle-dev"
281
+ # after upstream/template-specific replacements (i.e. after the yield),
282
+ # so the token itself is not altered by those replacements.
283
283
  begin
284
284
  token = "{KETTLE|DEV|GEM}"
285
285
  content = content.gsub(token, "kettle-dev") if content.include?(token)
286
286
  rescue StandardError => e
287
287
  Kettle::Dev.debug_error(e, __method__)
288
- # If replacement fails unexpectedly, proceed with content as-is
289
288
  end
290
289
 
291
290
  basename = File.basename(dest_path.to_s)
@@ -323,114 +322,7 @@ module Kettle
323
322
  # @return [String] merged content
324
323
  def merge_gemfile_dependencies(src_content, dest_content)
325
324
  begin
326
- gem_re = /^\s*gem\s+['"]([^'"\s]+)['"].*$/
327
- # Collect first occurrence of each gem line in source
328
- src_gems = {}
329
- src_content.each_line do |ln|
330
- next if ln.strip.start_with?("#")
331
- if (m = ln.match(gem_re))
332
- name = m[1]
333
- src_gems[name] ||= ln.rstrip
334
- end
335
- end
336
-
337
- # --- Handle `source` replacement/insertion ---
338
- src_source_line = nil
339
- src_content.each_line do |ln|
340
- next if ln.strip.start_with?("#")
341
- if ln =~ /^\s*source\s+['"][^'"]+['"]\s*$/
342
- src_source_line = ln.rstrip + "\n"
343
- break
344
- end
345
- end
346
-
347
- dest_lines = dest_content.lines.dup
348
-
349
- if src_source_line
350
- dest_source_idx = dest_lines.index do |ln|
351
- !ln.strip.start_with?("#") && ln =~ /^\s*source\s+['"][^'"]+['"]\s*$/
352
- end
353
- if dest_source_idx
354
- dest_lines[dest_source_idx] = src_source_line
355
- else
356
- # Insert after any leading contiguous comment/blank block at top of file
357
- insert_idx = 0
358
- while insert_idx < dest_lines.length && (dest_lines[insert_idx].strip.empty? || dest_lines[insert_idx].lstrip.start_with?("#"))
359
- insert_idx += 1
360
- end
361
- dest_lines.insert(insert_idx, src_source_line)
362
- end
363
- end
364
-
365
- # --- Handle `git_source` replacement/insertion ---
366
- # Collect non-comment git_source lines from source (preserve order)
367
- src_git_lines = src_content.each_line.select { |ln| !ln.strip.start_with?("#") && ln =~ /^\s*git_source\s*\(/ }
368
- if src_git_lines.any?
369
- # Insert new git_source lines in the same order as they appear in the source
370
- # When inserting (not replacing), place them immediately after the source line if present
371
- insert_after_source_idx = dest_lines.index { |ln| !ln.strip.start_with?("#") && ln =~ /^\s*source\s+['"][^'"]+['"]\s*$/ }
372
-
373
- # Iterate source git lines in reverse for insertion so order is preserved when inserting at same index
374
- src_git_lines.reverse_each do |gln|
375
- # Attempt to extract the git_source "name" (handles forms like git_source(:github) or git_source :github)
376
- name_match = gln.match(/^\s*git_source\s*\(?\s*:?(\w+)\b/)
377
- name = name_match ? name_match[1].to_s : nil
378
-
379
- replaced = false
380
- if name
381
- # Try to find a git_source in destination with the same name
382
- dest_same_idx = dest_lines.index do |dln|
383
- !dln.strip.start_with?("#") && dln =~ /^\s*git_source\s*\(?\s*:?#{Regexp.escape(name)}\b/
384
- end
385
- if dest_same_idx
386
- dest_lines[dest_same_idx] = gln.rstrip + "\n"
387
- replaced = true
388
- end
389
- end
390
-
391
- unless replaced
392
- # If destination has a github git_source, replace that
393
- dest_github_idx = dest_lines.index do |dln|
394
- !dln.strip.start_with?("#") && dln =~ /^\s*git_source\s*\(?\s*:?github\b/
395
- end
396
- if dest_github_idx
397
- dest_lines[dest_github_idx] = gln.rstrip + "\n"
398
- else
399
- # Insert below the source line if present, otherwise at top (after comments)
400
- insert_idx =
401
- if insert_after_source_idx
402
- insert_after_source_idx + 1
403
- else
404
- 0
405
- end
406
- dest_lines.insert(insert_idx, gln.rstrip + "\n")
407
- end
408
- end
409
- end
410
- end
411
-
412
- # Index existing gems in destination (after potential source/git_source changes)
413
- dest_gems = {}
414
- dest_lines.join.each_line do |ln|
415
- next if ln.strip.start_with?("#")
416
- if (m = ln.match(gem_re))
417
- dest_gems[m[1]] = true
418
- end
419
- end
420
-
421
- missing = src_gems.keys.reject { |n| dest_gems.key?(n) }
422
- # If nothing to change, return original destination content
423
- if missing.empty? && src_source_line.nil? && src_git_lines.empty?
424
- return dest_content
425
- end
426
-
427
- out = dest_lines.join
428
- out << "\n" unless out.end_with?("\n") || out.empty?
429
- if missing.any?
430
- out << missing.map { |n| src_gems[n] }.join("\n")
431
- out << "\n"
432
- end
433
- out
325
+ Kettle::Dev::PrismGemfile.merge_gem_calls(src_content.to_s, dest_content.to_s)
434
326
  rescue StandardError => e
435
327
  Kettle::Dev.debug_error(e, __method__)
436
328
  dest_content
@@ -444,7 +336,7 @@ module Kettle
444
336
  else
445
337
  ""
446
338
  end
447
- Kettle::Dev::AppraisalsAstMerger.merge(content, existing)
339
+ Kettle::Dev::PrismAppraisals.merge(content, existing)
448
340
  rescue StandardError => e
449
341
  Kettle::Dev.debug_error(e, __method__)
450
342
  content
@@ -684,8 +576,8 @@ module Kettle
684
576
  # ignore
685
577
  end
686
578
 
687
- # Replace occurrences of the template gem name in text, including inside
688
- # markdown reference labels like [🖼️kettle-dev] and identifiers like kettle-dev-i
579
+ # Replace occurrences of the literal template gem name ("kettle-dev")
580
+ # with the destination gem name.
689
581
  c = c.gsub("kettle-dev", gem_name)
690
582
  c = c.gsub(/\bKettle::Dev\b/u, namespace) unless namespace.empty?
691
583
  c = c.gsub("Kettle%3A%3ADev", namespace_shield) unless namespace_shield.empty?
@@ -6,7 +6,7 @@ module Kettle
6
6
  module Version
7
7
  # The gem version.
8
8
  # @return [String]
9
- VERSION = "1.2.0"
9
+ VERSION = "1.2.1"
10
10
 
11
11
  module_function
12
12
 
data/lib/kettle/dev.rb CHANGED
@@ -22,6 +22,9 @@ module Kettle
22
22
  autoload :GitCommitFooter, "kettle/dev/git_commit_footer"
23
23
  autoload :InputAdapter, "kettle/dev/input_adapter"
24
24
  autoload :PrismUtils, "kettle/dev/prism_utils"
25
+ autoload :PrismGemspec, "kettle/dev/prism_gemspec"
26
+ autoload :PrismGemfile, "kettle/dev/prism_gemfile"
27
+ autoload :PrismAppraisals, "kettle/dev/prism_appraisals"
25
28
  autoload :ReadmeBackers, "kettle/dev/readme_backers"
26
29
  autoload :OpenCollectiveConfig, "kettle/dev/open_collective_config"
27
30
  autoload :SourceMerger, "kettle/dev/source_merger"
@@ -76,15 +79,30 @@ module Kettle
76
79
  @defaults = []
77
80
 
78
81
  class << self
79
- # Emit a debug warning for rescued errors when DEBUG=true.
82
+ # Emit a debug warning for rescued errors when kettle-dev debugging is enabled.
83
+ # Controlled by KETTLE_DEV_DEBUG=true (or DEBUG=true as fallback).
80
84
  # @param error [Exception]
81
85
  # @param context [String, Symbol, nil] optional label, often __method__
82
86
  # @return [void]
83
87
  def debug_error(error, context = nil)
84
88
  return unless DEBUGGING
85
- ctx = context ? context.to_s : "rescue"
89
+
90
+ ctx = context ? context.to_s : "KETTLE-DEV-RESCUE"
86
91
  Kernel.warn("[#{ctx}] #{error.class}: #{error.message}")
87
- rescue Exception
92
+ rescue StandardError
93
+ # never raise from debug logging
94
+ end
95
+
96
+ # Emit a debug log line when kettle-dev debugging is enabled.
97
+ # Controlled by KETTLE_DEV_DEBUG=true (or DEBUG=true as fallback).
98
+ # @param msg [String]
99
+ # @return [void]
100
+ def debug_log(msg, context = nil)
101
+ return unless DEBUGGING
102
+
103
+ ctx = context ? context.to_s : "KETTLE-DEV-DEBUG"
104
+ Kernel.warn("[#{ctx}] #{msg}")
105
+ rescue StandardError
88
106
  # never raise from debug logging
89
107
  end
90
108
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kettle-dev
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -340,7 +340,6 @@ files:
340
340
  - kettle-dev.gemspec.example
341
341
  - lib/kettle-dev.rb
342
342
  - lib/kettle/dev.rb
343
- - lib/kettle/dev/appraisals_ast_merger.rb
344
343
  - lib/kettle/dev/changelog_cli.rb
345
344
  - lib/kettle/dev/ci_helpers.rb
346
345
  - lib/kettle/dev/ci_monitor.rb
@@ -354,6 +353,9 @@ files:
354
353
  - lib/kettle/dev/modular_gemfiles.rb
355
354
  - lib/kettle/dev/open_collective_config.rb
356
355
  - lib/kettle/dev/pre_release_cli.rb
356
+ - lib/kettle/dev/prism_appraisals.rb
357
+ - lib/kettle/dev/prism_gemfile.rb
358
+ - lib/kettle/dev/prism_gemspec.rb
357
359
  - lib/kettle/dev/prism_utils.rb
358
360
  - lib/kettle/dev/rakelib/appraisal.rake
359
361
  - lib/kettle/dev/rakelib/bench.rake
@@ -412,10 +414,10 @@ licenses:
412
414
  - MIT
413
415
  metadata:
414
416
  homepage_uri: https://kettle-dev.galtzo.com/
415
- source_code_uri: https://github.com/kettle-rb/kettle-dev/tree/v1.2.0
416
- changelog_uri: https://github.com/kettle-rb/kettle-dev/blob/v1.2.0/CHANGELOG.md
417
+ source_code_uri: https://github.com/kettle-rb/kettle-dev/tree/v1.2.1
418
+ changelog_uri: https://github.com/kettle-rb/kettle-dev/blob/v1.2.1/CHANGELOG.md
417
419
  bug_tracker_uri: https://github.com/kettle-rb/kettle-dev/issues
418
- documentation_uri: https://www.rubydoc.info/gems/kettle-dev/1.2.0
420
+ documentation_uri: https://www.rubydoc.info/gems/kettle-dev/1.2.1
419
421
  funding_uri: https://github.com/sponsors/pboling
420
422
  wiki_uri: https://github.com/kettle-rb/kettle-dev/wiki
421
423
  news_uri: https://www.railsbling.com/tags/kettle-dev
metadata.gz.sig CHANGED
Binary file