Undefined method for a gem?

I’m thinking that the API for this gem has changed, hence the error?
I’m
looking into the documentation. Else, I’m not sure how to approach an
undefined method.

I pulled the code from:

Practical Ruby Gems
http://www.apress.com/book/view/9781590598115

thufir@ARRAKIS:~/rb$
thufir@ARRAKIS:~/rb$ ruby rss2mysql.rb
/var/lib/gems/1.8/gems/feedtools-0.2.29/lib/feed_tools/feed.rb:312:in
load_remote_feed!': undefined method scheme’ for nil:NilClass
(NoMethodError)
from /var/lib/gems/1.8/gems/feedtools-0.2.29/lib/feed_tools/
feed.rb:202:in update!' from /var/lib/gems/1.8/gems/feedtools-0.2.29/lib/feed_tools/ feed.rb:155:in open’
from rss2mysql.rb:32
thufir@ARRAKIS:~/rb$
thufir@ARRAKIS:~/rb$ cat rss2mysql.rb
require ‘rubygems’
require ‘active_record’
require ‘feed_tools’

feed_url = ARGV[0]

This call creates a connection to our database.

ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:host => “127.0.0.1”,
:username => “ruby”, # Note that while this is the default setting for
MySQL,
:password => “password”, # a properly secured system will have a
different MySQL
# username and password, and if so, you’ll need to
# change these settings.
:database => “rss2mysql”)
class Items < ActiveRecord::Base
end

If the table doesn’t exist, we’ll create it.

unless Items.table_exists?
ActiveRecord::Schema.define do
create_table :items do |t|
t.column :title, :string
t.column :content, :string
t.column :source, :string
t.column :url, :string
t.column :timestamp, :timestamp
t.column :keyword_id, :integer
t.column :guid, :string
end
end
end
feed=FeedTools::Feed.open(feed_url)
feed.items.each do |feed_item|
if not (Items.find_by_title(feed_item.title)
or Items.find_by_url(feed_item.link)
or Items.find_by_guid(feed_item.guid))
puts “processing item ‘#{feed_item.title}’ - new”

Items.new do |newitem|
   newitem.title=feed_item.title.gsub(/<[^>]*>/, '')
   newitem.guid=feed_item.guid
   if feed_item.publisher.name
       newitem.source=feed_item.publisher.name
   end
   newitem.url=feed_item.link
   newitem.content=feed_item.description
   newitem.timestamp=feed_item.published
   newitem.save
end

else
puts “processing item ‘#{feed_item.title}’ - old”
end
end

thufir@ARRAKIS:~/rb$

thanks,

Thufir

GROUP gmane.comp.lang.ruby.general
User-Agent: Pan/0.132 (Waxed in Black)

On Sun, 20 Sep 2009 14:40:14 +0900, Thufir wrote:

I pulled the code from:

Practical Ruby Gems
http://www.apress.com/book/view/9781590598115

Chapter 10, parsing feeds.

Ok, a bit silly – I forgot to pass a URL, so it seems to populate the
db. I guess it was trying to send null values to the db?

-Thufir