{"id":13484478,"url":"https://github.com/cardmagic/simple-rss","last_synced_at":"2026-04-06T06:03:11.424Z","repository":{"id":414916,"uuid":"34412","full_name":"cardmagic/simple-rss","owner":"cardmagic","description":"A simple, flexible, extensible, and liberal RSS and Atom reader for Ruby. It is designed to be backwards compatible with the standard RSS parser, but will never do RSS generation.","archived":false,"fork":false,"pushed_at":"2026-03-29T21:20:10.000Z","size":164,"stargazers_count":229,"open_issues_count":0,"forks_count":66,"subscribers_count":7,"default_branch":"master","last_synced_at":"2026-04-03T19:35:58.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/cardmagic/simple-rss","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cardmagic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2008-07-15T22:24:59.000Z","updated_at":"2026-03-29T21:19:09.000Z","dependencies_parsed_at":"2022-07-07T18:11:29.308Z","dependency_job_id":null,"html_url":"https://github.com/cardmagic/simple-rss","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/cardmagic/simple-rss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardmagic%2Fsimple-rss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardmagic%2Fsimple-rss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardmagic%2Fsimple-rss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardmagic%2Fsimple-rss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cardmagic","download_url":"https://codeload.github.com/cardmagic/simple-rss/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardmagic%2Fsimple-rss/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31461534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"online","status_checked_at":"2026-04-06T02:00:07.287Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:25.029Z","updated_at":"2026-04-06T06:03:11.418Z","avatar_url":"https://github.com/cardmagic.png","language":"Ruby","readme":"# SimpleRSS\n\n[![Gem Version](https://badge.fury.io/rb/simple-rss.svg)](https://badge.fury.io/rb/simple-rss)\n[![CI](https://github.com/cardmagic/simple-rss/actions/workflows/ruby.yml/badge.svg)](https://github.com/cardmagic/simple-rss/actions/workflows/ruby.yml)\n[![License: LGPL](https://img.shields.io/badge/License-LGPL-blue.svg)](https://opensource.org/licenses/LGPL-3.0)\n\nA simple, flexible, extensible, and liberal RSS and Atom reader for Ruby. Designed to be backwards compatible with Ruby's standard RSS parser while handling malformed feeds gracefully.\n\n## Features\n\n- Parses both RSS and Atom feeds\n- Tolerant of malformed XML (regex-based parsing)\n- Built-in URL fetching with conditional GET support (ETags, Last-Modified)\n- JSON and XML serialization\n- Extensible tag definitions\n- Zero runtime dependencies\n\n## What's New in 2.0\n\nVersion 2.0 is a major update with powerful new capabilities:\n\n- **URL Fetching** - One-liner feed fetching with `SimpleRSS.fetch(url)`. Supports timeouts, custom headers, and automatic redirect following.\n\n- **Conditional GET** - Bandwidth-efficient polling with ETag and Last-Modified support. Returns `nil` when feeds haven't changed (304 Not Modified).\n\n- **JSON Serialization** - Export feeds with `to_json`, `to_hash`, and Rails-compatible `as_json`. Time objects serialize to ISO 8601.\n\n- **XML Serialization** - Convert any parsed feed to clean RSS 2.0 or Atom XML with `to_xml(format: :rss2)` or `to_xml(format: :atom)`.\n\n- **Array Tags** - Collect all occurrences of a tag (like multiple categories) with the `array_tags:` option.\n\n- **Attribute Parsing** - Extract attributes from feed, item, and media tags using the `tag#attr` syntax.\n\n- **UTF-8 Normalization** - All parsed content is automatically normalized to UTF-8 encoding.\n\n- **Modern Ruby** - Full compatibility with Ruby 3.1 through 4.0, with RBS type annotations and Steep type checking.\n\n- **Enumerable Support** - Iterate feeds naturally with `each`, `map`, `select`, and all Enumerable methods. Access items by index with `rss[0]` and get the latest items sorted by date with `latest(n)`.\n\n## Installation\n\nAdd to your Gemfile:\n\n```ruby\ngem \"simple-rss\"\n```\n\nOr install directly:\n\n```bash\ngem install simple-rss\n```\n\n## Quick Start\n\n```ruby\nrequire \"simple-rss\"\nrequire \"uri\"\nrequire \"net/http\"\n\n# Parse from a string or IO object\nxml = Net::HTTP.get(URI(\"https://example.com/feed.xml\"))\nrss = SimpleRSS.parse(xml)\n\nrss.channel.title        # =\u003e \"Example Feed\"\nrss.items.first.title    # =\u003e \"First Post\"\nrss.items.first.pubDate  # =\u003e 2024-01-15 12:00:00 -0500 (Time object)\n```\n\n## Usage\n\n### Fetching Feeds\n\nSimpleRSS includes a built-in fetcher with conditional GET support for efficient polling:\n\n```ruby\n# Simple fetch\nfeed = SimpleRSS.fetch(\"https://example.com/feed.xml\")\n\n# With timeout\nfeed = SimpleRSS.fetch(\"https://example.com/feed.xml\", timeout: 10)\n\n# Conditional GET - only download if modified\nfeed = SimpleRSS.fetch(\"https://example.com/feed.xml\")\n# Store these for next request\netag = feed.etag\nlast_modified = feed.last_modified\n\n# On subsequent requests, pass the stored values\nfeed = SimpleRSS.fetch(\n  \"https://example.com/feed.xml\",\n  etag:,\n  last_modified:\n)\n# Returns nil if feed hasn't changed (304 Not Modified)\n```\n\n### Accessing Feed Data\n\nSimpleRSS provides both RSS and Atom style accessors:\n\n```ruby\nfeed = SimpleRSS.parse(xml)\n\n# RSS style\nfeed.channel.title\nfeed.channel.link\nfeed.channel.description\nfeed.items\n\n# Atom style (aliases)\nfeed.feed.title\nfeed.entries\n```\n\n### Item Attributes\n\nItems support both hash and method access:\n\n```ruby\nitem = feed.items.first\n\n# Hash access\nitem[:title]\nitem[:link]\nitem[:pubDate]\n\n# Method access\nitem.title\nitem.link\nitem.pubDate\n```\n\nDate fields are automatically parsed into `Time` objects:\n\n```ruby\nitem.pubDate.class  # =\u003e Time\nitem.pubDate.year   # =\u003e 2024\n```\n\n### Iterating with Enumerable\n\nSimpleRSS includes `Enumerable`, so you can iterate feeds naturally:\n\n```ruby\nfeed = SimpleRSS.parse(xml)\n\n# Iterate over items\nfeed.each { |item| puts item.title }\n\n# Use any Enumerable method\ntitles = feed.map { |item| item.title }\ntech_posts = feed.select { |item| item.category == \"tech\" }\nfirst_five = feed.first(5)\ntotal = feed.count\n\n# Access items by index\nfeed[0].title   # first item\nfeed[-1].title  # last item\n\n# Get the n most recent items (sorted by pubDate or updated)\nfeed.latest(10)\n```\n\n### JSON Serialization\n\n```ruby\nfeed = SimpleRSS.parse(xml)\n\n# Get as hash\nfeed.to_hash\n# =\u003e { title: \"Feed Title\", link: \"...\", items: [...] }\n\n# Get as JSON string\nfeed.to_json\n# =\u003e '{\"title\":\"Feed Title\",\"link\":\"...\",\"items\":[...]}'\n\n# Works with Rails/ActiveSupport\nfeed.as_json\n```\n\n### XML Serialization\n\nConvert parsed feeds to standard RSS 2.0 or Atom format:\n\n```ruby\nfeed = SimpleRSS.parse(xml)\n\n# Convert to RSS 2.0\nfeed.to_xml(format: :rss2)\n\n# Convert to Atom\nfeed.to_xml(format: :atom)\n```\n\n### Extending Tag Support\n\nAdd support for custom or non-standard tags:\n\n```ruby\n# Add a new feed-level tag\nSimpleRSS.feed_tags \u003c\u003c :custom_tag\n\n# Add item-level tags\nSimpleRSS.item_tags \u003c\u003c :custom_item_tag\n\n# Parse tags with specific rel attributes (common in Atom)\nSimpleRSS.item_tags \u003c\u003c :\"link+enclosure\"\n# Accessible as: item.link_enclosure\n\n# Parse tag attributes\nSimpleRSS.item_tags \u003c\u003c :\"media:content#url\"\n# Accessible as: item.media_content_url\n\n# Parse item/entry attributes\nSimpleRSS.item_tags \u003c\u003c :\"entry#xml:lang\"\n# Accessible as: item.entry_xml_lang\n```\n\n#### Tag Syntax Reference\n\n| Syntax | Example | Accessor | Description |\n|--------|---------|----------|-------------|\n| `tag` | `:title` | `.title` | Simple element content |\n| `tag#attr` | `:\"media:content#url\"` | `.media_content_url` | Attribute value |\n| `tag+rel` | `:\"link+alternate\"` | `.link_alternate` | Element with specific `rel` attribute |\n\n### Collecting Multiple Values\n\nBy default, SimpleRSS returns only the first occurrence of each tag. To collect all values:\n\n```ruby\n# Collect all categories for each item\nfeed = SimpleRSS.parse(xml, array_tags: [:category])\n\nitem.category  # =\u003e [\"tech\", \"programming\", \"ruby\"]\n```\n\n## API Reference\n\n### `SimpleRSS.parse(source, options = {})`\n\nParse RSS/Atom content from a string or IO object.\n\n**Parameters:**\n- `source` - String or IO object containing feed XML\n- `options` - Hash of options\n  - `:array_tags` - Array of tag symbols to collect as arrays\n\n**Returns:** `SimpleRSS` instance\n\n### `SimpleRSS.fetch(url, options = {})`\n\nFetch and parse a feed from a URL.\n\n**Parameters:**\n- `url` - Feed URL string\n- `options` - Hash of options\n  - `:timeout` - Request timeout in seconds\n  - `:etag` - ETag from previous request (for conditional GET)\n  - `:last_modified` - Last-Modified header from previous request\n  - `:follow_redirects` - Follow redirects (default: true)\n  - `:headers` - Hash of additional HTTP headers\n\n**Returns:** `SimpleRSS` instance, or `nil` if 304 Not Modified\n\n### Instance Methods\n\n| Method | Description |\n|--------|-------------|\n| `#channel` / `#feed` | Returns self (for RSS/Atom style access) |\n| `#items` / `#entries` | Array of parsed items |\n| `#each` | Iterate over items (includes `Enumerable`) |\n| `#[](index)` | Access item by index |\n| `#latest(n = 10)` | Get n most recent items by date |\n| `#to_json` | JSON string representation |\n| `#to_hash` / `#as_json` | Hash representation |\n| `#to_xml(format:)` | XML string (`:rss2` or `:atom`) |\n| `#etag` | ETag header from fetch (if applicable) |\n| `#last_modified` | Last-Modified header from fetch (if applicable) |\n| `#source` | Original source XML string |\n\n## Compatibility\n\n- Ruby 3.1+\n- No runtime dependencies\n\n## Development\n\n```bash\n# Run tests\nbundle exec rake test\n\n# Run linter\nbundle exec rubocop\n\n# Type checking\nbundle exec steep check\n\n# Interactive console\nbundle exec rake console\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/my-feature`)\n3. Make your changes with tests\n4. Ensure tests pass (`bundle exec rake test`)\n5. Submit a pull request\n\n## Authors\n\n- [Lucas Carlson](mailto:lucas@rufy.com)\n- [Herval Freire](mailto:hervalfreire@gmail.com)\n\nInspired by [Blagg](http://www.raelity.org/lang/perl/blagg) by Rael Dornfest.\n\n## License\n\nThis library is released under the terms of the [GNU LGPL](LICENSE).\n","funding_links":[],"categories":["RSS","Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardmagic%2Fsimple-rss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcardmagic%2Fsimple-rss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardmagic%2Fsimple-rss/lists"}