kete-feedzirra 0.0.8.1 → 0.0.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/README.textile +11 -2
  2. data/Rakefile +3 -0
  3. data/lib/feedzirra.rb +10 -10
  4. data/lib/feedzirra/feed.rb +45 -42
  5. data/lib/feedzirra/parser/atom.rb +47 -0
  6. data/lib/feedzirra/parser/atom_entry.rb +51 -0
  7. data/lib/feedzirra/parser/atom_feed_burner.rb +27 -0
  8. data/lib/feedzirra/parser/atom_feed_burner_entry.rb +35 -0
  9. data/lib/feedzirra/parser/itunes_rss.rb +50 -0
  10. data/lib/feedzirra/parser/itunes_rss_item.rb +31 -0
  11. data/lib/feedzirra/parser/itunes_rss_owner.rb +12 -0
  12. data/lib/feedzirra/parser/rss.rb +40 -0
  13. data/lib/feedzirra/parser/rss_entry.rb +55 -0
  14. data/spec/feedzirra/feed_spec.rb +30 -27
  15. data/spec/feedzirra/feed_utilities_spec.rb +9 -9
  16. data/spec/feedzirra/{atom_entry_spec.rb → parser/atom_entry_spec.rb} +7 -3
  17. data/spec/feedzirra/{atom_feed_burner_entry_spec.rb → parser/atom_feed_burner_entry_spec.rb} +4 -4
  18. data/spec/feedzirra/{atom_feed_burner_spec.rb → parser/atom_feed_burner_spec.rb} +6 -6
  19. data/spec/feedzirra/{atom_spec.rb → parser/atom_spec.rb} +16 -8
  20. data/spec/feedzirra/{itunes_rss_item_spec.rb → parser/itunes_rss_item_spec.rb} +3 -3
  21. data/spec/feedzirra/{itunes_rss_owner_spec.rb → parser/itunes_rss_owner_spec.rb} +3 -3
  22. data/spec/feedzirra/{itunes_rss_spec.rb → parser/itunes_rss_spec.rb} +5 -5
  23. data/spec/feedzirra/{rss_entry_spec.rb → parser/rss_entry_spec.rb} +14 -14
  24. data/spec/feedzirra/{rss_spec.rb → parser/rss_spec.rb} +17 -18
  25. metadata +22 -21
  26. data/lib/feedzirra/atom.rb +0 -35
  27. data/lib/feedzirra/atom_entry.rb +0 -41
  28. data/lib/feedzirra/atom_feed_burner.rb +0 -22
  29. data/lib/feedzirra/atom_feed_burner_entry.rb +0 -30
  30. data/lib/feedzirra/itunes_rss.rb +0 -46
  31. data/lib/feedzirra/itunes_rss_item.rb +0 -28
  32. data/lib/feedzirra/itunes_rss_owner.rb +0 -8
  33. data/lib/feedzirra/rss.rb +0 -36
  34. data/lib/feedzirra/rss_entry.rb +0 -48
@@ -1,10 +1,10 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
2
 
3
- describe Feedzirra::ITunesRSSItem do
3
+ describe Feedzirra::Parser::ITunesRSSItem do
4
4
  before(:each) do
5
5
  # I don't really like doing it this way because these unit test should only rely on ITunesRssItem,
6
6
  # but this is actually how it should work. You would never just pass entry xml straight to the ITunesRssItem
7
- @item = Feedzirra::ITunesRSS.parse(sample_itunes_feed).entries.first
7
+ @item = Feedzirra::Parser::ITunesRSS.parse(sample_itunes_feed).entries.first
8
8
  end
9
9
 
10
10
  it "should parse the title" do
@@ -1,10 +1,10 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
2
 
3
- describe Feedzirra::ITunesRSSOwner do
3
+ describe Feedzirra::Parser::ITunesRSSOwner do
4
4
  before(:each) do
5
5
  # I don't really like doing it this way because these unit test should only rely on RSSEntry,
6
6
  # but this is actually how it should work. You would never just pass entry xml straight to the ITunesRssOwner
7
- @owner = Feedzirra::ITunesRSS.parse(sample_itunes_feed).itunes_owners.first
7
+ @owner = Feedzirra::Parser::ITunesRSS.parse(sample_itunes_feed).itunes_owners.first
8
8
  end
9
9
 
10
10
  it "should parse the name" do
@@ -1,19 +1,19 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
2
 
3
- describe Feedzirra::ITunesRSS do
3
+ describe Feedzirra::Parser::ITunesRSS do
4
4
  describe "#will_parse?" do
5
5
  it "should return true for an itunes RSS feed" do
6
- Feedzirra::ITunesRSS.should be_able_to_parse(sample_itunes_feed)
6
+ Feedzirra::Parser::ITunesRSS.should be_able_to_parse(sample_itunes_feed)
7
7
  end
8
8
 
9
9
  it "should return fase for an atom feed" do
10
- Feedzirra::ITunesRSS.should_not be_able_to_parse(sample_atom_feed)
10
+ Feedzirra::Parser::ITunesRSS.should_not be_able_to_parse(sample_atom_feed)
11
11
  end
12
12
  end
13
13
 
14
14
  describe "parsing" do
15
15
  before(:each) do
16
- @feed = Feedzirra::ITunesRSS.parse(sample_itunes_feed)
16
+ @feed = Feedzirra::Parser::ITunesRSS.parse(sample_itunes_feed)
17
17
  end
18
18
 
19
19
  it "should parse the subtitle" do
@@ -1,33 +1,33 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
2
 
3
- describe Feedzirra::RSSEntry do
3
+ describe Feedzirra::Parser::RSSEntry do
4
4
  describe "parsing of simple rss feed item" do
5
5
  before(:each) do
6
6
  # I don't really like doing it this way because these unit test should only rely on RSSEntry,
7
7
  # but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
8
- @entry = Feedzirra::RSS.parse(sample_rss_feed).entries.first
8
+ @entry = Feedzirra::Parser::RSS.parse(sample_rss_feed).entries.first
9
9
  end
10
-
10
+
11
11
  it "should parse the title" do
12
12
  @entry.title.should == "Nokogiri’s Slop Feature"
13
13
  end
14
-
14
+
15
15
  it "should parse the url" do
16
16
  @entry.url.should == "http://tenderlovemaking.com/2008/12/04/nokogiris-slop-feature/"
17
17
  end
18
-
18
+
19
19
  it "should parse the author" do
20
20
  @entry.author.should == "Aaron Patterson"
21
21
  end
22
-
22
+
23
23
  it "should parse the content" do
24
24
  @entry.content.should == sample_rss_entry_content
25
25
  end
26
-
26
+
27
27
  it "should provide a summary" do
28
28
  @entry.summary.should == "Oops! When I released nokogiri version 1.0.7, I totally forgot to talk about Nokogiri::Slop() feature that was added. Why is it called \"slop\"? It lets you sloppily explore documents. Basically, it decorates your document with method_missing() that allows you to search your document via method calls.\nGiven this document:\n\ndoc = Nokogiri::Slop(<<-eohtml)\n<html>\n  <body>\n  [...]"
29
29
  end
30
-
30
+
31
31
  it "should parse the published date" do
32
32
  @entry.published.to_s.should == "Thu Dec 04 17:17:49 UTC 2008"
33
33
  end
@@ -35,7 +35,7 @@ describe Feedzirra::RSSEntry do
35
35
  it "should parse the categories" do
36
36
  @entry.categories.should == ['computadora', 'nokogiri', 'rails']
37
37
  end
38
-
38
+
39
39
  it "should parse the guid as id" do
40
40
  @entry.id.should == "http://tenderlovemaking.com/?p=198"
41
41
  end
@@ -45,7 +45,7 @@ describe Feedzirra::RSSEntry do
45
45
  before(:each) do
46
46
  # I don't really like doing it this way because these unit test should only rely on RSSEntry,
47
47
  # but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
48
- @entry = Feedzirra::RSS.parse(sample_media_rss_feed).entries.first
48
+ @entry = Feedzirra::Parser::RSS.parse(sample_media_rss_feed).entries.first
49
49
  end
50
50
 
51
51
  it "should parse the title" do
@@ -63,11 +63,11 @@ describe Feedzirra::RSSEntry do
63
63
  it "should provide a summary" do
64
64
  @entry.summary.should == sample_media_rss_entry_content
65
65
  end
66
-
66
+
67
67
  it "should parse the published date" do
68
68
  @entry.published.to_s.should == "Mon Mar 23 07:55:43 UTC 2009"
69
69
  end
70
-
70
+
71
71
  it "should parse the guid as id" do
72
72
  @entry.id.should == "http://horowhenua.kete.net.nz/site/images/show/15535-the-new-boy-on-the-block"
73
73
  end
@@ -77,7 +77,7 @@ describe Feedzirra::RSSEntry do
77
77
  end
78
78
 
79
79
  it "should parse media:description as media_description" do
80
- @entry.media_description.should == "big crane from  Wellington visits the site for the week"
80
+ @entry.media_description.should == "big crane from Wellington visits the site for the week"
81
81
  end
82
82
 
83
83
  it "should parse media:thumbnail url as media_thumbnail" do
@@ -1,9 +1,9 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
2
 
3
- describe Feedzirra::RSS do
3
+ describe Feedzirra::Parser::RSS do
4
4
  describe "#will_parse?" do
5
5
  it "should return true for an RSS feed" do
6
- Feedzirra::RSS.should be_able_to_parse(sample_rss_feed)
6
+ Feedzirra::Parser::RSS.should be_able_to_parse(sample_rss_feed)
7
7
  end
8
8
 
9
9
  # this is no longer true. combined rdf and rss into one
@@ -12,13 +12,13 @@ describe Feedzirra::RSS do
12
12
  # end
13
13
 
14
14
  it "should return fase for an atom feed" do
15
- Feedzirra::RSS.should_not be_able_to_parse(sample_atom_feed)
15
+ Feedzirra::Parser::RSS.should_not be_able_to_parse(sample_atom_feed)
16
16
  end
17
17
  end
18
18
 
19
19
  describe "parsing of simple rss feed" do
20
20
  before(:each) do
21
- @feed = Feedzirra::RSS.parse(sample_rss_feed)
21
+ @feed = Feedzirra::Parser::RSS.parse(sample_rss_feed)
22
22
  end
23
23
 
24
24
  it "should parse the title" do
@@ -41,49 +41,48 @@ describe Feedzirra::RSS do
41
41
 
42
42
  describe "parsing of media rss feed" do
43
43
  before(:each) do
44
- @feed = Feedzirra::RSS.parse(sample_media_rss_feed)
44
+ @feed = Feedzirra::Parser::RSS.parse(sample_media_rss_feed)
45
45
  end
46
-
46
+
47
47
  it "should parse the title" do
48
48
  @feed.title.should == "horowhenua.kete.net.nz - Latest 50 Results in images"
49
49
  end
50
-
50
+
51
51
  it "should parse the url" do
52
52
  @feed.url.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington"
53
53
  end
54
-
54
+
55
55
  it "should parse link rel='related' as related" do
56
56
  @feed.related.should == ["http://horowhenua.kete.net.nz/", "http://horowhenua.kete.net.nz/site/all/images"]
57
57
  end
58
-
58
+
59
59
  it "should parse the description" do
60
60
  @feed.description.should == "Showing 1 - 50 results of 368"
61
61
  end
62
-
62
+
63
63
  it "should parse the language" do
64
64
  @feed.language.should == "en-nz"
65
65
  end
66
-
66
+
67
67
  it "should provide an accessor for the feed_url" do
68
68
  @feed.respond_to?(:feed_url).should == true
69
69
  @feed.respond_to?(:feed_url=).should == true
70
70
  end
71
-
71
+
72
72
  it "should parse the prev atom:link" do
73
- @feed.prev_page.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington&page=1"
73
+ @feed.prev_page.should == "http://aws.typepad.com/aws/atom.xml?page=1"
74
74
  end
75
75
 
76
76
  it "should parse the next atom:link" do
77
- @feed.next_page.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington&page=3"
77
+ @feed.next_page.should == "http://aws.typepad.com/aws/atom.xml?page=3"
78
78
  end
79
79
 
80
80
  it "should parse the last atom:link" do
81
- @feed.last_page.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington&page=5"
81
+ @feed.last_page.should == "http://aws.typepad.com/aws/atom.xml?page=5"
82
82
  end
83
-
83
+
84
84
  it "should parse entries" do
85
85
  @feed.entries.size.should == 50
86
86
  end
87
87
  end
88
-
89
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kete-feedzirra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8.1
4
+ version: 0.0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-21 00:00:00 -07:00
12
+ date: 2009-08-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -85,15 +85,15 @@ files:
85
85
  - lib/core_ext/string.rb
86
86
  - lib/feedzirra.rb
87
87
  - lib/feedzirra/feed.rb
88
- - lib/feedzirra/atom.rb
89
- - lib/feedzirra/atom_entry.rb
90
- - lib/feedzirra/atom_feed_burner.rb
91
- - lib/feedzirra/atom_feed_burner_entry.rb
92
- - lib/feedzirra/itunes_rss.rb
93
- - lib/feedzirra/itunes_rss_item.rb
94
- - lib/feedzirra/itunes_rss_owner.rb
95
- - lib/feedzirra/rss.rb
96
- - lib/feedzirra/rss_entry.rb
88
+ - lib/feedzirra/parser/atom.rb
89
+ - lib/feedzirra/parser/atom_entry.rb
90
+ - lib/feedzirra/parser/atom_feed_burner.rb
91
+ - lib/feedzirra/parser/atom_feed_burner_entry.rb
92
+ - lib/feedzirra/parser/itunes_rss.rb
93
+ - lib/feedzirra/parser/itunes_rss_item.rb
94
+ - lib/feedzirra/parser/itunes_rss_owner.rb
95
+ - lib/feedzirra/parser/rss.rb
96
+ - lib/feedzirra/parser/rss_entry.rb
97
97
  - lib/feedzirra/feed_utilities.rb
98
98
  - lib/feedzirra/feed_entry_utilities.rb
99
99
  - README.textile
@@ -101,19 +101,20 @@ files:
101
101
  - spec/spec.opts
102
102
  - spec/spec_helper.rb
103
103
  - spec/feedzirra/feed_spec.rb
104
- - spec/feedzirra/atom_spec.rb
105
- - spec/feedzirra/atom_entry_spec.rb
106
- - spec/feedzirra/atom_feed_burner_spec.rb
107
- - spec/feedzirra/atom_feed_burner_entry_spec.rb
108
- - spec/feedzirra/itunes_rss_spec.rb
109
- - spec/feedzirra/itunes_rss_item_spec.rb
110
- - spec/feedzirra/itunes_rss_owner_spec.rb
111
- - spec/feedzirra/rss_spec.rb
112
- - spec/feedzirra/rss_entry_spec.rb
104
+ - spec/feedzirra/parser/atom_spec.rb
105
+ - spec/feedzirra/parser/atom_entry_spec.rb
106
+ - spec/feedzirra/parser/atom_feed_burner_spec.rb
107
+ - spec/feedzirra/parser/atom_feed_burner_entry_spec.rb
108
+ - spec/feedzirra/parser/itunes_rss_spec.rb
109
+ - spec/feedzirra/parser/itunes_rss_item_spec.rb
110
+ - spec/feedzirra/parser/itunes_rss_owner_spec.rb
111
+ - spec/feedzirra/parser/rss_spec.rb
112
+ - spec/feedzirra/parser/rss_entry_spec.rb
113
113
  - spec/feedzirra/feed_utilities_spec.rb
114
114
  - spec/feedzirra/feed_entry_utilities_spec.rb
115
115
  has_rdoc: true
116
116
  homepage: http://github.com/pauldix/feedzirra
117
+ licenses:
117
118
  post_install_message:
118
119
  rdoc_options: []
119
120
 
@@ -134,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
135
  requirements: []
135
136
 
136
137
  rubyforge_project:
137
- rubygems_version: 1.2.0
138
+ rubygems_version: 1.3.5
138
139
  signing_key:
139
140
  specification_version: 2
140
141
  summary: "A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all."
@@ -1,35 +0,0 @@
1
- module Feedzirra
2
- # == Summary
3
- # Parser for dealing with Atom feeds.
4
- #
5
- # == Attributes
6
- # * prev_page
7
- # * next_page
8
- # * last_page
9
- # * title
10
- # * subtitle
11
- # * updated
12
- # * feed_url
13
- # * url
14
- # * related
15
- # * entries
16
- class Atom
17
- include SAXMachine
18
- include FeedUtilities
19
- element :"atom:link", :as => :prev_page, :value => :href, :with => {:rel => 'prev'}
20
- element :"atom:link", :as => :next_page, :value => :href, :with => {:rel => 'next'}
21
- element :"atom:link", :as => :last_page, :value => :href, :with => {:rel => 'last'}
22
- element :title
23
- element :subtitle
24
- element :updated
25
- element :link, :as => :url, :value => :href, :with => {:type => "text/html"}
26
- element :link, :as => :feed_url, :value => :href, :with => {:type => "application/atom+xml"}
27
- elements :link, :as => :related, :value => :href, :with => {:rel => "related"}
28
-
29
- elements :entry, :as => :entries, :class => AtomEntry
30
-
31
- def self.able_to_parse?(xml) #:nodoc:
32
- xml =~ /(Atom)|(#{Regexp.escape("http://purl.org/atom")})/
33
- end
34
- end
35
- end
@@ -1,41 +0,0 @@
1
- module Feedzirra
2
- # == Summary
3
- # Parser for dealing with Atom feed entries.
4
- #
5
- # == Attributes
6
- # * title
7
- # * url
8
- # * related
9
- # * author
10
- # * content
11
- # * summary
12
- # * published
13
- # * categories
14
- # * media_content
15
- # * media_description
16
- # * media_thumbnail
17
- # * enclosure
18
- class AtomEntry
19
- include SAXMachine
20
- include FeedEntryUtilities
21
- element :title
22
- element :link, :as => :url, :value => :href, :with => {:rel => "alternate"}
23
- elements :link, :as => :related, :value => :href, :with => {:rel => "related"}
24
- element :name, :as => :author
25
- element :content
26
- element :summary
27
- element :published
28
- element :id
29
- element :created, :as => :published
30
- element :issued, :as => :published
31
- element :updated
32
- element :modified, :as => :updated
33
- elements :category, :as => :categories, :value => :term
34
-
35
- element :"media:content", :as => :media_content, :value => :url
36
- element :"media:description", :as => :media_description
37
- element :"media:thumbnail", :as => :media_thumbnail, :value => :url
38
-
39
- element :enclosure, :value => :url
40
- end
41
- end
@@ -1,22 +0,0 @@
1
- module Feedzirra
2
- # == Summary
3
- # Parser for dealing with Feedburner Atom feeds.
4
- #
5
- # == Attributes
6
- # * title
7
- # * feed_url
8
- # * url
9
- # * entries
10
- class AtomFeedBurner
11
- include SAXMachine
12
- include FeedUtilities
13
- element :title
14
- element :link, :as => :url, :value => :href, :with => {:type => "text/html"}
15
- element :link, :as => :feed_url, :value => :href, :with => {:type => "application/atom+xml"}
16
- elements :entry, :as => :entries, :class => AtomFeedBurnerEntry
17
-
18
- def self.able_to_parse?(xml) #:nodoc:
19
- (xml =~ /Atom/ && xml =~ /feedburner/) || false
20
- end
21
- end
22
- end
@@ -1,30 +0,0 @@
1
- module Feedzirra
2
- # == Summary
3
- # Parser for dealing with Feedburner Atom feed entries.
4
- #
5
- # == Attributes
6
- # * title
7
- # * url
8
- # * author
9
- # * content
10
- # * summary
11
- # * published
12
- # * categories
13
- class AtomFeedBurnerEntry
14
- include SAXMachine
15
- include FeedEntryUtilities
16
- element :title
17
- element :name, :as => :author
18
- element :link, :as => :url, :value => :href, :with => {:rel => "alternate"}
19
- element :"feedburner:origLink", :as => :url
20
- element :summary
21
- element :content
22
- element :published
23
- element :id
24
- element :issued, :as => :published
25
- element :created, :as => :published
26
- element :updated
27
- element :modified, :as => :updated
28
- elements :category, :as => :categories, :value => :term
29
- end
30
- end
@@ -1,46 +0,0 @@
1
- module Feedzirra
2
- # iTunes is RSS 2.0 + some apple extensions
3
- # Source: http://www.apple.com/itunes/whatson/podcasts/specs.html
4
- class ITunesRSS
5
- include SAXMachine
6
- include FeedUtilities
7
-
8
- attr_accessor :feed_url
9
-
10
- # RSS 2.0 elements that need including
11
- element :copyright
12
- element :description
13
- element :language
14
- element :managingEditor
15
- element :title
16
- element :link, :as => :url
17
-
18
- # If author is not present use managingEditor on the channel
19
- element :"itunes:author", :as => :itunes_author
20
- element :"itunes:block", :as => :itunes_block
21
- element :"itunes:image", :value => :href, :as => :itunes_image
22
- element :"itunes:explicit", :as => :itunes_explicit
23
- element :"itunes:keywords", :as => :itunes_keywords
24
- # New URL for the podcast feed
25
- element :"itunes:new-feed-url", :as => :itunes_new_feed_url
26
- element :"itunes:subtitle", :as => :itunes_subtitle
27
- # If summary is not present, use the description tag
28
- element :"itunes:summary", :as => :itunes_summary
29
-
30
- # iTunes RSS feeds can have multiple main categories...
31
- # ...and multiple sub-categories per category
32
- # TODO subcategories not supported correctly - they are at the same level
33
- # as the main categories
34
- elements :"itunes:category", :as => :itunes_categories, :value => :text
35
-
36
- elements :"itunes:owner", :as => :itunes_owners, :class => ITunesRSSOwner
37
-
38
- elements :item, :as => :entries, :class => ITunesRSSItem
39
-
40
- def self.able_to_parse?(xml)
41
- xml =~ /xmlns:itunes=\"http:\/\/www.itunes.com\/dtds\/podcast-1.0.dtd\"/
42
- end
43
-
44
- end
45
-
46
- end