jsl-feedzirra 0.0.12.10 → 0.0.12.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ module Feedzirra
3
3
  UPDATABLE_ATTRIBUTES = %w(title feed_url url last_modified)
4
4
 
5
5
  attr_writer :updated, :last_modified, :entries
6
+
6
7
  attr_accessor :etag
7
8
 
8
9
  def initialize
@@ -26,15 +27,15 @@ module Feedzirra
26
27
  def updated?
27
28
  @updated
28
29
  end
29
-
30
+
30
31
  def new_entries
31
32
  @entries.select{ |e| e.new_entry? }
32
33
  end
33
-
34
+
34
35
  def has_new_entries?
35
36
  new_entries.size > 0
36
37
  end
37
-
38
+
38
39
  def update_from_feed(feed)
39
40
  # Mark all existing entries as old, then add new entries, which are
40
41
  # marked as new by default.
@@ -43,41 +44,41 @@ module Feedzirra
43
44
  find_new_entries_for(feed).each do |e|
44
45
  self.entries << e
45
46
  end
46
-
47
- updated! if UPDATABLE_ATTRIBUTES.any? { |name| update_attribute(feed, name) }
47
+
48
+ updated! if UPDATABLE_ATTRIBUTES.map { |name| update_attribute(feed, name) }.any?
48
49
  end
49
-
50
+
50
51
  def update_attribute(feed, name)
51
52
  old_value, new_value = send(name), feed.send(name)
52
-
53
+
53
54
  if old_value != new_value
54
55
  send("#{name}=", new_value)
55
56
  end
56
57
  end
57
-
58
+
58
59
  def sanitize_entries!
59
60
  entries.each {|entry| entry.sanitize!}
60
61
  end
61
-
62
+
62
63
  private
63
-
64
+
64
65
  def updated!
65
66
  @updated = true
66
67
  end
67
-
68
+
68
69
  def find_new_entries_for(feed)
69
70
  # This implementation is a hack to get around the fact that not all feeds
70
71
  # have a published date - we exploit the fact that feeds are always
71
72
  # ordered with newest element first to work backwards until we reach feed urls
72
- # that we've already seen.
73
- feed.entries.reverse.inject([]) do |res, entry|
74
- break res if entry.url == self.entries.first.url
75
- res << entry
73
+ # that we've already seen.
74
+ unless self.entries.first.nil?
75
+ feed.entries.reverse.inject([]) do |res, entry|
76
+ break res if entry.url == self.entries.first.url
77
+ res << entry
78
+ end
79
+ else
80
+ self.entries
76
81
  end
77
82
  end
78
-
79
- def existing_entry?(test_entry)
80
- entries.any? { |entry| entry.url == test_entry.url }
81
- end
82
83
  end
83
- end
84
+ end
@@ -5,7 +5,7 @@ module Feedzirra
5
5
  # Source: http://www.apple.com/itunes/whatson/podcasts/specs.html
6
6
  class ITunesRSSItem
7
7
  include SAXMachine
8
- include FeedUtilities
8
+ include FeedEntryUtilities
9
9
  element :author
10
10
  element :guid
11
11
  element :title
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. spec_helper])
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
2
 
3
3
  describe Feedzirra::FeedUtilities do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. spec_helper])
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
2
 
3
3
  describe Feedzirra::FeedUtilities do
4
4
  before do
@@ -34,7 +34,7 @@ describe Feedzirra::Parser::ITunesRSSItem do
34
34
  end
35
35
 
36
36
  it "should parse the published date" do
37
- @item.published.should == "Wed, 15 Jun 2005 19:00:00 GMT"
37
+ @item.published.should == Time.parse('Wed Jun 15 19:00:00 UTC 2005')
38
38
  end
39
39
 
40
40
  it "should parse the duration" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsl-feedzirra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12.10
4
+ version: 0.0.12.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix
@@ -13,7 +13,7 @@ date: 2009-05-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: hashback
16
+ name: jsl-hashback
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -137,14 +137,14 @@ files:
137
137
  - spec/feedzirra/parser/itunes_rss_owner_spec.rb
138
138
  - spec/feedzirra/parser/rss_spec.rb
139
139
  - spec/feedzirra/parser/rss_entry_spec.rb
140
- - spec/feedzirra/feed_utilities_spec.rb
141
- - spec/feedzirra/feed_entry_utilities_spec.rb
140
+ - spec/feedzirra/parser/feed_utilities_spec.rb
141
+ - spec/feedzirra/parser/feed_entry_utilities_spec.rb
142
142
  has_rdoc: true
143
143
  homepage: http://github.com/jsl/feedzirra
144
144
  post_install_message:
145
145
  rdoc_options:
146
146
  - --title
147
- - HashBack
147
+ - Feedzirra
148
148
  - --main
149
149
  - README.rdoc
150
150
  - --line-numbers