Skip to content

Fix Atom category attribute parsing - #64

Merged
cardmagic merged 1 commit into
masterfrom
fix/atom-category-terms
Sep 13, 2026
Merged

cardmagic merged 1 commit into
masterfrom
fix/atom-category-terms

Conversation

@cardmagic

@cardmagic cardmagic commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

Atom categories store their value in term, but the parser read element text and lost ordinary self-closing categories. Read Atom 1.0 terms so scalar category, array_tags: [:category], and items_by_category work together. Preserve source order and duplicates, skip missing or blank terms, and retain RSS category text, CDATA, and scalar/array behavior.

Resolve default and prefixed namespaces at each entry's actual position in the feed, including local overrides and resets. Keep category extraction within direct children so nested content, source metadata, comments, and neighboring entries cannot supply a category. Reuse the existing link tokenizer for direct-child extraction while retaining relation-link behavior and zero additional runtime dependencies. Update the README and Unreleased changelog.

Validation: the initial regression failed with expected ["ruby", "rails"] and actual nil; it passes after the fix. Added separate failing regressions for namespace declarations in comments and namespace leakage from an RDF channel to sibling items. The full suite passes on Ruby 3.4.8 (136 tests, 310 assertions; 3 existing network-test omissions), along with RuboCop, RBS generation/validation, and Steep. Category values also match namespace-aware XML extraction for all three entries in the archived fork fixture.

Review note: Hound reports single-quote style and test length/complexity limits from its defaults. The repository explicitly requires double quotes and excludes tests from those metrics in .rubocop.yml; the configured CI lint check passes. Those conflicting Hound threads are resolved without changing the project conventions.

Closes #56.

Read category terms from Atom attributes so scalar access, array
collection, and category filtering agree. Preserve RSS text and CDATA
while excluding nested categories and unusable Atom terms.

Resolve namespaces from each entry's actual ancestors, including local
overrides and resets. Share direct-child extraction with relation links
and document the behavior in the README and changelog.

Closes #56
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
Comment thread test/base/category_parsing_test.rb
@greptile-apps

greptile-apps Bot commented Sep 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates category parsing to read Atom 1.0 term attributes while retaining RSS text and CDATA behavior.

  • Restricts category extraction to direct item or entry children.
  • Resolves inherited, overridden, and reset XML namespaces at each entry.
  • Reuses direct-child tokenization for relation links and category extraction.
  • Adds regression coverage for scalar and array categories, filtering, namespace scope, ordering, duplicates, and nested metadata exclusion.
  • Documents the behavior in the README and Unreleased changelog.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete correctness, security, or independently actionable quality issue identified.

The new parser preserves existing relation-link and RSS category behavior while adding focused Atom namespace and term handling backed by boundary and regression coverage.

Important Files Changed

Filename Overview
lib/simple-rss.rb Adds namespace-aware direct-child category extraction and factors relation-link scanning through the shared child-element tokenizer.
test/base/category_parsing_test.rb Adds comprehensive regressions for Atom terms, RSS compatibility, namespace scoping, nested-element exclusion, ordering, duplicates, and filtering.
test/data/atom_categories.xml Provides Atom category fixtures covering attributes, entities, duplicates, blank terms, and prefixed categories.
test/data/rss_categories.xml Provides RSS category fixtures covering text, CDATA, duplicates, scalar behavior, and arrays.
README.md Documents Atom term extraction, RSS compatibility, category filtering, and namespace behavior.
CHANGELOG.md Records the category parsing fix and its compatibility guarantees under Unreleased.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Scan feed for item or entry] --> B[Resolve namespace context at entry position]
  B --> C[Inspect configured item tags]
  C -->|category| D[Tokenize direct child elements]
  D --> E{Category namespace}
  E -->|Atom 1.0| F[Read and normalize term attribute]
  E -->|RSS namespace| G[Read element text or CDATA]
  E -->|Foreign or undeclared prefix| H[Skip category]
  F --> I[Apply scalar or array behavior]
  G --> I
  I --> J[Populate item category]
  C -->|other tag| K[Use existing item-tag parser]
Loading

Reviews (1): Last reviewed commit: "fix: parse Atom category terms" | Re-trigger Greptile

@cardmagic
cardmagic merged commit a2cc690 into master Sep 13, 2026
7 checks passed
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.

Fix Atom category attribute parsing

2 participants