Hi,
I released RSS Parser 0.1.7:
http://raa.ruby-lang.org/project/rss/
Here are new features:
- Atom support
- (official) DublinCore module with RSS 2.0 support
- New convenience methods to convert feed type: to_xml,
to_feed, to_rss, to_atom and to_xml.
Here are changes:
- dc_rightses → dc_rights_list: Thanks to Mathieu Bouchard!
- Stop ruby 1.6.x support
= Details
== Atom support
Atom support means the followings:
- RSS::Parser.parse can parse Atom feed document with
validation. - RSS::Parser.parse can parse Atom entry document with
validation. - RSS::Maker.make can make Atom feed document.
- RSS::Maker.make can make Atom entry document.
To support Atom, I changed the following reading APIs of RSS
Maker:
- maker.channel.title
- maker.channel.description
- maker.channel.copyright
- item.title
- item.link
- item.description
- item.rights
They return a String or nil since 0.1.6. But They always
return an object.
I think this change doesn’t have big impact because most of
users don’t use them. They always use only writer APIs.
== DublinCore module with RSS 2.0 support
RSS Parser parses DublinCore module in RSS 2.0 now
officially. We need to require some files. We can just write
the following:
require ‘rss’
feed = RSS::Parser.parse(…)
== Feed conversion
We can convert RSS 1.0 to RSS 2.0 by the following code:
rss20 = rss10.to_rss(“2.0”)
We can convert RSS 1.0 to Atom feed document by the
following code:
feed = rss10.to_atom(“feed”)
But you may need to set some values required by returned
feed type but not required by converted feed. For example,
/rss/item/title isn’t required value in RSS 2.0 but
/rdf:RDF/item/title is required value in RSS 1.0. In the
situation, we can set default value like the following:
rss10 = rss20.to_rss(“1.0”) do |maker|
maker.items.each do |item|
item.title.content ||= “Default Title”
end
end
Thanks,