Module: Yarss
- Defined in:
- lib/yarss.rb,
lib/yarss/feed.rb,
lib/yarss/item.rb,
lib/yarss/version.rb,
lib/yarss/attribute.rb,
lib/yarss/rdf/feed_parser.rb,
lib/yarss/rdf/item_parser.rb,
lib/yarss/rss/feed_parser.rb,
lib/yarss/rss/item_parser.rb,
lib/yarss/atom/feed_parser.rb,
lib/yarss/atom/item_parser.rb
Overview
RSS, RDF and Atom feeds parser.
Defined Under Namespace
Modules: Atom, Attribute, Rdf, Rss Classes: Error, Feed, Item, ParseError, UnknownParserError
Constant Summary collapse
- VERSION =
Version number, happy now?
'0.0.2'
Class Method Summary collapse
-
.from_file(path) ⇒ Feed
Parse a Feed out of a path to a XML.
-
.from_io(io) ⇒ Feed
Parse a Feed out of an IO (or whatever responds to
read
). -
.from_string(data, path_or_io = nil) ⇒ Feed
Parse a Feed out of raw XML.
-
.new(path_or_io) ⇒ Feed
Parse a Feed out of a path to a XML or an IO (or whatever responds to
read
).
Class Method Details
.from_file(path) ⇒ Feed
Parse a Feed out of a path to a XML.
92 93 94 95 |
# File 'lib/yarss.rb', line 92 def self.from_file(path) data = File.read(path) from_string(data, path) end |
.from_io(io) ⇒ Feed
Parse a Feed out of an IO (or whatever responds to read
).
69 70 71 72 |
# File 'lib/yarss.rb', line 69 def self.from_io(io) data = io.read from_string(data, io) end |
.from_string(data, path_or_io = nil) ⇒ Feed
Parse a Feed out of raw XML.
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/yarss.rb', line 116 def self.from_string(data, path_or_io = nil) data = MultiXml.parse(data) return Rss::FeedParser.new(data).parse if data['rss'] return Atom::FeedParser.new(data).parse if data['feed'] return Rdf::FeedParser.new(data).parse if data['rdf:RDF'] || data['RDF'] msg = "Cannot find parser for #{path_or_io}" if path_or_io raise UnknownParserError, msg rescue MultiXml::ParseError => e raise ParseError, e end |