Strange behavior with Sequel + RSS::Parser

L

Luis Parravicini

Hi

I'm having a strange behavior when using RSS::parser after requiring
the sequel gem. After doing a require 'sequel', the number of news
items is always 0. The script below is a small test which reads a rss
feed with 6 items and prints the number of news items parsed. The
first puts is after requiring 'rss', and the last puts is after
requiring 'sequel'.

# require 'rss'
read 6, should be: 6
# require 'rubygems'
read 6, should be: 6
# require 'sequel'
read 0, should be: 6

I've run this script with:
sequel 0.2.1.1 and ruby 1.8.5 (2006-08-25) [i486-linux]
sequel 0.3.0.1 and ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux]

Anyone seen this before?

Thanks


---[begin] test_case.rb -----------------------------------------
ITEMS = 6

def rss_items
rss = RSS::parser.parse(IO.readlines('feed.xml').join)
rss.items.size
end

def compare(items)
puts "read #{items}, should be: #{ITEMS}"
end


require 'rss'
compare(rss_items)

require 'rubygems'
compare(rss_items)

require 'sequel'
compare(rss_items)
---[end] test_case.rb -----------------------------------------

---[begin] feed.xml -----------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="0.91">
<channel>
<title/>
<description/>
<link/>

<item/>
<item/>
<item/>
<item/>
<item/>
<item/>

</channel>
</rss>
---[end] test_case.rb -----------------------------------------
 
S

Sharon Rosner

I'm having a strange behavior when using RSS::parser after requiring
the sequel gem. After doing a require 'sequel', the number of news
items is always 0. The script below is a small test which reads a rss
feed with 6 items and prints the number of news items parsed. The
first puts is after requiring 'rss', and the last puts is after
requiring 'sequel'.

I've traced this problem down to the ruby2ruby gem, which is used by
Sequel. The Ruby2Ruby code contains the following trick:

class NilClass # Objective-C trick
def method_missing(msg, *args, &block)
nil
end
end

Try to add this bit to your code instead of requiring Sequel and
you'll see the same behavior. It seems the RSS parser relies on nil
raising an error for invalid calls, and the monkey patch for
NilClass#method_missing screws things up.

I suggest you contact Ryan Davis, the author of Ruby2Ruby, for further
help.

best
Sharon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top