Permalink
Browse files

Merge master

  • Loading branch information...
2 parents f4565aa + 05f87de commit 804711eb0ebc4e03e3e2310ea0b0596d6098db86 @ezkl ezkl committed Feb 28, 2013
Showing with 55 additions and 9 deletions.
  1. +1 −0 HISTORY.md
  2. +1 −2 feedzirra.gemspec
  3. +9 −6 lib/feedzirra/feed_utilities.rb
  4. +44 −1 spec/feedzirra/feed_utilities_spec.rb
View
@@ -1,4 +1,5 @@
# HEAD
+* Compatibility fixes for Ruby 2.0 [[#136](https://github.com/pauldix/feedzirra/pull/136)].
* Remove gorillib dependency [[#113](https://github.com/pauldix/feedzirra/pull/113)].
# 0.2.0.rc2
View
@@ -6,12 +6,11 @@ Gem::Specification.new do |s|
s.version = Feedzirra::VERSION
s.authors = ['Paul Dix', 'Julien Kirch', "Ezekiel Templin"]
- s.date = '2013-02-28'
s.email = 'feedzirra@googlegroups.com'
s.homepage = 'http://github.com/pauldix/feedzirra'
s.summary = 'A feed fetching and parsing library'
- s.description = 'A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all.'
+ s.description = 'A library designed to retrieve and parse feeds as quickly as possible'
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -29,9 +29,9 @@ def update_from_feed(feed)
self.entries.unshift(*self.new_entries)
@updated = false
+
UPDATABLE_ATTRIBUTES.each do |name|
- updated = update_attribute(feed, name)
- @updated ||= updated
+ @updated ||= update_attribute(feed, name)
end
end
@@ -40,6 +40,9 @@ def update_attribute(feed, name)
if old_value != new_value
send("#{name}=", new_value)
+ true
+ else
+ false
end
end
@@ -54,19 +57,19 @@ def find_new_entries_for(feed)
# it's to get around the fact that not all feeds have a published date.
# however, they're always ordered with the newest one first.
# So we go through the entries just parsed and insert each one as a new entry
- # until we get to one that has the same url as the the newest for the feed
+ # until we get to one that has the same id as the the newest for the feed
return feed.entries if self.entries.length == 0
latest_entry = self.entries.first
found_new_entries = []
feed.entries.each do |entry|
- break if entry.url == latest_entry.url
+ break if entry.id == latest_entry.id
found_new_entries << entry
end
found_new_entries
end
def existing_entry?(test_entry)
- entries.any? { |entry| entry.url == test_entry.url }
+ entries.any? { |entry| entry.id == test_entry.id }
end
end
-end
+end
@@ -146,5 +146,48 @@
@feed.entries.should include(@old_entry)
end
end
+
+ describe "changing the url of an existing entry" do
+ before(:each) do
+ # I'm using the Atom class when I know I should be using a different one. However, this update_from_feed
+ # method would only be called against a feed item.
+ @feed = Feedzirra::Parser::Atom.new
+ @feed.title = "A title"
+ @feed.url = "http://pauldix.net"
+ @feed.feed_url = "http://feeds.feedburner.com/PaulDixExplainsNothing"
+ @feed.updated = false
+ @updated_feed = @feed.dup
+
+ @old_entry = Feedzirra::Parser::AtomEntry.new
+ @old_entry.url = "http://pauldix.net/old.html"
+ @old_entry.published = (Time.now - 10).to_s
+
+ @entry = Feedzirra::Parser::AtomEntry.new
+ @entry.published = (Time.now + 10).to_s
+ @entry.entry_id = "entry_id"
+ @entry.url = "http://pauldix.net/entry.html"
+
+ # only difference is a changed url
+ @entry_changed_url = @entry.dup
+ @entry_changed_url.url = "http://pauldix.net/updated.html"
+
+ # entry with changed url must be first
+ @feed.entries << @entry
+ @feed.entries << @old_entry
+ @updated_feed.entries << @entry_changed_url
+ @updated_feed.entries << @old_entry
+ end
+
+ it "should not put the complete feed into new_entries" do
+ @feed.update_from_feed(@updated_feed)
+
+ @feed.new_entries.should_not include(@entry_changed_url)
+ @feed.new_entries.should_not include(@old_entry)
+
+ # don't return complete feed
+ @feed.new_entries.size.should == 0
+ @feed.new_entries.size.should_not == 2
+ end
+ end
end
-end
+end

0 comments on commit 804711e

Please sign in to comment.