# Strange behavior with Sequel + RSS::Parser

**URL:** <https://www.ruby-forum.com/t/strange-behavior-with-sequel-rss-parser/118038>\
**Category:** Ruby\
**Created:** [October 23, 2007, 2:52pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-sequel-rss-parser/118038 "2007-10-23T14:52:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luispulidoman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dec6dc/32.png) [@luispulidoman](https://www.ruby-forum.com/u/luispulidoman)\
**Post date:** [October 23, 2007, 2:52pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-sequel-rss-parser/118038/1 "2007-10-23T14:52:06Z")

</div>

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 -----------------------------------------

---

<div class="post-metadata">

**Author:** ![luispulidoman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dec6dc/32.png) [@luispulidoman](https://www.ruby-forum.com/u/luispulidoman)\
**Post date:** [October 23, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-sequel-rss-parser/118038/2 "2007-10-23T16:17:02Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![luispulidoman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dec6dc/32.png) [@luispulidoman](https://www.ruby-forum.com/u/luispulidoman)\
**Post date:** [October 23, 2007, 6:24pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-sequel-rss-parser/118038/3 "2007-10-23T18:24:03Z")

</div>

On 10/23/07, Sharon R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

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

I’ve mailed Ryan about it, thanks Sharon!
