2009-08-28 48 views
0

對不起,這可能是一個基本/愚蠢/ noob問題 - 我只是想調整一個現有的Ruby腳本 - 它運行在我的Mac上,但無法在Ubuntu 9.04上運行。ruby​​ noob:/usr/lib/ruby/1.8/rss/rss.rb:922:in`have_required_elements?':undefined method

的錯誤是這樣的:

/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的應用程序審查scaper代碼: link text

隨着 link text

感謝拋出一些基本的RSS提要的東西提前任何提示/指針。 Chris

回答

1

錯誤消息是關於String沒有方法「have_required_elements?」。

根據http://www.ruby-doc.org/core-1.9/classes/RSS/Element.html RSS ::元素有一個名稱的方法。您可能在某個時候調用了一個帶有錯誤類型參數的方法。

這行看起來可疑:

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

你想連接兩個字符串?在這種情況下,您應該使用加號而不是逗號。這裏的逗號隱式地生成一個數組。

+0

謝謝 - 現在接下來的問題......但至少這個錯誤已經結束:) – 2009-08-29 19:45:16

相關問題