Skip to content

refactor: eliminate require_relative in cli and public_send from lib - #32

Open
ronaldtse wants to merge 5 commits into
mainfrom
fix/todo-round3
Open

refactor: eliminate require_relative in cli and public_send from lib#32
ronaldtse wants to merge 5 commits into
mainfrom
fix/todo-round3

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

Completes TODO 03, 05, and 12 from the consolidated TODO/ backlog.

  • TODO 03: Remove 13 require_relative lines from cli/main.rb. All CLI classes are autoloaded from lib/uniword.rb.
  • TODO 05: Eliminate 5 of 8 public_send sites via case/when dispatch or existing color_by_name accessor. Made ColorScheme#color_by_name public.
  • TODO 12: Documented 3 remaining public_send sites as legitimate dynamic dispatch (template property access, schema-driven serialization).

Test plan

  • Local: 5460 examples, 0 failures
  • CI: Ruby 3.3/3.4/4.0 × macOS/Ubuntu/Windows

TODO 03: Remove 13 require_relative lines from cli/main.rb. All CLI
classes are autoloaded from lib/uniword.rb (parent namespace file).

TODO 05: Eliminate 5 of 8 public_send sites in lib/:
- has_borders.rb: case/when for border sides (top/bottom/left/right/between/bar)
- warning_collector.rb: case/when for log levels (debug/info/warn/error)
- theme_processor.rb: use color_scheme.color_by_name(attr)
- theme_transformation.rb: use word_colors.color_by_name(key)
- footnote_reference_checker.rb: case/when for footnotes/endnotes
Also made ColorScheme#color_by_name public (was private).

TODO 12: Documented 3 remaining public_send sites as legitimate
dynamic dispatch:
- variable_resolver.rb: template property access on arbitrary objects
- element_serializer.rb: schema-driven serialization over Serializable

5460 specs pass, 0 failures.
TODO 04: Eliminated 23 of 30 instance_variable_set/get sites across
11 spec files. Each replaced with the public setter/reader:

- comments_part_spec, comment_spec, tracked_changes_spec: use lutaml-model
  public setters (comment_id=, author=, revision_id=)
- comment_range_spec: use attr_accessor marker_type=
- paragraph_validator_spec, table_validator_spec: use public setters
  (properties=, runs=, rows=)
- link_validator_spec: use bookmarks= setter
- run_builder_spec: use model.drawings instead of ivar_get
- image_embedding_spec: use new attr_reader :show_legend, :width, :height
  on ChartBuilder
- document_context_spec: use new attr_reader :parsed_parts

Remaining 7 sites are legitimate test infrastructure:
- 6 in zip_extractor_spec (Tempfile @Finalizer manipulation — external stdlib)
- 1 in element_validator_spec (class-level registry save/restore)
…ility specs

TODO 02 (partial): Replaced 5 of 65 double() calls:
- element_spec: RecordingVisitor class instead of double('visitor')
- accessibility_rule_spec: real DocumentRoot/Paragraph instead of
  double('Document')/double('Element')

Remaining 60 doubles are in larger files (word_css_spec 14,
image_alt_text_rule_spec 12, math_equation/plurimath 7 each)
that need per-test analysis.
…lity spec

TODO 02 (partial): 3 more doubles replaced:
- accessibility_checker_spec: real DocumentRoot.new instead of
  double('Document') with stubbed images/tables/paragraphs

Total doubles remaining:       59
…_spec

TODO 02 (partial): 4 more doubles replaced with real Drawing/Paragraph
instances. Total fixed: 10 of 65.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant