ast-template 7.1.22 → 8.0.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.
data/lib/ast/template.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'fileutils'
4
- require 'ast/merge'
5
- require_relative 'template/version'
3
+ require "fileutils"
4
+ require "ast/merge"
5
+ require_relative "template/version"
6
6
 
7
7
  module Ast
8
8
  module Template
@@ -20,16 +20,16 @@ module Ast
20
20
  SESSION_INVOCATION_TRANSPORT_VERSION = 1
21
21
  README_FAMILY_LANGUAGE_ORDER = %w[go ruby rust typescript].freeze
22
22
  README_FAMILY_LANGUAGE_LABELS = {
23
- 'go' => 'Go',
24
- 'ruby' => 'Ruby',
25
- 'rust' => 'Rust',
26
- 'typescript' => 'TypeScript'
23
+ "go" => "Go",
24
+ "ruby" => "Ruby",
25
+ "rust" => "Rust",
26
+ "typescript" => "TypeScript"
27
27
  }.freeze
28
- autoload :FileTypes, 'ast/template/file_types'
29
- autoload :MergeDispatch, 'ast/template/merge_dispatch'
30
- autoload :RustHostProvider, 'ast/template/rust_host_provider'
31
- autoload :Strategies, 'ast/template/strategies'
32
- autoload :TokenApplication, 'ast/template/token_application'
28
+ autoload :FileTypes, "ast/template/file_types"
29
+ autoload :MergeDispatch, "ast/template/merge_dispatch"
30
+ autoload :RustHostProvider, "ast/template/rust_host_provider"
31
+ autoload :Strategies, "ast/template/strategies"
32
+ autoload :TokenApplication, "ast/template/token_application"
33
33
 
34
34
  class << self
35
35
  def rust_host_provider
@@ -40,8 +40,8 @@ module Ast
40
40
  self_id = self_language.to_s
41
41
  alternatives = language_order.map(&:to_s).reject { |language| language == self_id }
42
42
  aliases = {
43
- 'SELF_LANG' => README_FAMILY_LANGUAGE_LABELS.fetch(self_id, self_id),
44
- 'SELF_LANG_ID' => self_id
43
+ "SELF_LANG" => README_FAMILY_LANGUAGE_LABELS.fetch(self_id, self_id),
44
+ "SELF_LANG_ID" => self_id
45
45
  }
46
46
  alternatives.each_with_index do |language, index|
47
47
  alias_prefix = "IMP_LANG#{index + 1}"
@@ -61,10 +61,10 @@ module Ast
61
61
  end
62
62
  aliases = readme_family_language_aliases(self_id)
63
63
  tokens = {
64
- 'FAMILY_SECTION_HEADING' => family[:section_heading].to_s,
65
- 'FAMILY_DESCRIPTION' => family[:description].to_s,
66
- 'SELF_PACKAGE_ROOT' => self_entry[:package_root].to_s,
67
- 'SELF_PACKAGE_MANAGER' => self_entry[:package_manager].to_s
64
+ "FAMILY_SECTION_HEADING" => family[:section_heading].to_s,
65
+ "FAMILY_DESCRIPTION" => family[:description].to_s,
66
+ "SELF_PACKAGE_ROOT" => self_entry[:package_root].to_s,
67
+ "SELF_PACKAGE_MANAGER" => self_entry[:package_manager].to_s
68
68
  }.merge(aliases)
69
69
 
70
70
  README_FAMILY_LANGUAGE_ORDER.reject { |language| language == self_id }.each_with_index do |language, index|
@@ -83,15 +83,15 @@ module Ast
83
83
  end
84
84
 
85
85
  def apply_readme_family_section(template_partial, package_metadata, family_metadata, destination_content,
86
- config = nil)
86
+ config = nil)
87
87
  package_entry = Ast::Merge.normalize_value(package_metadata || {})
88
88
  family = Ast::Merge.normalize_value(family_metadata || {})
89
89
  rendered_section = render_readme_family_section(template_partial, family, config).rstrip
90
90
  base_content = if destination_content.nil?
91
- "# #{package_entry[:name]}\n\n#{package_entry[:summary]}\n"
92
- else
93
- destination_content.to_s
94
- end
91
+ "# #{package_entry[:name]}\n\n#{package_entry[:summary]}\n"
92
+ else
93
+ destination_content.to_s
94
+ end
95
95
  content = replace_or_insert_markdown_heading_section(
96
96
  base_content,
97
97
  family[:section_heading].to_s,
@@ -114,14 +114,14 @@ module Ast
114
114
 
115
115
  def run_readme_family_section_command(command, config = nil)
116
116
  normalized = Ast::Merge.normalize_value(command || {})
117
- mode = normalized.fetch(:mode, 'plan').to_s
117
+ mode = normalized.fetch(:mode, "plan").to_s
118
118
  write_changes = %w[apply reapply].include?(mode)
119
119
  {
120
- profile_name: normalized.fetch(:profile_name, '').to_s,
120
+ profile_name: normalized.fetch(:profile_name, "").to_s,
121
121
  mode: mode,
122
122
  runner: run_readme_family_sections_for_package_directories(
123
- normalized.fetch(:root, '').to_s,
124
- normalized.fetch(:template_partial, '').to_s,
123
+ normalized.fetch(:root, "").to_s,
124
+ normalized.fetch(:template_partial, "").to_s,
125
125
  Array(normalized[:packages]),
126
126
  write_changes,
127
127
  config
@@ -130,7 +130,7 @@ module Ast
130
130
  end
131
131
 
132
132
  def run_readme_family_sections_for_package_directories(root, template_partial, packages, write_changes,
133
- config = nil)
133
+ config = nil)
134
134
  report = {
135
135
  package_count: packages.length,
136
136
  changed_count: 0,
@@ -140,7 +140,7 @@ module Ast
140
140
  packages.each do |package_entry|
141
141
  normalized_entry = Ast::Merge.normalize_value(package_entry)
142
142
  readme_path = normalized_entry.fetch(:readme_path).to_s
143
- full_path = File.join(root.to_s, readme_path.split('/'))
143
+ full_path = File.join(root.to_s, readme_path.split("/"))
144
144
  created = !File.exist?(full_path)
145
145
  destination_content = created ? nil : File.read(full_path)
146
146
  application = apply_readme_family_section(
@@ -169,14 +169,14 @@ module Ast
169
169
  end
170
170
 
171
171
  def merge_prepared_content_from_registry(registry, entry)
172
- family = entry.dig(:classification, :family) || entry.dig('classification', 'family')
172
+ family = entry.dig(:classification, :family) || entry.dig("classification", "family")
173
173
  adapter = registry[family.to_s]
174
174
  unless adapter
175
175
  return {
176
176
  ok: false,
177
177
  diagnostics: [{
178
- severity: 'error',
179
- category: 'configuration_error',
178
+ severity: "error",
179
+ category: "configuration_error",
180
180
  message: "missing family adapter for #{family}"
181
181
  }],
182
182
  policies: []
@@ -197,7 +197,7 @@ module Ast
197
197
  {
198
198
  mode: normalized_mode,
199
199
  adapter_families: registered_adapter_families(registry),
200
- diagnostics: Array(result&.dig(:apply_result, :diagnostics) || result&.dig('apply_result', 'diagnostics')),
200
+ diagnostics: Array(result&.dig(:apply_result, :diagnostics) || result&.dig("apply_result", "diagnostics")),
201
201
  runner_report: Ast::Merge.report_template_directory_runner(entries, result)
202
202
  }
203
203
  end
@@ -209,10 +209,10 @@ module Ast
209
209
  end
210
210
 
211
211
  registry = {}
212
- if include_family.call('markdown')
212
+ if include_family.call("markdown")
213
213
  begin
214
- require 'markly-merge'
215
- registry['markdown'] = lambda do |entry|
214
+ require "markly-merge"
215
+ registry["markdown"] = lambda do |entry|
216
216
  {
217
217
  ok: true,
218
218
  output: Markly::Merge::SmartMerger.new(
@@ -226,34 +226,34 @@ module Ast
226
226
  end
227
227
  rescue LoadError
228
228
  begin
229
- require 'markdown-merge'
230
- registry['markdown'] = lambda do |entry|
231
- Markdown::Merge.merge_markdown(entry[:prepared_template_content], entry[:destination_content], 'markdown')
229
+ require "markdown-merge"
230
+ registry["markdown"] = lambda do |entry|
231
+ Markdown::Merge.merge_markdown(entry[:prepared_template_content], entry[:destination_content], "markdown")
232
232
  end
233
233
  rescue LoadError
234
234
  end
235
235
  end
236
236
  end
237
- if include_family.call('toml')
237
+ if include_family.call("toml")
238
238
  begin
239
- require 'toml-merge'
240
- registry['toml'] = lambda do |entry|
241
- Toml::Merge.merge_toml(entry[:prepared_template_content], entry[:destination_content], 'toml')
239
+ require "toml-merge"
240
+ registry["toml"] = lambda do |entry|
241
+ Toml::Merge.merge_toml(entry[:prepared_template_content], entry[:destination_content], "toml")
242
242
  end
243
243
  rescue LoadError
244
244
  end
245
245
  end
246
- if include_family.call('ruby')
246
+ if include_family.call("ruby")
247
247
  begin
248
- require 'prism-merge'
249
- registry['ruby'] = lambda do |entry|
250
- Prism::Merge.merge_ruby(entry[:prepared_template_content], entry[:destination_content], 'ruby')
248
+ require "prism-merge"
249
+ registry["ruby"] = lambda do |entry|
250
+ Prism::Merge.merge_ruby(entry[:prepared_template_content], entry[:destination_content], "ruby")
251
251
  end
252
252
  rescue LoadError
253
253
  begin
254
- require 'ruby-merge'
255
- registry['ruby'] = lambda do |entry|
256
- Ruby::Merge.merge_ruby(entry[:prepared_template_content], entry[:destination_content], 'ruby')
254
+ require "ruby-merge"
255
+ registry["ruby"] = lambda do |entry|
256
+ Ruby::Merge.merge_ruby(entry[:prepared_template_content], entry[:destination_content], "ruby")
257
257
  end
258
258
  rescue LoadError
259
259
  end
@@ -274,7 +274,7 @@ module Ast
274
274
  end
275
275
 
276
276
  def plan_template_directory_session_from_directories(template_root, destination_root,
277
- context, default_strategy, overrides, replacements, config = nil)
277
+ context, default_strategy, overrides, replacements, config = nil)
278
278
  entries = Ast::Merge.plan_template_tree_execution_from_directories(
279
279
  template_root,
280
280
  destination_root,
@@ -288,7 +288,7 @@ module Ast
288
288
  end
289
289
 
290
290
  def apply_template_directory_session_to_directory(template_root, destination_root,
291
- context, default_strategy, overrides, replacements, config = nil, &merge_callback)
291
+ context, default_strategy, overrides, replacements, config = nil, &merge_callback)
292
292
  result = Ast::Merge.apply_template_tree_execution_to_directory(
293
293
  template_root,
294
294
  destination_root,
@@ -303,7 +303,7 @@ module Ast
303
303
  end
304
304
 
305
305
  def reapply_template_directory_session_to_directory(template_root, destination_root,
306
- context, default_strategy, overrides, replacements, config = nil, &merge_callback)
306
+ context, default_strategy, overrides, replacements, config = nil, &merge_callback)
307
307
  result = Ast::Merge.apply_template_tree_execution_to_directory(
308
308
  template_root,
309
309
  destination_root,
@@ -318,7 +318,7 @@ module Ast
318
318
  end
319
319
 
320
320
  def apply_template_directory_session_with_registry_to_directory(template_root, destination_root,
321
- context, default_strategy, overrides, replacements, registry, config = nil)
321
+ context, default_strategy, overrides, replacements, registry, config = nil)
322
322
  result = Ast::Merge.apply_template_tree_execution_to_directory(
323
323
  template_root,
324
324
  destination_root,
@@ -334,7 +334,7 @@ module Ast
334
334
  end
335
335
 
336
336
  def apply_template_directory_session_with_default_registry_to_directory(template_root, destination_root,
337
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
337
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
338
338
  registry = default_family_merge_adapter_registry(allowed_families)
339
339
  apply_template_directory_session_with_registry_to_directory(
340
340
  template_root,
@@ -350,9 +350,9 @@ module Ast
350
350
 
351
351
  def required_families(entries)
352
352
  Array(entries).filter_map do |entry|
353
- next unless (entry[:execution_action] || entry['execution_action']).to_s == 'merge_prepared_content'
353
+ next unless (entry[:execution_action] || entry["execution_action"]).to_s == "merge_prepared_content"
354
354
 
355
- entry.dig(:classification, :family) || entry.dig('classification', 'family')
355
+ entry.dig(:classification, :family) || entry.dig("classification", "family")
356
356
  end.uniq.sort
357
357
  end
358
358
 
@@ -369,7 +369,7 @@ module Ast
369
369
  end
370
370
 
371
371
  def report_adapter_capabilities_from_directories(template_root, destination_root,
372
- context, default_strategy, overrides, replacements, registry, config = nil)
372
+ context, default_strategy, overrides, replacements, registry, config = nil)
373
373
  entries = Ast::Merge.plan_template_tree_execution_from_directories(
374
374
  template_root,
375
375
  destination_root,
@@ -383,7 +383,7 @@ module Ast
383
383
  end
384
384
 
385
385
  def report_default_adapter_capabilities_from_directories(template_root, destination_root,
386
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
386
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
387
387
  report_adapter_capabilities_from_directories(
388
388
  template_root,
389
389
  destination_root,
@@ -404,7 +404,7 @@ module Ast
404
404
  end
405
405
 
406
406
  def plan_template_directory_session_envelope_from_directories(template_root, destination_root,
407
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
407
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
408
408
  report_template_directory_session_envelope(
409
409
  plan_template_directory_session_from_directories(
410
410
  template_root,
@@ -429,7 +429,7 @@ module Ast
429
429
  end
430
430
 
431
431
  def apply_template_directory_session_envelope_with_default_registry_to_directory(template_root, destination_root,
432
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
432
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
433
433
  report_template_directory_session_envelope(
434
434
  apply_template_directory_session_with_default_registry_to_directory(
435
435
  template_root,
@@ -455,53 +455,53 @@ module Ast
455
455
  end
456
456
 
457
457
  def report_template_directory_session_status(envelope)
458
- session_report = envelope[:session_report] || envelope['session_report'] || {}
459
- adapter_capabilities = envelope[:adapter_capabilities] || envelope['adapter_capabilities'] || {}
460
- runner_report = session_report[:runner_report] || session_report['runner_report'] || {}
461
- plan_report = runner_report[:plan_report] || runner_report['plan_report'] || {}
462
- entries = Array(plan_report[:entries] || plan_report['entries'])
463
- plan_summary = plan_report[:summary] || plan_report['summary'] || {}
464
- apply_report = runner_report[:apply_report] || runner_report['apply_report'] || {}
465
- apply_entries = Array(apply_report[:entries] || apply_report['entries'])
466
- apply_summary = apply_report[:summary] || apply_report['summary'] || {}
458
+ session_report = envelope[:session_report] || envelope["session_report"] || {}
459
+ adapter_capabilities = envelope[:adapter_capabilities] || envelope["adapter_capabilities"] || {}
460
+ runner_report = session_report[:runner_report] || session_report["runner_report"] || {}
461
+ plan_report = runner_report[:plan_report] || runner_report["plan_report"] || {}
462
+ entries = Array(plan_report[:entries] || plan_report["entries"])
463
+ plan_summary = plan_report[:summary] || plan_report["summary"] || {}
464
+ apply_report = runner_report[:apply_report] || runner_report["apply_report"] || {}
465
+ apply_entries = Array(apply_report[:entries] || apply_report["entries"])
466
+ apply_summary = apply_report[:summary] || apply_report["summary"] || {}
467
467
  blocked_paths = (entries + apply_entries).filter_map do |entry|
468
- status = entry[:status] || entry['status']
469
- destination_path = entry[:destination_path] || entry['destination_path']
470
- destination_path if status.to_s == 'blocked' && destination_path
468
+ status = entry[:status] || entry["status"]
469
+ destination_path = entry[:destination_path] || entry["destination_path"]
470
+ destination_path if status.to_s == "blocked" && destination_path
471
471
  end.uniq.sort
472
472
  missing_families = Array(
473
- adapter_capabilities[:missing_families] || adapter_capabilities['missing_families']
473
+ adapter_capabilities[:missing_families] || adapter_capabilities["missing_families"]
474
474
  ).map(&:to_s).sort
475
475
 
476
476
  {
477
- mode: (session_report[:mode] || session_report['mode']).to_s,
478
- ready: !(adapter_capabilities[:ready] || adapter_capabilities['ready']).nil? && blocked_paths.empty?,
477
+ mode: (session_report[:mode] || session_report["mode"]).to_s,
478
+ ready: !(adapter_capabilities[:ready] || adapter_capabilities["ready"]).nil? && blocked_paths.empty?,
479
479
  missing_families: missing_families,
480
480
  blocked_paths: blocked_paths,
481
- planned_write_count: plan_summary.fetch(:create, plan_summary.fetch('create', 0)) +
482
- plan_summary.fetch(:update, plan_summary.fetch('update', 0)),
483
- written_count: apply_summary.fetch(:written, apply_summary.fetch('written', 0))
481
+ planned_write_count: plan_summary.fetch(:create, plan_summary.fetch("create", 0)) +
482
+ plan_summary.fetch(:update, plan_summary.fetch("update", 0)),
483
+ written_count: apply_summary.fetch(:written, apply_summary.fetch("written", 0))
484
484
  }
485
485
  end
486
486
 
487
487
  def template_directory_session_status_envelope(status)
488
488
  {
489
- kind: 'template_directory_session_status',
489
+ kind: "template_directory_session_status",
490
490
  version: SESSION_STATUS_TRANSPORT_VERSION,
491
491
  status: deep_dup(status)
492
492
  }
493
493
  end
494
494
 
495
495
  def import_template_directory_session_status_envelope(envelope)
496
- unless envelope[:kind] == 'template_directory_session_status'
496
+ unless envelope[:kind] == "template_directory_session_status"
497
497
  return [nil,
498
- { category: 'kind_mismatch',
499
- message: 'expected template_directory_session_status envelope kind.' }]
498
+ {category: "kind_mismatch",
499
+ message: "expected template_directory_session_status envelope kind."}]
500
500
  end
501
501
  unless envelope[:version] == SESSION_STATUS_TRANSPORT_VERSION
502
502
  return [nil,
503
- { category: 'unsupported_version',
504
- message: "unsupported template_directory_session_status envelope version #{envelope[:version]}." }]
503
+ {category: "unsupported_version",
504
+ message: "unsupported template_directory_session_status envelope version #{envelope[:version]}."}]
505
505
  end
506
506
 
507
507
  [deep_dup(envelope[:status]), nil]
@@ -509,38 +509,38 @@ module Ast
509
509
 
510
510
  def report_template_directory_session_diagnostics(mode, entries, adapter_capabilities, result = nil)
511
511
  missing_families = Array(
512
- adapter_capabilities[:missing_families] || adapter_capabilities['missing_families']
512
+ adapter_capabilities[:missing_families] || adapter_capabilities["missing_families"]
513
513
  ).map(&:to_s)
514
514
  blocked_apply_paths = Array(
515
- result&.dig(:apply_report, :entries) || result&.dig('apply_report', 'entries')
515
+ result&.dig(:apply_report, :entries) || result&.dig("apply_report", "entries")
516
516
  ).filter_map do |entry|
517
- destination_path = entry[:destination_path] || entry['destination_path']
518
- status = entry[:status] || entry['status']
519
- destination_path if status.to_s == 'blocked' && destination_path
517
+ destination_path = entry[:destination_path] || entry["destination_path"]
518
+ status = entry[:status] || entry["status"]
519
+ destination_path if status.to_s == "blocked" && destination_path
520
520
  end
521
521
 
522
522
  diagnostics = Array(entries).flat_map do |entry|
523
- path = entry[:destination_path] || entry['destination_path'] ||
524
- entry[:logical_destination_path] || entry['logical_destination_path']
525
- family = entry.dig(:classification, :family) || entry.dig('classification', 'family')
523
+ path = entry[:destination_path] || entry["destination_path"] ||
524
+ entry[:logical_destination_path] || entry["logical_destination_path"]
525
+ family = entry.dig(:classification, :family) || entry.dig("classification", "family")
526
526
  result_entries = []
527
- block_reason = entry[:block_reason] || entry['block_reason']
528
- if (entry[:blocked] || entry['blocked']) && block_reason.to_s == 'unresolved_tokens'
527
+ block_reason = entry[:block_reason] || entry["block_reason"]
528
+ if (entry[:blocked] || entry["blocked"]) && block_reason.to_s == "unresolved_tokens"
529
529
  result_entries << {
530
- severity: 'error',
531
- category: 'configuration_error',
532
- reason: 'unresolved_tokens',
530
+ severity: "error",
531
+ category: "configuration_error",
532
+ reason: "unresolved_tokens",
533
533
  path: path,
534
534
  message: "unresolved template tokens block #{path}"
535
535
  }
536
536
  end
537
- if (entry[:execution_action] || entry['execution_action']).to_s == 'merge_prepared_content' &&
538
- missing_families.include?(family.to_s) &&
539
- (result.nil? || blocked_apply_paths.empty? || blocked_apply_paths.include?(path))
537
+ if (entry[:execution_action] || entry["execution_action"]).to_s == "merge_prepared_content" &&
538
+ missing_families.include?(family.to_s) &&
539
+ (result.nil? || blocked_apply_paths.empty? || blocked_apply_paths.include?(path))
540
540
  result_entries << {
541
- severity: 'error',
542
- category: 'configuration_error',
543
- reason: 'missing_family_adapter',
541
+ severity: "error",
542
+ category: "configuration_error",
543
+ reason: "missing_family_adapter",
544
544
  path: path,
545
545
  family: family.to_s,
546
546
  message: "missing family adapter for #{family} blocks #{path}"
@@ -558,29 +558,29 @@ module Ast
558
558
 
559
559
  def template_directory_session_diagnostics_envelope(diagnostics)
560
560
  {
561
- kind: 'template_directory_session_diagnostics',
561
+ kind: "template_directory_session_diagnostics",
562
562
  version: SESSION_DIAGNOSTICS_TRANSPORT_VERSION,
563
563
  diagnostics: deep_dup(diagnostics)
564
564
  }
565
565
  end
566
566
 
567
567
  def import_template_directory_session_diagnostics_envelope(envelope)
568
- unless envelope[:kind] == 'template_directory_session_diagnostics'
568
+ unless envelope[:kind] == "template_directory_session_diagnostics"
569
569
  return [nil,
570
- { category: 'kind_mismatch',
571
- message: 'expected template_directory_session_diagnostics envelope kind.' }]
570
+ {category: "kind_mismatch",
571
+ message: "expected template_directory_session_diagnostics envelope kind."}]
572
572
  end
573
573
  unless envelope[:version] == SESSION_DIAGNOSTICS_TRANSPORT_VERSION
574
574
  return [nil,
575
- { category: 'unsupported_version',
576
- message: "unsupported template_directory_session_diagnostics envelope version #{envelope[:version]}." }]
575
+ {category: "unsupported_version",
576
+ message: "unsupported template_directory_session_diagnostics envelope version #{envelope[:version]}."}]
577
577
  end
578
578
 
579
579
  [deep_dup(envelope[:diagnostics]), nil]
580
580
  end
581
581
 
582
582
  def plan_template_directory_session_diagnostics_from_directories(template_root, destination_root,
583
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
583
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
584
584
  entries = Ast::Merge.plan_template_tree_execution_from_directories(
585
585
  template_root,
586
586
  destination_root,
@@ -598,7 +598,7 @@ module Ast
598
598
  end
599
599
 
600
600
  def apply_template_directory_session_diagnostics_with_default_registry_to_directory(template_root, destination_root,
601
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
601
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
602
602
  registry = default_family_merge_adapter_registry(allowed_families)
603
603
  result = Ast::Merge.apply_template_tree_execution_to_directory(
604
604
  template_root,
@@ -628,7 +628,7 @@ module Ast
628
628
  end
629
629
 
630
630
  def plan_template_directory_session_outcome_from_directories(template_root, destination_root,
631
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
631
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
632
632
  report_template_directory_session_outcome(
633
633
  plan_template_directory_session_from_directories(
634
634
  template_root,
@@ -665,7 +665,7 @@ module Ast
665
665
  end
666
666
 
667
667
  def apply_template_directory_session_outcome_with_default_registry_to_directory(template_root, destination_root,
668
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
668
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
669
669
  registry = default_family_merge_adapter_registry(allowed_families)
670
670
  result = Ast::Merge.apply_template_tree_execution_to_directory(
671
671
  template_root,
@@ -695,7 +695,7 @@ module Ast
695
695
  end
696
696
 
697
697
  def reapply_template_directory_session_outcome_with_default_registry_to_directory(template_root, destination_root,
698
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
698
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
699
699
  registry = default_family_merge_adapter_registry(allowed_families)
700
700
  result = Ast::Merge.apply_template_tree_execution_to_directory(
701
701
  template_root,
@@ -725,9 +725,9 @@ module Ast
725
725
  end
726
726
 
727
727
  def run_template_directory_session_with_default_registry_to_directory(mode, template_root, destination_root,
728
- context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
728
+ context, default_strategy, overrides, replacements, allowed_families = nil, config = nil)
729
729
  case mode.to_s
730
- when 'plan'
730
+ when "plan"
731
731
  plan_template_directory_session_outcome_from_directories(
732
732
  template_root,
733
733
  destination_root,
@@ -738,7 +738,7 @@ module Ast
738
738
  allowed_families,
739
739
  config
740
740
  )
741
- when 'apply'
741
+ when "apply"
742
742
  apply_template_directory_session_outcome_with_default_registry_to_directory(
743
743
  template_root,
744
744
  destination_root,
@@ -749,7 +749,7 @@ module Ast
749
749
  allowed_families,
750
750
  config
751
751
  )
752
- when 'reapply'
752
+ when "reapply"
753
753
  reapply_template_directory_session_outcome_with_default_registry_to_directory(
754
754
  template_root,
755
755
  destination_root,
@@ -770,45 +770,45 @@ module Ast
770
770
  unless request[:ready]
771
771
  return report_template_directory_session_configuration_outcome(
772
772
  request[:mode],
773
- { mode: request[:mode], ready: request[:ready], diagnostics: request[:diagnostics] }
773
+ {mode: request[:mode], ready: request[:ready], diagnostics: request[:diagnostics]}
774
774
  )
775
775
  end
776
776
  normalized = deep_dup(request[:resolved_options])
777
777
  run_template_directory_session_with_default_registry_to_directory(
778
- normalized[:mode] || normalized['mode'],
779
- normalized[:template_root] || normalized['template_root'],
780
- normalized[:destination_root] || normalized['destination_root'],
781
- normalized[:context] || normalized['context'] || {},
782
- normalized[:default_strategy] || normalized['default_strategy'],
783
- normalized[:overrides] || normalized['overrides'] || [],
784
- normalized[:replacements] || normalized['replacements'] || {},
785
- normalized[:allowed_families] || normalized['allowed_families'],
786
- normalized[:config] || normalized['config']
778
+ normalized[:mode] || normalized["mode"],
779
+ normalized[:template_root] || normalized["template_root"],
780
+ normalized[:destination_root] || normalized["destination_root"],
781
+ normalized[:context] || normalized["context"] || {},
782
+ normalized[:default_strategy] || normalized["default_strategy"],
783
+ normalized[:overrides] || normalized["overrides"] || [],
784
+ normalized[:replacements] || normalized["replacements"] || {},
785
+ normalized[:allowed_families] || normalized["allowed_families"],
786
+ normalized[:config] || normalized["config"]
787
787
  )
788
788
  end
789
789
 
790
790
  def report_template_directory_session_options_configuration(options)
791
791
  normalized = deep_dup(options)
792
792
  diagnostics = []
793
- unless (normalized[:destination_root] || normalized['destination_root']).to_s.length.positive?
793
+ unless (normalized[:destination_root] || normalized["destination_root"]).to_s.length.positive?
794
794
  diagnostics << {
795
- severity: 'error',
796
- category: 'configuration_error',
797
- reason: 'missing_destination_root',
798
- message: 'missing destination_root for template session'
795
+ severity: "error",
796
+ category: "configuration_error",
797
+ reason: "missing_destination_root",
798
+ message: "missing destination_root for template session"
799
799
  }
800
800
  end
801
- unless (normalized[:template_root] || normalized['template_root']).to_s.length.positive?
801
+ unless (normalized[:template_root] || normalized["template_root"]).to_s.length.positive?
802
802
  diagnostics << {
803
- severity: 'error',
804
- category: 'configuration_error',
805
- reason: 'missing_template_root',
806
- message: 'missing template_root for template session'
803
+ severity: "error",
804
+ category: "configuration_error",
805
+ reason: "missing_template_root",
806
+ message: "missing template_root for template session"
807
807
  }
808
808
  end
809
809
  diagnostics.sort_by! { |entry| entry[:reason] }
810
810
  {
811
- mode: normalize_session_mode(normalized[:mode] || normalized['mode']),
811
+ mode: normalize_session_mode(normalized[:mode] || normalized["mode"]),
812
812
  ready: diagnostics.empty?,
813
813
  diagnostics: diagnostics
814
814
  }
@@ -818,7 +818,7 @@ module Ast
818
818
  normalized = deep_dup(options)
819
819
  configuration = report_template_directory_session_options_configuration(normalized)
820
820
  {
821
- request_kind: 'options',
821
+ request_kind: "options",
822
822
  mode: configuration[:mode],
823
823
  ready: configuration[:ready],
824
824
  diagnostics: deep_dup(configuration[:diagnostics]),
@@ -832,13 +832,13 @@ module Ast
832
832
  diagnostics = report_template_directory_session_options_configuration(normalized_overrides)[:diagnostics]
833
833
  profile = normalized_profiles[profile_name.to_s] || normalized_profiles[profile_name.to_sym]
834
834
  mode = normalize_session_mode(
835
- normalized_overrides[:mode] || normalized_overrides['mode'] || profile&.[](:mode) || profile&.[]('mode')
835
+ normalized_overrides[:mode] || normalized_overrides["mode"] || profile&.[](:mode) || profile&.[]("mode")
836
836
  )
837
837
  unless profile
838
838
  diagnostics << {
839
- severity: 'error',
840
- category: 'configuration_error',
841
- reason: 'missing_profile',
839
+ severity: "error",
840
+ category: "configuration_error",
841
+ reason: "missing_profile",
842
842
  message: "unknown template session profile: #{profile_name}"
843
843
  }
844
844
  end
@@ -853,7 +853,7 @@ module Ast
853
853
  def report_template_directory_session_profile_request(profiles, profile_name, overrides)
854
854
  configuration = report_template_directory_session_profile_configuration(profiles, profile_name, overrides)
855
855
  {
856
- request_kind: 'profile',
856
+ request_kind: "profile",
857
857
  profile_name: profile_name.to_s,
858
858
  mode: configuration[:mode],
859
859
  ready: configuration[:ready],
@@ -883,22 +883,22 @@ module Ast
883
883
 
884
884
  def template_directory_session_outcome_envelope(outcome)
885
885
  {
886
- kind: 'template_directory_session_outcome',
886
+ kind: "template_directory_session_outcome",
887
887
  version: SESSION_OUTCOME_TRANSPORT_VERSION,
888
888
  outcome: deep_dup(outcome)
889
889
  }
890
890
  end
891
891
 
892
892
  def import_template_directory_session_outcome_envelope(envelope)
893
- unless envelope[:kind] == 'template_directory_session_outcome'
893
+ unless envelope[:kind] == "template_directory_session_outcome"
894
894
  return [nil,
895
- { category: 'kind_mismatch',
896
- message: 'expected template_directory_session_outcome envelope kind.' }]
895
+ {category: "kind_mismatch",
896
+ message: "expected template_directory_session_outcome envelope kind."}]
897
897
  end
898
898
  unless envelope[:version] == SESSION_OUTCOME_TRANSPORT_VERSION
899
899
  return [nil,
900
- { category: 'unsupported_version',
901
- message: "unsupported template_directory_session_outcome envelope version #{envelope[:version]}." }]
900
+ {category: "unsupported_version",
901
+ message: "unsupported template_directory_session_outcome envelope version #{envelope[:version]}."}]
902
902
  end
903
903
 
904
904
  [deep_dup(envelope[:outcome]), nil]
@@ -906,38 +906,38 @@ module Ast
906
906
 
907
907
  def run_template_directory_session_request(request)
908
908
  normalized = deep_dup(request)
909
- unless normalized[:ready] || normalized['ready']
910
- mode = normalized[:mode] || normalized['mode']
911
- diagnostics = normalized[:diagnostics] || normalized['diagnostics'] || []
909
+ unless normalized[:ready] || normalized["ready"]
910
+ mode = normalized[:mode] || normalized["mode"]
911
+ diagnostics = normalized[:diagnostics] || normalized["diagnostics"] || []
912
912
  return report_template_directory_session_configuration_outcome(
913
913
  mode,
914
- { mode: mode, ready: false, diagnostics: diagnostics }
914
+ {mode: mode, ready: false, diagnostics: diagnostics}
915
915
  )
916
916
  end
917
917
 
918
918
  run_template_directory_session_with_options(
919
- normalized[:resolved_options] || normalized['resolved_options']
919
+ normalized[:resolved_options] || normalized["resolved_options"]
920
920
  )
921
921
  end
922
922
 
923
923
  def template_directory_session_request_envelope(request)
924
924
  {
925
- kind: 'template_directory_session_request',
925
+ kind: "template_directory_session_request",
926
926
  version: SESSION_REQUEST_TRANSPORT_VERSION,
927
927
  request: deep_dup(request)
928
928
  }
929
929
  end
930
930
 
931
931
  def import_template_directory_session_request_envelope(envelope)
932
- unless envelope[:kind] == 'template_directory_session_request'
932
+ unless envelope[:kind] == "template_directory_session_request"
933
933
  return [nil,
934
- { category: 'kind_mismatch',
935
- message: 'expected template_directory_session_request envelope kind.' }]
934
+ {category: "kind_mismatch",
935
+ message: "expected template_directory_session_request envelope kind."}]
936
936
  end
937
937
  unless envelope[:version] == SESSION_REQUEST_TRANSPORT_VERSION
938
938
  return [nil,
939
- { category: 'unsupported_version',
940
- message: "unsupported template_directory_session_request envelope version #{envelope[:version]}." }]
939
+ {category: "unsupported_version",
940
+ message: "unsupported template_directory_session_request envelope version #{envelope[:version]}."}]
941
941
  end
942
942
 
943
943
  [deep_dup(envelope[:request]), nil]
@@ -945,42 +945,42 @@ module Ast
945
945
 
946
946
  def run_template_directory_session_runner_request(request, profiles = {})
947
947
  normalized = deep_dup(request)
948
- request_kind = normalized[:request_kind] || normalized['request_kind']
949
- if request_kind.to_s == 'profile'
948
+ request_kind = normalized[:request_kind] || normalized["request_kind"]
949
+ if request_kind.to_s == "profile"
950
950
  return run_template_directory_session_request(
951
951
  report_template_directory_session_profile_request(
952
952
  profiles,
953
- normalized[:profile_name] || normalized['profile_name'],
954
- normalized[:overrides] || normalized['overrides'] || {}
953
+ normalized[:profile_name] || normalized["profile_name"],
954
+ normalized[:overrides] || normalized["overrides"] || {}
955
955
  )
956
956
  )
957
957
  end
958
958
 
959
959
  run_template_directory_session_request(
960
960
  report_template_directory_session_options_request(
961
- normalized[:options] || normalized['options'] || {}
961
+ normalized[:options] || normalized["options"] || {}
962
962
  )
963
963
  )
964
964
  end
965
965
 
966
966
  def template_directory_session_runner_request_envelope(request)
967
967
  {
968
- kind: 'template_directory_session_runner_request',
968
+ kind: "template_directory_session_runner_request",
969
969
  version: SESSION_RUNNER_REQUEST_TRANSPORT_VERSION,
970
970
  request: deep_dup(request)
971
971
  }
972
972
  end
973
973
 
974
974
  def import_template_directory_session_runner_request_envelope(envelope)
975
- unless envelope[:kind] == 'template_directory_session_runner_request'
975
+ unless envelope[:kind] == "template_directory_session_runner_request"
976
976
  return [nil,
977
- { category: 'kind_mismatch',
978
- message: 'expected template_directory_session_runner_request envelope kind.' }]
977
+ {category: "kind_mismatch",
978
+ message: "expected template_directory_session_runner_request envelope kind."}]
979
979
  end
980
980
  unless envelope[:version] == SESSION_RUNNER_REQUEST_TRANSPORT_VERSION
981
981
  return [nil,
982
- { category: 'unsupported_version',
983
- message: "unsupported template_directory_session_runner_request envelope version #{envelope[:version]}." }]
982
+ {category: "unsupported_version",
983
+ message: "unsupported template_directory_session_runner_request envelope version #{envelope[:version]}."}]
984
984
  end
985
985
 
986
986
  [deep_dup(envelope[:request]), nil]
@@ -988,38 +988,38 @@ module Ast
988
988
 
989
989
  def report_template_directory_session_runner_input(input)
990
990
  normalized = deep_dup(input)
991
- request_kind = (normalized[:request_kind] || normalized['request_kind']).to_s
991
+ request_kind = (normalized[:request_kind] || normalized["request_kind"]).to_s
992
992
  options = {
993
- mode: normalized[:mode] || normalized['mode'],
994
- template_root: normalized[:template_root] || normalized['template_root'],
995
- destination_root: normalized[:destination_root] || normalized['destination_root'],
996
- context: normalized[:context] || normalized['context'] || {},
997
- default_strategy: normalized[:default_strategy] || normalized['default_strategy'] || 'merge',
998
- overrides: normalized[:overrides] || normalized['overrides'] || [],
999
- replacements: normalized[:replacements] || normalized['replacements'] || {},
1000
- allowed_families: if normalized.key?(:allowed_families) || normalized.key?('allowed_families')
1001
- normalized[:allowed_families] || normalized['allowed_families']
993
+ mode: normalized[:mode] || normalized["mode"],
994
+ template_root: normalized[:template_root] || normalized["template_root"],
995
+ destination_root: normalized[:destination_root] || normalized["destination_root"],
996
+ context: normalized[:context] || normalized["context"] || {},
997
+ default_strategy: normalized[:default_strategy] || normalized["default_strategy"] || "merge",
998
+ overrides: normalized[:overrides] || normalized["overrides"] || [],
999
+ replacements: normalized[:replacements] || normalized["replacements"] || {},
1000
+ allowed_families: if normalized.key?(:allowed_families) || normalized.key?("allowed_families")
1001
+ normalized[:allowed_families] || normalized["allowed_families"]
1002
1002
  end
1003
1003
  }
1004
- if request_kind == 'profile'
1004
+ if request_kind == "profile"
1005
1005
  return {
1006
- request_kind: 'profile',
1007
- profile_name: normalized[:profile_name] || normalized['profile_name'],
1006
+ request_kind: "profile",
1007
+ profile_name: normalized[:profile_name] || normalized["profile_name"],
1008
1008
  overrides: begin
1009
1009
  sparse = {
1010
- mode: normalized[:mode] || normalized['mode'],
1011
- template_root: normalized[:template_root] || normalized['template_root'],
1012
- destination_root: normalized[:destination_root] || normalized['destination_root']
1010
+ mode: normalized[:mode] || normalized["mode"],
1011
+ template_root: normalized[:template_root] || normalized["template_root"],
1012
+ destination_root: normalized[:destination_root] || normalized["destination_root"]
1013
1013
  }
1014
- context = normalized[:context] || normalized['context']
1015
- sparse[:context] = context if context.is_a?(Hash) && (context[:project_name] || context['project_name'])
1016
- strategy = normalized[:default_strategy] || normalized['default_strategy']
1017
- sparse[:default_strategy] = strategy if strategy && strategy != 'merge'
1018
- overrides = normalized[:overrides] || normalized['overrides']
1014
+ context = normalized[:context] || normalized["context"]
1015
+ sparse[:context] = context if context.is_a?(Hash) && (context[:project_name] || context["project_name"])
1016
+ strategy = normalized[:default_strategy] || normalized["default_strategy"]
1017
+ sparse[:default_strategy] = strategy if strategy && strategy != "merge"
1018
+ overrides = normalized[:overrides] || normalized["overrides"]
1019
1019
  sparse[:overrides] = overrides if overrides.is_a?(Array) && !overrides.empty?
1020
- replacements = normalized[:replacements] || normalized['replacements']
1020
+ replacements = normalized[:replacements] || normalized["replacements"]
1021
1021
  sparse[:replacements] = replacements if replacements.is_a?(Hash) && !replacements.empty?
1022
- allowed_families = normalized.key?(:allowed_families) ? normalized[:allowed_families] : normalized['allowed_families']
1022
+ allowed_families = normalized.key?(:allowed_families) ? normalized[:allowed_families] : normalized["allowed_families"]
1023
1023
  sparse[:allowed_families] = allowed_families unless allowed_families.nil?
1024
1024
  sparse
1025
1025
  end
@@ -1027,40 +1027,40 @@ module Ast
1027
1027
  end
1028
1028
 
1029
1029
  {
1030
- request_kind: 'options',
1030
+ request_kind: "options",
1031
1031
  options: options
1032
1032
  }
1033
1033
  end
1034
1034
 
1035
1035
  def report_template_directory_session_runner_payload(payload)
1036
1036
  normalized = deep_dup(payload)
1037
- request_kind = normalized[:request_kind] || normalized['request_kind']
1037
+ request_kind = normalized[:request_kind] || normalized["request_kind"]
1038
1038
  request_kind = if request_kind.to_s.empty?
1039
- if normalized.key?(:profile_name) || normalized.key?('profile_name') ||
1040
- normalized.key?(:default_profile_name) || normalized.key?('default_profile_name')
1041
- 'profile'
1042
- else
1043
- 'options'
1044
- end
1045
- else
1046
- request_kind.to_s
1047
- end
1039
+ if normalized.key?(:profile_name) || normalized.key?("profile_name") ||
1040
+ normalized.key?(:default_profile_name) || normalized.key?("default_profile_name")
1041
+ "profile"
1042
+ else
1043
+ "options"
1044
+ end
1045
+ else
1046
+ request_kind.to_s
1047
+ end
1048
1048
 
1049
1049
  result = {
1050
1050
  request_kind: request_kind,
1051
- mode: normalized[:mode] || normalized['mode'],
1052
- template_root: normalized[:template_root] || normalized['template_root'],
1053
- destination_root: normalized[:destination_root] || normalized['destination_root'],
1054
- context: normalized[:context] || normalized['context'] || {},
1055
- default_strategy: normalized[:default_strategy] || normalized['default_strategy'] || 'merge',
1056
- overrides: normalized[:overrides] || normalized['overrides'] || [],
1057
- replacements: normalized[:replacements] || normalized['replacements'] || {},
1058
- allowed_families: if normalized.key?(:allowed_families) || normalized.key?('allowed_families')
1059
- normalized.key?(:allowed_families) ? normalized[:allowed_families] : normalized['allowed_families']
1051
+ mode: normalized[:mode] || normalized["mode"],
1052
+ template_root: normalized[:template_root] || normalized["template_root"],
1053
+ destination_root: normalized[:destination_root] || normalized["destination_root"],
1054
+ context: normalized[:context] || normalized["context"] || {},
1055
+ default_strategy: normalized[:default_strategy] || normalized["default_strategy"] || "merge",
1056
+ overrides: normalized[:overrides] || normalized["overrides"] || [],
1057
+ replacements: normalized[:replacements] || normalized["replacements"] || {},
1058
+ allowed_families: if normalized.key?(:allowed_families) || normalized.key?("allowed_families")
1059
+ normalized.key?(:allowed_families) ? normalized[:allowed_families] : normalized["allowed_families"]
1060
1060
  end
1061
1061
  }
1062
- profile_name = normalized[:profile_name] || normalized['profile_name'] ||
1063
- normalized[:default_profile_name] || normalized['default_profile_name']
1062
+ profile_name = normalized[:profile_name] || normalized["profile_name"] ||
1063
+ normalized[:default_profile_name] || normalized["default_profile_name"]
1064
1064
  result[:profile_name] = profile_name if profile_name
1065
1065
  result
1066
1066
  end
@@ -1076,22 +1076,22 @@ module Ast
1076
1076
 
1077
1077
  def template_directory_session_runner_payload_envelope(payload)
1078
1078
  {
1079
- kind: 'template_directory_session_runner_payload',
1079
+ kind: "template_directory_session_runner_payload",
1080
1080
  version: SESSION_RUNNER_PAYLOAD_TRANSPORT_VERSION,
1081
1081
  payload: deep_dup(payload)
1082
1082
  }
1083
1083
  end
1084
1084
 
1085
1085
  def import_template_directory_session_runner_payload_envelope(envelope)
1086
- unless envelope[:kind] == 'template_directory_session_runner_payload'
1086
+ unless envelope[:kind] == "template_directory_session_runner_payload"
1087
1087
  return [nil,
1088
- { category: 'kind_mismatch',
1089
- message: 'expected template_directory_session_runner_payload envelope kind.' }]
1088
+ {category: "kind_mismatch",
1089
+ message: "expected template_directory_session_runner_payload envelope kind."}]
1090
1090
  end
1091
1091
  unless envelope[:version] == SESSION_RUNNER_PAYLOAD_TRANSPORT_VERSION
1092
1092
  return [nil,
1093
- { category: 'unsupported_version',
1094
- message: "unsupported template_directory_session_runner_payload envelope version #{envelope[:version]}." }]
1093
+ {category: "unsupported_version",
1094
+ message: "unsupported template_directory_session_runner_payload envelope version #{envelope[:version]}."}]
1095
1095
  end
1096
1096
 
1097
1097
  [deep_dup(envelope[:payload]), nil]
@@ -1099,49 +1099,49 @@ module Ast
1099
1099
 
1100
1100
  def run_template_directory_session_entrypoint(entrypoint, profiles = {})
1101
1101
  normalized = deep_dup(entrypoint)
1102
- if normalized[:payload] || normalized['payload']
1102
+ if normalized[:payload] || normalized["payload"]
1103
1103
  return run_template_directory_session_runner_payload(
1104
- normalized[:payload] || normalized['payload'],
1104
+ normalized[:payload] || normalized["payload"],
1105
1105
  profiles
1106
1106
  )
1107
1107
  end
1108
1108
 
1109
- if normalized[:request] || normalized['request']
1109
+ if normalized[:request] || normalized["request"]
1110
1110
  return run_template_directory_session_runner_request(
1111
- normalized[:request] || normalized['request'],
1111
+ normalized[:request] || normalized["request"],
1112
1112
  profiles
1113
1113
  )
1114
1114
  end
1115
1115
 
1116
1116
  report_template_directory_session_configuration_outcome(
1117
- 'plan',
1118
- { mode: 'plan', ready: false, diagnostics: [] }
1117
+ "plan",
1118
+ {mode: "plan", ready: false, diagnostics: []}
1119
1119
  )
1120
1120
  end
1121
1121
 
1122
1122
  def report_template_directory_session_entrypoint(entrypoint)
1123
1123
  normalized = deep_dup(entrypoint)
1124
- if normalized[:payload] || normalized['payload']
1124
+ if normalized[:payload] || normalized["payload"]
1125
1125
  return {
1126
- source_kind: 'payload',
1126
+ source_kind: "payload",
1127
1127
  runner_request: report_template_directory_session_runner_input(
1128
1128
  report_template_directory_session_runner_payload(
1129
- normalized[:payload] || normalized['payload']
1129
+ normalized[:payload] || normalized["payload"]
1130
1130
  )
1131
1131
  )
1132
1132
  }
1133
1133
  end
1134
1134
 
1135
- if normalized[:request] || normalized['request']
1135
+ if normalized[:request] || normalized["request"]
1136
1136
  return {
1137
- source_kind: 'request',
1138
- runner_request: normalized[:request] || normalized['request']
1137
+ source_kind: "request",
1138
+ runner_request: normalized[:request] || normalized["request"]
1139
1139
  }
1140
1140
  end
1141
1141
 
1142
1142
  {
1143
- source_kind: '',
1144
- runner_request: { request_kind: 'options' }
1143
+ source_kind: "",
1144
+ runner_request: {request_kind: "options"}
1145
1145
  }
1146
1146
  end
1147
1147
 
@@ -1231,22 +1231,22 @@ module Ast
1231
1231
 
1232
1232
  def template_directory_session_inspection_envelope(inspection)
1233
1233
  {
1234
- kind: 'template_directory_session_inspection',
1234
+ kind: "template_directory_session_inspection",
1235
1235
  version: SESSION_INSPECTION_TRANSPORT_VERSION,
1236
1236
  inspection: deep_dup(inspection)
1237
1237
  }
1238
1238
  end
1239
1239
 
1240
1240
  def import_template_directory_session_inspection_envelope(envelope)
1241
- unless envelope[:kind] == 'template_directory_session_inspection'
1241
+ unless envelope[:kind] == "template_directory_session_inspection"
1242
1242
  return [nil,
1243
- { category: 'kind_mismatch',
1244
- message: 'expected template_directory_session_inspection envelope kind.' }]
1243
+ {category: "kind_mismatch",
1244
+ message: "expected template_directory_session_inspection envelope kind."}]
1245
1245
  end
1246
1246
  unless envelope[:version] == SESSION_INSPECTION_TRANSPORT_VERSION
1247
1247
  return [nil,
1248
- { category: 'unsupported_version',
1249
- message: "unsupported template_directory_session_inspection envelope version #{envelope[:version]}." }]
1248
+ {category: "unsupported_version",
1249
+ message: "unsupported template_directory_session_inspection envelope version #{envelope[:version]}."}]
1250
1250
  end
1251
1251
 
1252
1252
  [deep_dup(envelope[:inspection]), nil]
@@ -1254,13 +1254,13 @@ module Ast
1254
1254
 
1255
1255
  def run_template_directory_session_dispatch(operation, entrypoint, profiles = {})
1256
1256
  case operation.to_s
1257
- when 'inspect'
1257
+ when "inspect"
1258
1258
  {
1259
1259
  operation: operation.to_s,
1260
1260
  inspection: report_template_directory_session_inspection(entrypoint, profiles),
1261
1261
  outcome: nil
1262
1262
  }
1263
- when 'run'
1263
+ when "run"
1264
1264
  {
1265
1265
  operation: operation.to_s,
1266
1266
  inspection: nil,
@@ -1274,10 +1274,10 @@ module Ast
1274
1274
  def run_template_directory_session_command(command, profiles = {})
1275
1275
  normalized = deep_dup(command)
1276
1276
  run_template_directory_session_dispatch(
1277
- normalized[:operation] || normalized['operation'],
1277
+ normalized[:operation] || normalized["operation"],
1278
1278
  {
1279
- payload: normalized[:payload] || normalized['payload'],
1280
- request: normalized[:request] || normalized['request']
1279
+ payload: normalized[:payload] || normalized["payload"],
1280
+ request: normalized[:request] || normalized["request"]
1281
1281
  },
1282
1282
  profiles
1283
1283
  )
@@ -1287,19 +1287,19 @@ module Ast
1287
1287
  normalized = deep_dup(command)
1288
1288
  run_template_directory_session_command(
1289
1289
  {
1290
- operation: normalized[:operation] || normalized['operation'],
1290
+ operation: normalized[:operation] || normalized["operation"],
1291
1291
  payload: {
1292
- request_kind: normalized[:request_kind] || normalized['request_kind'],
1293
- default_profile_name: normalized[:default_profile_name] || normalized['default_profile_name'],
1294
- profile_name: normalized[:profile_name] || normalized['profile_name'],
1295
- mode: normalized[:mode] || normalized['mode'],
1296
- template_root: normalized[:template_root] || normalized['template_root'],
1297
- destination_root: normalized[:destination_root] || normalized['destination_root'],
1298
- context: normalized[:context] || normalized['context'],
1299
- default_strategy: normalized[:default_strategy] || normalized['default_strategy'],
1300
- overrides: normalized[:overrides] || normalized['overrides'],
1301
- replacements: normalized[:replacements] || normalized['replacements'],
1302
- allowed_families: normalized.key?(:allowed_families) ? normalized[:allowed_families] : normalized['allowed_families']
1292
+ request_kind: normalized[:request_kind] || normalized["request_kind"],
1293
+ default_profile_name: normalized[:default_profile_name] || normalized["default_profile_name"],
1294
+ profile_name: normalized[:profile_name] || normalized["profile_name"],
1295
+ mode: normalized[:mode] || normalized["mode"],
1296
+ template_root: normalized[:template_root] || normalized["template_root"],
1297
+ destination_root: normalized[:destination_root] || normalized["destination_root"],
1298
+ context: normalized[:context] || normalized["context"],
1299
+ default_strategy: normalized[:default_strategy] || normalized["default_strategy"],
1300
+ overrides: normalized[:overrides] || normalized["overrides"],
1301
+ replacements: normalized[:replacements] || normalized["replacements"],
1302
+ allowed_families: normalized.key?(:allowed_families) ? normalized[:allowed_families] : normalized["allowed_families"]
1303
1303
  }
1304
1304
  },
1305
1305
  profiles
@@ -1308,7 +1308,7 @@ module Ast
1308
1308
 
1309
1309
  def run_template_directory_session(invocation, profiles = {})
1310
1310
  normalized = deep_dup(invocation)
1311
- if normalized[:payload] || normalized['payload'] || normalized[:request] || normalized['request']
1311
+ if normalized[:payload] || normalized["payload"] || normalized[:request] || normalized["request"]
1312
1312
  return run_template_directory_session_command(normalized, profiles)
1313
1313
  end
1314
1314
 
@@ -1317,22 +1317,22 @@ module Ast
1317
1317
 
1318
1318
  def template_directory_session_entrypoint_envelope(entrypoint)
1319
1319
  {
1320
- kind: 'template_directory_session_entrypoint',
1320
+ kind: "template_directory_session_entrypoint",
1321
1321
  version: SESSION_ENTRYPOINT_TRANSPORT_VERSION,
1322
1322
  entrypoint: deep_dup(entrypoint)
1323
1323
  }
1324
1324
  end
1325
1325
 
1326
1326
  def import_template_directory_session_entrypoint_envelope(envelope)
1327
- unless envelope[:kind] == 'template_directory_session_entrypoint'
1327
+ unless envelope[:kind] == "template_directory_session_entrypoint"
1328
1328
  return [nil,
1329
- { category: 'kind_mismatch',
1330
- message: 'expected template_directory_session_entrypoint envelope kind.' }]
1329
+ {category: "kind_mismatch",
1330
+ message: "expected template_directory_session_entrypoint envelope kind."}]
1331
1331
  end
1332
1332
  unless envelope[:version] == SESSION_ENTRYPOINT_TRANSPORT_VERSION
1333
1333
  return [nil,
1334
- { category: 'unsupported_version',
1335
- message: "unsupported template_directory_session_entrypoint envelope version #{envelope[:version]}." }]
1334
+ {category: "unsupported_version",
1335
+ message: "unsupported template_directory_session_entrypoint envelope version #{envelope[:version]}."}]
1336
1336
  end
1337
1337
 
1338
1338
  [deep_dup(envelope[:entrypoint]), nil]
@@ -1340,22 +1340,22 @@ module Ast
1340
1340
 
1341
1341
  def template_directory_session_command_envelope(command)
1342
1342
  {
1343
- kind: 'template_directory_session_command',
1343
+ kind: "template_directory_session_command",
1344
1344
  version: SESSION_COMMAND_TRANSPORT_VERSION,
1345
1345
  command: deep_dup(command)
1346
1346
  }
1347
1347
  end
1348
1348
 
1349
1349
  def import_template_directory_session_command_envelope(envelope)
1350
- unless envelope[:kind] == 'template_directory_session_command'
1350
+ unless envelope[:kind] == "template_directory_session_command"
1351
1351
  return [nil,
1352
- { category: 'kind_mismatch',
1353
- message: 'expected template_directory_session_command envelope kind.' }]
1352
+ {category: "kind_mismatch",
1353
+ message: "expected template_directory_session_command envelope kind."}]
1354
1354
  end
1355
1355
  unless envelope[:version] == SESSION_COMMAND_TRANSPORT_VERSION
1356
1356
  return [nil,
1357
- { category: 'unsupported_version',
1358
- message: "unsupported template_directory_session_command envelope version #{envelope[:version]}." }]
1357
+ {category: "unsupported_version",
1358
+ message: "unsupported template_directory_session_command envelope version #{envelope[:version]}."}]
1359
1359
  end
1360
1360
 
1361
1361
  [deep_dup(envelope[:command]), nil]
@@ -1363,22 +1363,22 @@ module Ast
1363
1363
 
1364
1364
  def template_directory_session_command_payload_envelope(payload)
1365
1365
  {
1366
- kind: 'template_directory_session_command_payload',
1366
+ kind: "template_directory_session_command_payload",
1367
1367
  version: SESSION_COMMAND_PAYLOAD_TRANSPORT_VERSION,
1368
1368
  payload: deep_dup(payload)
1369
1369
  }
1370
1370
  end
1371
1371
 
1372
1372
  def import_template_directory_session_command_payload_envelope(envelope)
1373
- unless envelope[:kind] == 'template_directory_session_command_payload'
1373
+ unless envelope[:kind] == "template_directory_session_command_payload"
1374
1374
  return [nil,
1375
- { category: 'kind_mismatch',
1376
- message: 'expected template_directory_session_command_payload envelope kind.' }]
1375
+ {category: "kind_mismatch",
1376
+ message: "expected template_directory_session_command_payload envelope kind."}]
1377
1377
  end
1378
1378
  unless envelope[:version] == SESSION_COMMAND_PAYLOAD_TRANSPORT_VERSION
1379
1379
  return [nil,
1380
- { category: 'unsupported_version',
1381
- message: "unsupported template_directory_session_command_payload envelope version #{envelope[:version]}." }]
1380
+ {category: "unsupported_version",
1381
+ message: "unsupported template_directory_session_command_payload envelope version #{envelope[:version]}."}]
1382
1382
  end
1383
1383
 
1384
1384
  [deep_dup(envelope[:payload]), nil]
@@ -1386,22 +1386,22 @@ module Ast
1386
1386
 
1387
1387
  def template_directory_session_invocation_envelope(invocation)
1388
1388
  {
1389
- kind: 'template_directory_session_invocation',
1389
+ kind: "template_directory_session_invocation",
1390
1390
  version: SESSION_INVOCATION_TRANSPORT_VERSION,
1391
1391
  invocation: deep_dup(invocation)
1392
1392
  }
1393
1393
  end
1394
1394
 
1395
1395
  def import_template_directory_session_invocation_envelope(envelope)
1396
- unless envelope[:kind] == 'template_directory_session_invocation'
1396
+ unless envelope[:kind] == "template_directory_session_invocation"
1397
1397
  return [nil,
1398
- { category: 'kind_mismatch',
1399
- message: 'expected template_directory_session_invocation envelope kind.' }]
1398
+ {category: "kind_mismatch",
1399
+ message: "expected template_directory_session_invocation envelope kind."}]
1400
1400
  end
1401
1401
  unless envelope[:version] == SESSION_INVOCATION_TRANSPORT_VERSION
1402
1402
  return [nil,
1403
- { category: 'unsupported_version',
1404
- message: "unsupported template_directory_session_invocation envelope version #{envelope[:version]}." }]
1403
+ {category: "unsupported_version",
1404
+ message: "unsupported template_directory_session_invocation envelope version #{envelope[:version]}."}]
1405
1405
  end
1406
1406
 
1407
1407
  [deep_dup(envelope[:invocation]), nil]
@@ -1409,16 +1409,16 @@ module Ast
1409
1409
 
1410
1410
  def report_session_request_from_runner_request(request, profiles = {})
1411
1411
  normalized = deep_dup(request)
1412
- if (normalized[:request_kind] || normalized['request_kind']).to_s == 'profile'
1412
+ if (normalized[:request_kind] || normalized["request_kind"]).to_s == "profile"
1413
1413
  return report_template_directory_session_profile_request(
1414
1414
  profiles,
1415
- normalized[:profile_name] || normalized['profile_name'],
1416
- normalized[:overrides] || normalized['overrides'] || {}
1415
+ normalized[:profile_name] || normalized["profile_name"],
1416
+ normalized[:overrides] || normalized["overrides"] || {}
1417
1417
  )
1418
1418
  end
1419
1419
 
1420
1420
  report_template_directory_session_options_request(
1421
- normalized[:options] || normalized['options'] || {}
1421
+ normalized[:options] || normalized["options"] || {}
1422
1422
  )
1423
1423
  end
1424
1424
 
@@ -1429,22 +1429,22 @@ module Ast
1429
1429
  normalized_profile = deep_dup(profile)
1430
1430
  normalized_overrides = deep_dup(overrides)
1431
1431
  {
1432
- mode: normalized_overrides[:mode] || normalized_overrides['mode'] ||
1433
- normalized_profile[:mode] || normalized_profile['mode'],
1434
- template_root: normalized_overrides[:template_root] || normalized_overrides['template_root'],
1435
- destination_root: normalized_overrides[:destination_root] || normalized_overrides['destination_root'],
1436
- context: normalized_overrides[:context] || normalized_overrides['context'] ||
1437
- normalized_profile[:context] || normalized_profile['context'] || {},
1438
- default_strategy: normalized_overrides[:default_strategy] || normalized_overrides['default_strategy'] ||
1439
- normalized_profile[:default_strategy] || normalized_profile['default_strategy'],
1440
- overrides: normalized_overrides[:overrides] || normalized_overrides['overrides'] ||
1441
- normalized_profile[:overrides] || normalized_profile['overrides'] || [],
1442
- replacements: normalized_overrides[:replacements] || normalized_overrides['replacements'] ||
1443
- normalized_profile[:replacements] || normalized_profile['replacements'] || {},
1444
- allowed_families: normalized_overrides[:allowed_families] || normalized_overrides['allowed_families'] ||
1445
- normalized_profile[:allowed_families] || normalized_profile['allowed_families'],
1446
- config: normalized_overrides[:config] || normalized_overrides['config'] ||
1447
- normalized_profile[:config] || normalized_profile['config']
1432
+ mode: normalized_overrides[:mode] || normalized_overrides["mode"] ||
1433
+ normalized_profile[:mode] || normalized_profile["mode"],
1434
+ template_root: normalized_overrides[:template_root] || normalized_overrides["template_root"],
1435
+ destination_root: normalized_overrides[:destination_root] || normalized_overrides["destination_root"],
1436
+ context: normalized_overrides[:context] || normalized_overrides["context"] ||
1437
+ normalized_profile[:context] || normalized_profile["context"] || {},
1438
+ default_strategy: normalized_overrides[:default_strategy] || normalized_overrides["default_strategy"] ||
1439
+ normalized_profile[:default_strategy] || normalized_profile["default_strategy"],
1440
+ overrides: normalized_overrides[:overrides] || normalized_overrides["overrides"] ||
1441
+ normalized_profile[:overrides] || normalized_profile["overrides"] || [],
1442
+ replacements: normalized_overrides[:replacements] || normalized_overrides["replacements"] ||
1443
+ normalized_profile[:replacements] || normalized_profile["replacements"] || {},
1444
+ allowed_families: normalized_overrides[:allowed_families] || normalized_overrides["allowed_families"] ||
1445
+ normalized_profile[:allowed_families] || normalized_profile["allowed_families"],
1446
+ config: normalized_overrides[:config] || normalized_overrides["config"] ||
1447
+ normalized_profile[:config] || normalized_profile["config"]
1448
1448
  }
1449
1449
  end
1450
1450
 
@@ -1453,7 +1453,7 @@ module Ast
1453
1453
  unless request[:ready]
1454
1454
  return report_template_directory_session_configuration_outcome(
1455
1455
  request[:mode],
1456
- { mode: request[:mode], ready: request[:ready], diagnostics: request[:diagnostics] }
1456
+ {mode: request[:mode], ready: request[:ready], diagnostics: request[:diagnostics]}
1457
1457
  )
1458
1458
  end
1459
1459
 
@@ -1467,7 +1467,7 @@ module Ast
1467
1467
  return "#{replacement}\n" if normalized.empty?
1468
1468
 
1469
1469
  lines = normalized.split("\n")
1470
- heading = "#{'#' * heading_level} #{heading_text}"
1470
+ heading = "#{"#" * heading_level} #{heading_text}"
1471
1471
  heading_index = lines.index { |line| line.strip == heading }
1472
1472
  if heading_index
1473
1473
  section_end = lines.length
@@ -1479,34 +1479,34 @@ module Ast
1479
1479
  end
1480
1480
  end
1481
1481
  output_lines = lines[0...heading_index] + replacement.split("\n")
1482
- output_lines << '' if section_end < lines.length && lines[section_end] != ''
1482
+ output_lines << "" if section_end < lines.length && lines[section_end] != ""
1483
1483
  output_lines += lines[section_end..]
1484
1484
  return "#{output_lines.join("\n")}\n"
1485
1485
  end
1486
1486
 
1487
1487
  insert_at = readme_family_section_insert_index(lines)
1488
1488
  output_lines = lines[0...insert_at]
1489
- output_lines << '' if output_lines.any? && output_lines.last != ''
1489
+ output_lines << "" if output_lines.any? && output_lines.last != ""
1490
1490
  output_lines += replacement.split("\n")
1491
- output_lines << '' if insert_at < lines.length && lines[insert_at] != ''
1491
+ output_lines << "" if insert_at < lines.length && lines[insert_at] != ""
1492
1492
  output_lines += lines[insert_at..]
1493
1493
  "#{output_lines.join("\n")}\n"
1494
1494
  end
1495
1495
 
1496
1496
  def markdown_heading_level(line)
1497
1497
  match = line.to_s.strip.match(/\A(#+)\s/)
1498
- match && match[1].length <= 6 ? match[1].length : 0
1498
+ (match && match[1].length <= 6) ? match[1].length : 0
1499
1499
  end
1500
1500
 
1501
1501
  def readme_family_section_insert_index(lines)
1502
1502
  index = 0
1503
1503
  if markdown_heading_level(lines[0]) == 1
1504
1504
  index = 1
1505
- index += 1 while index < lines.length && lines[index] == ''
1505
+ index += 1 while index < lines.length && lines[index] == ""
1506
1506
  end
1507
1507
  while index < lines.length
1508
- if lines[index] == ''
1509
- index += 1 while index < lines.length && lines[index] == ''
1508
+ if lines[index] == ""
1509
+ index += 1 while index < lines.length && lines[index] == ""
1510
1510
  return index
1511
1511
  end
1512
1512
  index += 1
@@ -1520,13 +1520,13 @@ module Ast
1520
1520
 
1521
1521
  def normalize_session_mode(mode)
1522
1522
  normalized_mode = mode.to_s
1523
- MODES.include?(normalized_mode) ? normalized_mode : 'plan'
1523
+ MODES.include?(normalized_mode) ? normalized_mode : "plan"
1524
1524
  end
1525
1525
 
1526
1526
  def compact_session_request_options(options)
1527
1527
  normalized = deep_dup(options)
1528
1528
  normalized.delete(:config)
1529
- normalized.delete('config')
1529
+ normalized.delete("config")
1530
1530
  normalized
1531
1531
  end
1532
1532
  end