Back to Source Monitor

item-creator-extraction

.vbw-planning/milestones/03-coverage-analysis-quick-wins-critical-path-test-co/phases/04-code-quality-conventions-cleanup/PLAN-02-SUMMARY.md

0.13.02.1 KB
Original Source

Plan 02 Summary: item-creator-extraction

What Was Done

Extracted ItemCreator (601 lines, 50+ methods) into two focused sub-modules following the FeedFetcher extraction pattern from Phase 3.

Files Created

  • lib/source_monitor/items/item_creator/entry_parser.rb (390 lines) -- All field extraction methods (extract_guid, extract_url, extract_authors, etc.) plus utility methods (string_or_nil, safe_integer, split_keywords, etc.)
  • lib/source_monitor/items/item_creator/content_extractor.rb (113 lines) -- Feed content processing through readability (process_feed_content, wrap_content_for_readability, etc.)

Files Modified

  • lib/source_monitor/items/item_creator.rb -- Slimmed from 601 to 174 lines. Now contains only orchestration logic (find/create/update items), Result struct, constants, and forwarding methods for backward compatibility with tests.

Line Counts

FileBeforeAfter
item_creator.rb601174
entry_parser.rb--390
content_extractor.rb--113
Total601677

Architecture

  • EntryParser receives source:, entry:, and content_extractor: -- exposes parse returning full attributes hash
  • ContentExtractor receives source: -- exposes process_feed_content(raw_content, title:)
  • ItemCreator delegates build_attributes to entry_parser.parse via lazy accessor
  • Forwarding methods on ItemCreator preserve backward compatibility for tests that call private methods via send

Test Results

  • ItemCreator tests: 78 runs, 258 assertions, 0 failures, 0 errors
  • Full suite: 757 runs, 2630 assertions, 0 errors, 0 failures related to extraction (1 pre-existing paginator test-ordering sensitivity)
  • RuboCop: 363 files inspected, no offenses detected

Success Criteria

  • ItemCreator main file under 300 lines (174)
  • Two sub-modules created: entry_parser.rb, content_extractor.rb
  • Public API unchanged -- ItemCreator.call(source:, entry:) returns Result struct
  • All existing tests pass without modification
  • Full test suite passes (757 runs, 0 errors)
  • RuboCop passes on all modified/new files