diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-28 13:59:58 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-28 13:59:58 +0300 |
| commit | f905fc9da0aed140b85efd0de1f8731cef001173 (patch) | |
| tree | d46d3b02ad4ba0bf612951f15180969ac02683ce /src/lib/generation-metadata.source.sh | |
| parent | cf889b4cc771d44e36189d6fc09dfa23b2529bfd (diff) | |
Refactor over-length functions into ~30-line helpers (vr0)
Pure, behavior-preserving refactor: extract _-prefixed helpers from six
functions that exceeded the project's 50-line threshold, leaving each
original as a thin orchestrator. Generated HTML, dry-run output,
shuriken.json, EXIF cache behavior and the flush-grid layout are all
byte-identical (full test suite green).
Refactored:
- _generation_metadata_json -> _generation_metadata_json_head +
_generation_metadata_json_settings
- print_dry_run_plan -> _print_dry_run_settings + _print_dry_run_files
- _photo_exif_tooltip_text_from_values -> _collect_exif_tooltip_parts +
_emit_exif_tooltip_parts
- cached_photo_identify_output -> _rebuild_photo_identify_cache
- render_album_pages -> _render_album_page (one page record)
- append_preview_grid -> _roll_and_align_page_tiles + _emit_page_tiles
(uniquely-named namerefs to avoid circular-nameref)
Left intact (delicate errexit/trap management that must stay in one
function scope, where a split would change semantics):
source_template_file, refresh_splash, generate_staged,
replace_dist_with_staging.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/generation-metadata.source.sh')
| -rw-r--r-- | src/lib/generation-metadata.source.sh | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lib/generation-metadata.source.sh b/src/lib/generation-metadata.source.sh index dc3578a..f70bc23 100644 --- a/src/lib/generation-metadata.source.sh +++ b/src/lib/generation-metadata.source.sh @@ -48,7 +48,10 @@ _collect_generation_metadata() { _GENERATION_METADATA["settings_original_basepath"]="$ORIGINAL_BASEPATH" } -_generation_metadata_json() { +# Emit the generator/generated_at/config_source/template/source/generated/tarball +# JSON sections (everything before "settings"). All read the _GENERATION_METADATA +# global the collector populated; split out only to keep the serialiser short. +_generation_metadata_json_head() { printf '{\n' printf ' "generator": {\n' printf ' "name": %s,\n' \ @@ -86,6 +89,11 @@ _generation_metadata_json() { printf ' "file": %s\n' \ "$(json_string "${_GENERATION_METADATA["tarball_file"]}")" printf ' },\n' +} + +# Emit the "settings" object and the closing brace. Split from the head so each +# half stays around 30 lines; identical byte output to the original one-shot. +_generation_metadata_json_settings() { printf ' "settings": {\n' printf ' "title": %s,\n' \ "$(json_string "${_GENERATION_METADATA["settings_title"]}")" @@ -115,6 +123,13 @@ _generation_metadata_json() { printf '}\n' } +# Serialise _GENERATION_METADATA to the dist/shuriken.json layout. Thin +# orchestrator over the head + settings emitters above. +_generation_metadata_json() { + _generation_metadata_json_head + _generation_metadata_json_settings +} + write_generation_metadata() { local -r tarball_file="$1"; shift |
