aasmith / feed-normalizer Goto Github PK
View Code? Open in Web Editor NEWExtensible Ruby wrapper for Atom and RSS parsers
Home Page: http://feed-normalizer.rubyforge.org/
License: BSD 3-Clause "New" or "Revised" License
Extensible Ruby wrapper for Atom and RSS parsers
Home Page: http://feed-normalizer.rubyforge.org/
License: BSD 3-Clause "New" or "Revised" License
Current gem version is two years old, and there were some improvements for this time.
Maybe, it's possible to release it?
any chance you can update the current gem on rubygems.org? The latest gem only has changes up until January 2010.
Hello,
I've aggregating two feeds and sorting them by date. Here's the code:
feeds = [
'http://blog.woralelandia.com/tag/mi-musica/feed/',
'http://mexicoindie.net/feed/'
]
stories = []
feeds.each do |f|
feed = FeedNormalizer::FeedNormalizer.parse f
stories.push( *feed.entries )
end
stories.sort_by! { |k| k[ :date_published ] }
SystemStackError: stack level too deep
from /home/renich/.gem/ruby/2.2.0/gems/feed-normalizer-1.5.2/lib/structures.rb:14:in `rescue in method_missing'
I am getting 20 stories so it shouldn't be much. Could you help me out with this and maybe add a suggestion at the readme?
I ran into this while processing a twitter feed where someone had managed to inject new-line characters into the tweet.
Here's the content in question:
"AppWireless: The following stores will have the Motorola Milestone by this afternoon: \nGordon’s\n Photo, Hazard, Harlan,... http://fb.me/HmcxV9X8"
When I run clean on that, I get:
>> FeedNormalizer::HtmlCleaner.clean str
NoMethodError: undefined method traverse_element' for nil:NilClass from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/whiny_nil.rb:52:in
method_missing'
from /usr/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpricot/traverse.rb:313:in /' from /usr/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpricot/traverse.rb:310:in
each'
from /usr/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpricot/traverse.rb:310:in /' from /usr/lib/ruby/gems/1.8/gems/feed-normalizer-1.5.2/lib/html-cleaner.rb:164:in
remove_tags!'
from /usr/lib/ruby/gems/1.8/gems/feed-normalizer-1.5.2/lib/html-cleaner.rb:72:in `clean'
from (irb):82
From what I can tell, the problem stems from this regular expression in #clean:
# get all the tags in the document
# Somewhere near hpricot 0.4.92 "" starting to return all elements,
# including text nodes instead of just tagged elements.
tags = (doc/"").inject([]) { |m,e| m << e.name if(e.respond_to?(:name) && e.name =~ /^\w+$/) ; m }.uniq
Which is matching against the full text node, and matches "Gordon's" since it is wrapped in newlines. I'm guessing the regular expression is there to try to filter out text nodes? If so, I'd suggest changing the pattern to
/\A\w+\Z/
To force the match against to whole string. Unless there's a cleaner way to filter out text nodes?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.