forked from jmhodges/rfeedparser
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
62 lines (50 loc) · 5.44 KB
/
Copy pathindex.html
File metadata and controls
62 lines (50 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="author" content="Jeff Hodges (http://somethingsimilar.com)"><title>Universal Feed Parser in Ruby</title></head><body>
<h2>Introduction to rFeedParser, the Universal Feed Parser in Ruby</h2>
<p>rFeedParser is a translation of Mark Pilgrim's <a href="http://feedparser.org/">Universal Feed Parser</a> from Python into Ruby. It has nearly the exact same behavior.</p>
<p>Example code:</p>
<p><pre> require 'rubygems'
require 'rfeedparser'
pf = FeedParser.parse(a_url_file_stream_or_string)
# Or
pf = rfp(a_url_file_stream_or_string)
# These next four lines are equivalent.
pf.entries.each{ |e| puts e.title }
pf.entries.each{ |e| puts e['title'] }
pf['entries'].each{ |e| puts e.title }
pf['entries'].each{ |e| puts e['title'] }
</pre></p>
<p><strong>Notes on XML Parsers:</strong> Because of rfeedparser's ability to work with multiple available XML parsers, we do not include one as a requirement. This is an unfortunate side effect of the <code>expat</code> XML bindings not being a ruby gem and the <code>rubygems</code> package management system having no way to specify that one of multiple gems would satisfy a dependency requirement. You'll have to install the <code>libxml-ruby</code> gem manually, or install the <code>expat</code> XML bindings. The <code>expat</code> bindings are available on OS X as <code>rb-xmlparser</code> in MacPorts, or on a Ubuntu or Debian system as the <code>libxml-parser-ruby1.8</code> package.</p>
<p><strong>Notes on Time/Date Storage:</strong> The storage of dates in the *_parsed items (such as, updated_parsed, created_parsed, etc.) are in the Python 9-tuple format. While this is great for passing the date tests, Ruby has no good way of understanding these things. There is now a "_time" key next to every key containing a Python datetime 9-tuple that contains a Ruby Time object. So, if you see <code>updated</code> or <code>updated_parsed</code>, you can also find a <code>updated_time</code> right next door.</p>
<p>More documentation can be found over at the <a href="http://feedparser.org/docs/">Feed Parser documentation</a> site.</p>
<p>There is one extra thing. You can subclass <code>StrictFeedParser</code> or <code>LooseFeedParser</code> and pass it to <code>FeedParser#parse</code> with the keys <code>:strict</code> and <code>:loose</code> and your subclass will be used to parse the feeds in its respective case.</p>
<p>The latest release can is <a href="http://rubyforge.org/frs/?group_id=3309">0.9.952</a> and you can track new releases, send bug reports or just yell at me belligerently over at the <a href="http://rubyforge.org/projects/rfeedparser/">rFeedParser project page</a>.</p>
<h2>Depedencies and Installation</h2>
<p>rfeedparser has undergone some major changes and now supports not only the expat XML parser, but the new, better version of libxml-ruby. We've also dropped the ActiveSupport gem through sheer awesomeness. rfp is now quite a bit less than a Frankenstein's monster.</p>
<p>The <code>libxml-ruby</code>
<p>The rest of the gems are as follows:</p>
<ul>
<li><a href="http://code.whytheluckystiff.net/hpricot/">Hpricot</a></li>
<li><a href="http://rubyforge.org/projects/char-encodings/">Character-Encodings</a></li>
<li><a href="http://rubyforge.org/projects/ruby-htmltools">HTMLTools</a></li>
<li><a href="http://htmlentities.rubyforge.org/">HTMLEntities</a></li>
</ul>
<p>These dependencies are all being used because they allow for (mostly) UTF-8 safe parsing and speed out the wazoo. rFeedParser runs at roughly the same pace as the Python Feed Parser in its best configuration. Of course, rFeedParser is quite a bit faster and more complete than the other Ruby feed parsers available.</p>
<p>Well, enough talk. Go code. And get a hold of me through the <a href="http://rubyforge.org/projects/rfeedparser/">project page</a> or <a href="http://www.somethingsimilar.com/wordpress/contact/">my contact form</a> if you have questions.</p>
<h2>Tests and Completeness</h2>
<p>For the curious, rFeedParser's XML test cases are exactly the same XML
files that the original Universal Feed Parser is tested against. It
currently succeeds on 98.7% of the tests, with some of the failures
coming from "superficial" problems ("would pass if this little twiddly
bit that doesn't mean anything was different"). I hope to correct these
in the near future. I should point out here that this large of a
success rate over such a mature and complex testing environment makes
rFeedParser, by far, the most viable of the current crop of Ruby feed
parsers.</p>
<p>I'll be blogging about all the coolness I was
able to create from Sam Ruby's pirate testing ideas, Hpricot and
so on. Links will be appearing as I write them.</p>
<p>And, lo, the first link, <a href="http://www.somethingsimilar.com/wordpress/2007/07/22/on-rfeedparser/">On rFeedParser</a>, did appear. And, it was way a bit long but, otherwise okay.</p>
</body></html>