Project

lamppost

0.0
No commit activity in last 3 years
No release in over 3 years
Lamppost is a basic OPML parser that uses Feedjira
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 5.5
~> 10.0

Runtime

 Project Readme

Lamppost

Gem Version Dependency Status Build Status Code Climate Coverage Status

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

opml = Lamppost::OPML.new(response.body)

You have access to any elements from the OPML's <head>.

title = opml.head.title
name = opml.head.owner_name

And the outlines from the <body>

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 gem. That gem registers the OPML parser with Feedjira, so it is available any time Feedjira is used to parse a document.

# Parse against OPML explicitly
Feedjira::Feed.parse_with(Feedjira::Parser::OPML, response.body)
# 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.