2011-01-19 19 views
0

使用Ruby 1.8,FeedTools可以獲取並解析RSS/atom feed鏈接,並指定非饋送鏈接。對於如:FeedTools的行爲與JRuby不同

ruby-1.8.7-p174 > f = FeedTools::Feed.open("http://techcrunch.com/") 
=> #<FeedTools::Feed:0xc99cf8 URL:http://feeds.feedburner.com/TechCrunch> 
ruby-1.8.7-p174 > f.title 
=> "TechCrunch" 

然而,使用JRuby 1.5.2,FeedTools無法獲取並解析RSS /給非饋環節的Atom feed鏈接。對於如:

jruby-1.5.2 > f = FeedTools::Feed.open("http://techcrunch.com/")        
=> #<FeedTools::Feed:0x1206 URL:http://techcrunch.com/> 
jruby-1.5.2 > f.title           
=> nil 

有時,它也提供了以下錯誤:

FeedTools::FeedAccessError: [URL] does not appear to be a feed.

我如何能得到FeedTools使用JRuby工作任何想法?

回答

1

feedtools gem似乎存在一個錯誤。在用給定MIME類型定位供稿鏈接的方法中,當找到供稿鏈接時,將'lambda'替換爲'Proc.new'以從proc內部的方法返回。

--- a/feedtools-0.2.29/lib/feed_tools/helpers/html_helper.rb 
+++ b/feedtools-0.2.29/lib/feed_tools/helpers/html_helper.rb 
@@ -620,7 +620,7 @@ 
     end 
     end 
     get_link_nodes.call(document.root) 
-  process_link_nodes = lambda do |links| 
+  process_link_nodes = Proc.new do |links| 
     for link in links 
      next unless link.kind_of?(REXML::Element) 
      if link.attributes['type'].to_s.strip.downcase ==