Skip to content

feat: add URL fetching with conditional GET support#51

Merged
cardmagic merged 5 commits into
masterfrom
feature/url-fetching
Dec 29, 2025
Merged

feat: add URL fetching with conditional GET support#51
cardmagic merged 5 commits into
masterfrom
feature/url-fetching

Conversation

@cardmagic
Copy link
Copy Markdown
Owner

Summary

Add the ability to fetch and parse feeds directly from URLs, with support for conditional GET (ETag/Last-Modified) for efficient polling.

Usage

# Simple fetch
rss = SimpleRSS.fetch("https://news.ycombinator.com/rss")
rss.title  # => "Hacker News"

# Access caching headers for later
rss.etag           # => "\"abc123\""
rss.last_modified  # => "Wed, 21 Oct 2015 07:28:00 GMT"

# Conditional GET - returns nil if unchanged (304)
rss = SimpleRSS.fetch(url, etag: rss.etag, last_modified: rss.last_modified)
# Returns nil if unchanged, new feed if updated

Options

  • timeout: - connection/read timeout in seconds
  • headers: - custom headers hash (e.g., { "Authorization" => "Bearer ..." })
  • follow_redirects: - follow 301/302 redirects (default: true, max 5)
  • etag: - ETag for conditional GET
  • last_modified: - Last-Modified for conditional GET

Features

  • One-liner feed fetching
  • Bandwidth-efficient polling with conditional GET
  • Automatic redirect following (up to 5)
  • HTTPS support
  • Custom timeout and headers
  • Stores ETag/Last-Modified on parsed feed for subsequent requests

Test plan

  • 73 tests, 152 assertions pass
  • RuboCop passes
  • Steep type checking passes
  • Integration tests available with NETWORK_TESTS=1

Closes #46

- SimpleRSS.fetch(url) - fetch and parse feeds directly from URLs
- Conditional GET with etag: and last_modified: options
- Returns nil on 304 Not Modified for efficient polling
- Options: timeout:, headers:, follow_redirects:
- Automatically follows redirects (up to 5)
- Stores ETag and Last-Modified headers on parsed feed

Usage:
  rss = SimpleRSS.fetch("https://example.com/feed.xml")

  # Later, conditional fetch:
  rss = SimpleRSS.fetch(url, etag: rss.etag)
  # Returns nil if unchanged

Closes #46
Replace legacy README.markdown with modern README.md following
open source standards. Adds badges, structured sections, and
complete API reference covering all features including the new
URL fetching, JSON/XML serialization, and tag extensibility.

Updates code examples to Ruby 3.4 conventions (modern requires,
shorthand hash syntax, URI/Net::HTTP instead of open-uri).

Also updates gemspec: HTTPS homepage, removes deprecated
rubyforge_project, adds required_ruby_version >= 3.1.
Highlight major features added in version 2.0: URL fetching with
conditional GET, JSON/XML serialization, array tags, attribute
parsing, UTF-8 normalization, and Ruby 3.1-4.0 compatibility.
@cardmagic cardmagic merged commit 19a2b79 into master Dec 29, 2025
6 checks passed
@cardmagic cardmagic deleted the feature/url-fetching branch December 29, 2025 09:00
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.

Add URL fetching with conditional GET support

1 participant