Feedjira::Opml

Gem Version Dependency Status Build Status Code Climate Coverage Status

This gem registers a new parser with Feedjira which provides basic support for OPML files. It is based on OPML version 2.0, but does not currently support all aspects of the specification (directories, for example, are not supported).

Beyond what is provided by Feedjira, there is no support for converting OPML files to hashes, or generating valid OPML from other data sources.

Usage

Since feedjira-opml automatically registers its OPML parser with Feedjira, using the standard processing methods should generally yield the desired results.

ruby Feedjira::Feed.parse(string_of_xml)

The OPML parser will match on /\<opml/, so it won’t conflict with RSS, Atom, or other native Feedjira parsers.

If its necessary to use the OPML parser explicitly:

ruby Feedjira::Feed.parse_with(Feedjira::Parser::OPML, string_of_xml)

Output

All elements and attributes are typecast based on the OPML specification. The behavior for handling values that don’t adhere to the spec is undefined.

ruby @opml.head.title @opml.head.owner_name @opml.head.date_created # Returns a Time @opml.head.expansion_state # Returns an Array

Working with outlines is similar.

```ruby outline = @opml.body.outlines.first

url = outline.xml_url # Returns a URI ```

The isComment and isBreakpoint attributes are converted to booleans and accessed through convenience methods.

ruby is_comment = outline.comment?

There are certain situations where the spec requires certain values meet some criteria based on other values, (e.g. “An outline element whose type is link must have a url attribute whose value is an http address.”). These requirements are not currently enforced by the parser.