Sha256: 32a9806066bae848cf2c2df580609660c9e4e6b28230838e850faa307ef61698
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
# Lamppost Lamppost provides basic OPML parsing. It provides a convenience class for straightforward parsing of XML and files, but because it causes a parser class to get registered with Feedjira, it also allows you to take fetch and parse files with Feedjira itself. ### Basic Usage Pass in either a `File` or a `String` ```ruby opml = Lamppost::OPML.new(response.body) ``` You have access to any elements from the OPML's `<head>`. ```ruby title = opml.head.title name = opml.head.owner_name ``` And the outlines from the `<body>` ```ruby opml.outlines.each do |outline| text = outline.text url = outline.xml_url end ``` ### Feedjira Behind the scenes Lampost uses Feedjira parser classes provided by the [feedjira-opml](https://www.github.com/farski/feedjira-opml) gem. That gem registers the OPML parser with Feedjira, so it is available any time Feedjira is used to parse a document. ```ruby # Parse against OPML explicitly Feedjira::Feed.parse_with(Feedjira::Parser::OPML, response.body) ``` ```ruby # Feedjira will implicitly match the OPML parser when # it finds an <opml> tag Feedjira::Feed.parse(response.body) ``` You could also use Feedjira's `fetch_and_parse` method if you'd like.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lamppost-2.0.0 | README.md |
lamppost-1.0.1 | README.md |