Strange behavior with Sequel + RSS::Parser

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"?>
<item/>
<item/>
<item/>
<item/>
<item/>
<item/>
---[end] test_case.rb -----------------------------------------

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 D., the author of Ruby2Ruby, for further
help.

best
Sharon

On 10/23/07, Sharon R. [email protected] wrote:

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

I’ve mailed Ryan about it, thanks Sharon!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs