0

抱歉,这可能是一个基本/愚蠢/菜鸟问题——我只是想调整一个现有的 Ruby 脚本——它可以在我的 Mac 上运行,但无法在 Ubuntu 9.04 上运行。

错误是这样的:

/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

这是使用 Ruby 的 rss 位并尝试写出 RSS 文件。错误来自文件写入行:

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

这是基于 iPhone app review scaper 代码: link text

链接文本中抛出一些基本的 RSS 提要内容

提前感谢任何提示/指针。克里斯

4

1 回答 1

1

错误消息是关于 String 没有方法“have_required_elements?”。

根据http://www.ruby-doc.org/core-1.9/classes/RSS/Element.html RSS::Element 有一个具有该名称的方法。您可能在某些时候调用了带有错误类型参数的方法。

这条线看起来很可疑:

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

您是否要连接两个字符串?在这种情况下,您应该使用加号操作而不是逗号。这里的逗号隐式生成一个数组。

于 2009-08-28T15:34:29.050 回答