tags:

views:

67

answers:

1

Sorry, this might be a basic/stupid/noob question - I am just trying to tweak an existing Ruby script - it runs on my Mac ok, but failing to run on Ubuntu 9.04.

The error is this:

/usr/lib/ruby/1.8/rss/rss.rb:922:in `have_required_elements?': undefined method `have_required_elements?' for "App Store Reviews for ":String (NoMethodError)
    from /usr/lib/ruby/1.8/rss/maker/base.rb:188:in `any?'
    from /usr/lib/ruby/1.8/rss/rss.rb:922:in `each'
    from /usr/lib/ruby/1.8/rss/rss.rb:922:in `any?'
    from /usr/lib/ruby/1.8/rss/rss.rb:922:in `have_required_elements?'
    from /usr/lib/ruby/1.8/rss/maker/base.rb:188:in `all?'
    from /usr/lib/ruby/1.8/rss/rss.rb:917:in `each'
    from /usr/lib/ruby/1.8/rss/rss.rb:917:in `all?'
    from /usr/lib/ruby/1.8/rss/rss.rb:917:in `have_required_elements?'
    from /usr/lib/ruby/1.8/rss/rss.rb:962:in `tag'
    from /usr/lib/ruby/1.8/rss/rss.rb:884:in `to_s'
    from /usr/lib/ruby/1.8/rss/rss.rb:924:in `have_required_elements?'
    from /usr/lib/ruby/1.8/rss/maker/base.rb:188:in `all?'
    from /usr/lib/ruby/1.8/rss/rss.rb:917:in `each'
    from /usr/lib/ruby/1.8/rss/rss.rb:917:in `all?'
    from /usr/lib/ruby/1.8/rss/rss.rb:917:in `have_required_elements?'
    from /usr/lib/ruby/1.8/rss/rss.rb:962:in `tag'
    from /usr/lib/ruby/1.8/rss/rss.rb:1284:in `tag'
    from /usr/lib/ruby/1.8/rss/rss.rb:884:in `to_s'
    from ./appstore_reviews:215:in `write'
    from ./appstore_reviews:215
    from ./appstore_reviews:214:in `open'
    from ./appstore_reviews:214

Which is using the rss bit of Ruby and trying to write out the RSS file. Error comes from file write line:

...
version = "2.0"
destination = "appreviews_"+ARGV[0]+".xml"
puts destination
content = RSS::Maker.make(version) do |m|
m.items.do_sort = true

# a simple command-line presentation
software.keys.sort.each do |software_key|

m.channel.title = "App Store Reviews for ",software_key
m.channel.link = "http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=",ARGV[1],"&mt=8" # need to put in link to itunes
m.channel.description = "App Store Reviews for ",software_key
...

File.open(destination,"w") do |f|
f.write(content)
end

This is based on the iPhone app review scaper code: link text

With some basic RSS feed stuff thrown in link text

Thanks in advance for any tips/pointers. Chris

+1  A: 

The error message is about String not having a method "have_required_elements?".

According to http://www.ruby-doc.org/core-1.9/classes/RSS/Element.html RSS::Element has a method with that name. You probably call a method with a parameter of wrong type at some point.

This line looks suspicious:

m.channel.title = "App Store Reviews for ",software_key

Are you trying to concatenate two strings? In that case you should use a plus operation instead of a comma. The comma here implicitly generates an array.

Antti Tarvainen
Thanks - onto the next problem now... but at least this error has gone :)
Chris Kimpton