Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge master

  • Loading branch information...
commit 804711eb0ebc4e03e3e2310ea0b0596d6098db86 2 parents f4565aa + 05f87de
Ezekiel Templin authored February 28, 2013
1  HISTORY.md
Source Rendered
... ...
@@ -1,4 +1,5 @@
1 1
 # HEAD
  2
+* Compatibility fixes for Ruby 2.0 [[#136](https://github.com/pauldix/feedzirra/pull/136)].
2 3
 * Remove gorillib dependency [[#113](https://github.com/pauldix/feedzirra/pull/113)].
3 4
 
4 5
 # 0.2.0.rc2
3  feedzirra.gemspec
@@ -6,12 +6,11 @@ Gem::Specification.new do |s|
6 6
   s.version = Feedzirra::VERSION
7 7
 
8 8
   s.authors  = ['Paul Dix', 'Julien Kirch', "Ezekiel Templin"]
9  
-  s.date     = '2013-02-28'
10 9
   s.email    = 'feedzirra@googlegroups.com'
11 10
   s.homepage = 'http://github.com/pauldix/feedzirra'
12 11
 
13 12
   s.summary     = 'A feed fetching and parsing library'
14  
-  s.description = 'A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all.'
  13
+  s.description = 'A library designed to retrieve and parse feeds as quickly as possible'
15 14
 
16 15
   s.files         = `git ls-files`.split("\n")
17 16
   s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
15  lib/feedzirra/feed_utilities.rb
@@ -29,9 +29,9 @@ def update_from_feed(feed)
29 29
       self.entries.unshift(*self.new_entries)
30 30
 
31 31
       @updated = false
  32
+
32 33
       UPDATABLE_ATTRIBUTES.each do |name|
33  
-        updated = update_attribute(feed, name)
34  
-        @updated ||= updated
  34
+        @updated ||= update_attribute(feed, name)
35 35
       end
36 36
     end
37 37
 
@@ -40,6 +40,9 @@ def update_attribute(feed, name)
40 40
 
41 41
       if old_value != new_value
42 42
         send("#{name}=", new_value)
  43
+        true
  44
+      else
  45
+        false
43 46
       end
44 47
     end
45 48
 
@@ -54,19 +57,19 @@ def find_new_entries_for(feed)
54 57
       # it's to get around the fact that not all feeds have a published date.
55 58
       # however, they're always ordered with the newest one first.
56 59
       # So we go through the entries just parsed and insert each one as a new entry
57  
-      # until we get to one that has the same url as the the newest for the feed
  60
+      # until we get to one that has the same id as the the newest for the feed
58 61
       return feed.entries if self.entries.length == 0
59 62
       latest_entry = self.entries.first
60 63
       found_new_entries = []
61 64
       feed.entries.each do |entry|
62  
-        break if entry.url == latest_entry.url
  65
+        break if entry.id == latest_entry.id
63 66
         found_new_entries << entry
64 67
       end
65 68
       found_new_entries
66 69
     end
67 70
 
68 71
     def existing_entry?(test_entry)
69  
-      entries.any? { |entry| entry.url == test_entry.url }
  72
+      entries.any? { |entry| entry.id == test_entry.id }
70 73
     end
71 74
   end
72  
-end
  75
+end
45  spec/feedzirra/feed_utilities_spec.rb
@@ -146,5 +146,48 @@
146 146
         @feed.entries.should include(@old_entry)
147 147
       end
148 148
     end
  149
+
  150
+    describe "changing the url of an existing entry" do
  151
+      before(:each) do
  152
+        # I'm using the Atom class when I know I should be using a different one. However, this update_from_feed
  153
+        # method would only be called against a feed item.
  154
+        @feed = Feedzirra::Parser::Atom.new
  155
+        @feed.title    = "A title"
  156
+        @feed.url      = "http://pauldix.net"
  157
+        @feed.feed_url = "http://feeds.feedburner.com/PaulDixExplainsNothing"
  158
+        @feed.updated  = false
  159
+        @updated_feed = @feed.dup
  160
+
  161
+        @old_entry = Feedzirra::Parser::AtomEntry.new
  162
+        @old_entry.url = "http://pauldix.net/old.html"
  163
+        @old_entry.published = (Time.now - 10).to_s
  164
+
  165
+        @entry = Feedzirra::Parser::AtomEntry.new
  166
+        @entry.published = (Time.now + 10).to_s
  167
+        @entry.entry_id = "entry_id"
  168
+        @entry.url = "http://pauldix.net/entry.html"
  169
+
  170
+        # only difference is a changed url
  171
+        @entry_changed_url = @entry.dup
  172
+        @entry_changed_url.url = "http://pauldix.net/updated.html"
  173
+
  174
+        # entry with changed url must be first
  175
+        @feed.entries << @entry
  176
+        @feed.entries << @old_entry
  177
+        @updated_feed.entries << @entry_changed_url
  178
+        @updated_feed.entries << @old_entry
  179
+      end
  180
+
  181
+      it "should not put the complete feed into new_entries" do
  182
+        @feed.update_from_feed(@updated_feed)
  183
+
  184
+        @feed.new_entries.should_not include(@entry_changed_url)
  185
+        @feed.new_entries.should_not include(@old_entry)
  186
+
  187
+        # don't return complete feed
  188
+        @feed.new_entries.size.should == 0
  189
+        @feed.new_entries.size.should_not == 2
  190
+      end
  191
+    end
149 192
   end
150  
-end
  193
+end

0 notes on commit 804711e

Please sign in to comment.
Something went wrong with that request. Please try again.