feedjira 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a95a55c16d70ffd628b86e4063a4a6bd5507451
4
- data.tar.gz: e8b27d65d8e3734db3de73d85d0793f9c4aaba84
3
+ metadata.gz: d4bfa9a3ad56ca78ba82d37207e69ca4e12c8ee5
4
+ data.tar.gz: 5755201822491bd1f77cecb532ee9fc182bd0b42
5
5
  SHA512:
6
- metadata.gz: 30e378d04980d3d60e21fbb2dddeb64c5db9dac7c83e0927fb7c6220201f86873432c738b7936c9dff5b00e1e19f782a8844a11225411891a3527b9ecc2494f6
7
- data.tar.gz: 59f3590bea5343fa5e619d711e67e34ba8b33490b7d12a96bf456bcbe506e087ddac1662ced445e4ce8b779cb011496e22086fd951874c8b0468290a5ae17906
6
+ metadata.gz: 9c6539c549c742cd555d1f9b2c2c4c88eef74e7bca45c1abad55af1efb8b6fd9028973194841762090f2cc34ab87532632e0d9fc729f84edd6b076e33c9b20d5
7
+ data.tar.gz: 6e3fd5625766907bdbd6b4355ac56f4b6a18135bd0f42eb005c8616d111811024326bf3679e33e31753a1fed210a10d1c8aa387f93b8a223dfaccd43aafc1343
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Feedjira Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ * General
6
+ * Benchmarks have been moved to [feedjira-benchmarks][bench]
7
+
8
+ * Enhancements
9
+ * For Atom feeds, use self link for `feed_url` [#212][] [#213][]
10
+ * For Atom feeds, don't use self link for `url` [#212][] [#213][]
11
+
12
+ * Bug fixes
13
+ * Remove div that wraps xhtml content in Atom feeds [#214][]
14
+ * Properly parse itunes:new-feed-url [#217][]
15
+
16
+ [bench]: https://github.com/feedjira/feedjira-benchmarks
17
+ [#212]: https://github.com/feedjira/feedjira/issues/212
18
+ [#213]: https://github.com/feedjira/feedjira/pull/213
19
+ [#214]: https://github.com/feedjira/feedjira/issues/214
20
+ [#217]: https://github.com/feedjira/feedjira/pull/217
21
+
3
22
  ## 1.1.0
4
23
 
5
24
  * General
@@ -26,7 +45,7 @@
26
45
 
27
46
  ## 0.7.1
28
47
 
29
- * Bugfix
48
+ * Bug fixes
30
49
  * Don't use entry id for updating when feed doesn't provide it [#205][]
31
50
 
32
51
  [#205]: https://github.com/feedjira/feedjira/pull/205
@@ -7,7 +7,7 @@ module Feedjira
7
7
  element :title
8
8
  element :subtitle, :as => :description
9
9
  element :link, :as => :url, :value => :href, :with => {:type => "text/html"}
10
- element :link, :as => :feed_url, :value => :href, :with => {:type => "application/atom+xml"}
10
+ element :link, :as => :feed_url, :value => :href, :with => {:rel => "self"}
11
11
  elements :link, :as => :links, :value => :href
12
12
  elements :link, :as => :hubs, :value => :href, :with => {:rel => "hub"}
13
13
  elements :entry, :as => :entries, :class => AtomEntry
@@ -17,7 +17,7 @@ module Feedjira
17
17
  end
18
18
 
19
19
  def url
20
- @url || links.last
20
+ @url || (links - [feed_url]).last || links.last
21
21
  end
22
22
 
23
23
  def feed_url
@@ -34,26 +34,28 @@ module Feedjira
34
34
  end
35
35
 
36
36
  def to_xml
37
- process_nodes
37
+ process_content
38
38
  doc.to_xml
39
39
  end
40
40
 
41
41
  private
42
42
 
43
- def process_nodes
44
- nodes.each { |node| node.content = raw_html(node) unless node.cdata? }
43
+ def process_content
44
+ content_nodes.each do |node|
45
+ node.content = raw_html(node) unless node.cdata?
46
+ end
45
47
  end
46
48
 
47
- def nodes
49
+ def content_nodes
48
50
  doc.search 'entry > content[type="xhtml"]'
49
51
  end
50
52
 
51
53
  def raw_html(node)
52
- CGI.unescape_html node.inner_html
54
+ CGI.unescape_html node.search('div').inner_html
53
55
  end
54
56
 
55
57
  def doc
56
- @doc ||= Nokogiri::XML @xml
58
+ @doc ||= Nokogiri::XML(@xml).remove_namespaces!
57
59
  end
58
60
  end
59
61
  end
@@ -24,7 +24,7 @@ module Feedjira
24
24
  element :"itunes:explicit", :as => :itunes_explicit
25
25
  element :"itunes:keywords", :as => :itunes_keywords
26
26
  # New URL for the podcast feed
27
- element :"itunes:new-feed-url", :as => :itunes_new_feed_url
27
+ element :"itunes:new_feed_url", :as => :itunes_new_feed_url
28
28
  element :"itunes:subtitle", :as => :itunes_subtitle
29
29
  # If summary is not present, use the description tag
30
30
  element :"itunes:summary", :as => :itunes_summary
@@ -1,3 +1,3 @@
1
1
  module Feedjira
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -70,7 +70,21 @@ describe Feedjira::Parser::Atom do
70
70
  feed = Feedjira::Parser::Atom.parse sample_atom_xhtml_feed
71
71
  entry = feed.entries.first
72
72
 
73
- entry.content.should match /\<div/
73
+ entry.content.should match /\A\<p/
74
+ end
75
+ end
76
+
77
+ describe "parsing url and feed url based on rel attribute" do
78
+ before :each do
79
+ @feed = Feedjira::Parser::Atom.parse(sample_atom_middleman_feed)
80
+ end
81
+
82
+ it "should parse url" do
83
+ @feed.url.should == "http://feedjira.com/blog"
84
+ end
85
+
86
+ it "should parse feed url" do
87
+ @feed.feed_url.should == "http://feedjira.com/blog/feed.xml"
74
88
  end
75
89
  end
76
90
  end
@@ -54,5 +54,9 @@ describe Feedjira::Parser::ITunesRSS do
54
54
  it "should parse entries" do
55
55
  @feed.entries.size.should == 3
56
56
  end
57
+
58
+ it "should parse the new-feed-url" do
59
+ @feed.itunes_new_feed_url.should == "http://example.com/new.xml"
60
+ end
57
61
  end
58
62
  end
data/spec/sample_feeds.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module SampleFeeds
2
2
  FEEDS = {
3
3
  sample_atom_feed: "AmazonWebServicesBlog.xml",
4
+ sample_atom_middleman_feed: "FeedjiraBlog.xml",
4
5
  sample_atom_xhtml_feed: "pet_atom.xml",
5
6
  sample_atom_feed_line_breaks: "AtomFeedWithSpacesAroundEquals.xml",
6
7
  sample_atom_entry_content: "AmazonWebServicesBlogFirstEntryContent.xml",
@@ -0,0 +1,86 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom">
3
+ <title>Feedjira Blog</title>
4
+ <subtitle>A Blog for Feedjira</subtitle>
5
+ <id>http://feedjira.com/blog</id>
6
+ <link href="http://feedjira.com/blog"/>
7
+ <link href="http://feedjira.com/blog/feed.xml" rel="self"/>
8
+ <updated>2014-03-17T00:00:00Z</updated>
9
+ <author>
10
+ <name>Jon Allured</name>
11
+ </author>
12
+ <entry>
13
+ <title>Feedjira Goes One-Point-Oh</title>
14
+ <link rel="alternate" href="http://feedjira.com/blog/2014/03/17/feedjira-goes-one-point-oh.html"/>
15
+ <id>http://feedjira.com/blog/2014/03/17/feedjira-goes-one-point-oh.html</id>
16
+ <published>2014-03-17T00:00:00Z</published>
17
+ <updated>2014-03-17T08:02:45-05:00</updated>
18
+ <author>
19
+ <name>Jon Allured</name>
20
+ </author>
21
+ <content type="html">&lt;p&gt;Last fall, I asked &lt;a href="http://www.pauldix.net"&gt;Paul Dix&lt;/a&gt; if I could take over maintenance of his gem
22
+ Feedzirra. My request was totally out of the blue, so I was pretty pumped when
23
+ he got right back to me and said yes. He said that he didn&amp;rsquo;t have time to work
24
+ on it anymore and so I should feel free to do whatever I thought was best.&lt;/p&gt;
25
+
26
+ &lt;p&gt;Score!&lt;/p&gt;
27
+
28
+ &lt;p&gt;My first order of business was to go through the many open issues and pull
29
+ requests on GitHub. When I started there were over 60, a number that I&amp;rsquo;ve gotten
30
+ down to just a few. I thought it was important to ensure that users saw me treat
31
+ their issue as important and even if it was very old (which many were), I asked
32
+ if there was anything I could do to help.&lt;/p&gt;
33
+
34
+ &lt;p&gt;I was pleasantly surprised by the nice way many people responded and we got to
35
+ work addressing their questions and issues.&lt;/p&gt;
36
+
37
+ &lt;p&gt;As I was working through issues and pull requests, I kept &lt;a href="http://semver.org"&gt;SemVer&lt;/a&gt; in mind -
38
+ bug fixes in patch releases and backward-compatible changes in minor releases.
39
+ But I also realized that it was past time for this project to be at version 1.0.
40
+ In the SemVer FAQ, they talk about when to release version 1.0 and Feedzirra fit
41
+ the bill: it was being used in production, there was a stable API and I was
42
+ taking backwards compatibilty seriously.&lt;/p&gt;
43
+
44
+ &lt;p&gt;So I treated it as a project at 1.0 and I did my best to release versions that
45
+ were backward compatible and added deprecations for what I wanted to do in 1.0.
46
+ I saw things that I wanted to completely rewrite, but I resisted the urge to
47
+ burn it all down and start again.&lt;/p&gt;
48
+
49
+ &lt;p&gt;When I was close to being caught up on the backlog of issues and pull requests,
50
+ I started thinking about releasing version 1.0, and I knew I wanted to create a
51
+ website for the project. I worked with &lt;a href="http://danielariza.com"&gt;Daniel Ariza&lt;/a&gt; to make it happen. I
52
+ ripped apart the README and rewrote just about all the sections.&lt;/p&gt;
53
+
54
+ &lt;p&gt;There was an open issue on the project about renaming the Gem and I knew that
55
+ launching the website and releasing 1.0 would be the perfect opportunity, so I
56
+ went for it. There was a suggestion to change the name to Feedzilla, but since
57
+ that is already a thing, I went with Feedjira. I bought the domain and setup an
58
+ organization by that name on GitHub.&lt;/p&gt;
59
+
60
+ &lt;p&gt;With those things in place, I needed to actually update the code for these
61
+ changes. I wanted to make this transition as easy as possible and devised a
62
+ simple way to use &lt;a href="/versions.html"&gt;three versions&lt;/a&gt; to make the jump to 1.0.&lt;/p&gt;
63
+
64
+ &lt;p&gt;For most users, upgrading to 1.0 should be a breeze, but I have an &lt;a href="/upgrading.html"&gt;upgrade
65
+ page&lt;/a&gt; to help with a couple details. If you have any trouble upgrading,
66
+ please let me know by &lt;a href="https://github.com/feedjira/feedjira/issues"&gt;opening an issue&lt;/a&gt;.&lt;/p&gt;
67
+
68
+ &lt;p&gt;There are still lots of things I&amp;rsquo;d like to do with this Gem. I mentioned seeing
69
+ things that I wanted to completely rewrite, so that&amp;rsquo;ll be something that I work
70
+ on for a 2.0 release, but that&amp;rsquo;s a ways off. I&amp;rsquo;d like to officially support
71
+ JRuby. Many people use Feedjira with Rails, so a separate project that helps
72
+ those users get up and running quickly seems to have value.&lt;/p&gt;
73
+
74
+ &lt;p&gt;The list goes on.&lt;/p&gt;
75
+
76
+ &lt;p&gt;I do have a request before I finish this thing: I&amp;rsquo;d like to hear from users that
77
+ have apps in production using Feedjira. If you&amp;rsquo;re using Feedjira for a
78
+ commercial app, please &lt;a href="feedjira@gmail.com"&gt;email me&lt;/a&gt;!&lt;/p&gt;
79
+
80
+ &lt;p&gt;Thanks to everyone who has helped me accomplish this, but especially &lt;a href="http://www.pauldix.net"&gt;Paul
81
+ Dix&lt;/a&gt; for creating such a fun project to work on, &lt;a href="http://danielariza.com"&gt;Daniel Ariza&lt;/a&gt; for a
82
+ badass website design and the many people who opened issues or sent pull
83
+ requests. Open source is fun to work on because of people like you!! &amp;lt;3 &amp;lt;3 &amp;lt;3&lt;/p&gt;
84
+ </content>
85
+ </entry>
86
+ </feed>
@@ -8,6 +8,7 @@
8
8
  <language>en-us</language>
9
9
  <copyright>&#x2117; &amp; &#xA9; 2005 John Doe &amp; Family</copyright>
10
10
  <itunes:subtitle>A show about everything</itunes:subtitle>
11
+ <itunes:new-feed-url>http://example.com/new.xml</itunes:new-feed-url>
11
12
  <itunes:author>John Doe</itunes:author>
12
13
  <itunes:summary>All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our Podcast in the iTunes Music Store</itunes:summary>
13
14
  <description>All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our Podcast in the iTunes Music Store</description>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedjira
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-03-21 00:00:00.000000000 Z
14
+ date: 2014-04-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sax-machine
@@ -83,21 +83,6 @@ files:
83
83
  - LICENSE
84
84
  - README.md
85
85
  - Rakefile
86
- - benchmarks/README.md
87
- - benchmarks/basic.rb
88
- - benchmarks/feed_list.txt
89
- - benchmarks/feed_xml/apple.xml
90
- - benchmarks/feed_xml/cnn.xml
91
- - benchmarks/feed_xml/daring_fireball.xml
92
- - benchmarks/feed_xml/engadget.xml
93
- - benchmarks/feed_xml/feedjira_commits.xml
94
- - benchmarks/feed_xml/gizmodo.xml
95
- - benchmarks/feed_xml/loop.xml
96
- - benchmarks/feed_xml/rails.xml
97
- - benchmarks/feed_xml/white_house.xml
98
- - benchmarks/feed_xml/xkcd.xml
99
- - benchmarks/fetching_systems.rb
100
- - benchmarks/other_libraries.rb
101
86
  - feedjira.gemspec
102
87
  - lib/feedjira.rb
103
88
  - lib/feedjira/core_ext.rb
@@ -143,6 +128,7 @@ files:
143
128
  - spec/sample_feeds/AmazonWebServicesBlogFirstEntryContent.xml
144
129
  - spec/sample_feeds/AtomFeedWithSpacesAroundEquals.xml
145
130
  - spec/sample_feeds/FeedBurnerUrlNoAlternate.xml
131
+ - spec/sample_feeds/FeedjiraBlog.xml
146
132
  - spec/sample_feeds/GoogleDocsList.xml
147
133
  - spec/sample_feeds/HREFConsideredHarmful.xml
148
134
  - spec/sample_feeds/HREFConsideredHarmfulFirstEntry.xml
@@ -209,6 +195,7 @@ test_files:
209
195
  - spec/sample_feeds/AmazonWebServicesBlogFirstEntryContent.xml
210
196
  - spec/sample_feeds/AtomFeedWithSpacesAroundEquals.xml
211
197
  - spec/sample_feeds/FeedBurnerUrlNoAlternate.xml
198
+ - spec/sample_feeds/FeedjiraBlog.xml
212
199
  - spec/sample_feeds/GoogleDocsList.xml
213
200
  - spec/sample_feeds/HREFConsideredHarmful.xml
214
201
  - spec/sample_feeds/HREFConsideredHarmfulFirstEntry.xml
data/benchmarks/README.md DELETED
@@ -1,90 +0,0 @@
1
- # Feedjira Benchmarks
2
-
3
- Speed is an important feature of Feedjira and we use benchmarks to ensure we're
4
- fast and we stay that way.
5
-
6
- ## Fetching Options
7
-
8
- One way Feedjira achieves its speed is by fetching feeds in parallel. This
9
- benchmark compares ways to fetch feed urls:
10
-
11
- ```
12
- user system total real
13
- Net::HTTP 0.310000 0.110000 0.420000 ( 10.111994)
14
- Curl::Easy 0.140000 0.260000 0.400000 ( 14.692383)
15
- Curl::Multi 0.100000 0.170000 0.270000 ( 3.334533)
16
- ```
17
-
18
- See the [fetching systems code][fetching_systems] for more details.
19
-
20
- [fetching_systems]: https://github.com/feedjira/feedjira/blob/master/benchmarks/fetching_systems.rb
21
-
22
- ## Basic Benchmarks
23
-
24
- The basics to using Feedjira are the `parse`, `fetch_and_parse` and `update`
25
- methods, so this benchmark compares them:
26
-
27
- ```
28
- user system total real
29
- parse 1.500000 0.010000 1.510000 ( 1.498793)
30
- fetch_and_parse 2.230000 0.310000 2.540000 ( 12.212616)
31
- update 1.030000 0.270000 1.300000 ( 29.359274)
32
- ```
33
-
34
- See the [basic benchmark code][basic] for more details.
35
-
36
- [basic]: https://github.com/feedjira/feedjira/blob/master/benchmarks/basic.rb
37
-
38
- ## Other Libraries
39
-
40
- This benchmark compares various alternatives to Feedjira. As of 11/29/13, these
41
- are the top 10 gems in the [Atom & RSS Feed Parsing category][alternatives] on
42
- Ruby Toolbox:
43
-
44
- [alternatives]: https://www.ruby-toolbox.com/categories/feed_parsing
45
-
46
- * Feedjira
47
- * Simple-rss
48
- * Feed-normalizer
49
- * Ratom
50
- * Rfeedparser
51
- * FeedParser
52
- * Feed me
53
- * Feedtosis
54
- * Ruby-feedparser
55
- * Opds
56
-
57
- Only some of these are still under active deveopment and still others aren't a
58
- good fit for this type of benchmark comparison. Notes on those that were left
59
- out:
60
-
61
- * Ratom => only supports Atom
62
- * Rfeedparser => can't install, depends on hpricot v0.6
63
- * Feedtosis => can't install, unresolved dependencies
64
- * Opds => aimed at OPDS specifically
65
-
66
- The remaining alternatives are benchmarked in two ways. The parsing benchmarks
67
- just take raw XML and throw it at the library. Those that can also fetch, have a
68
- second benchmark for that work.
69
-
70
- Note: both FeedParser and Ruby-feedparser use the `FeedParser` namespace, so
71
- their benchmarks can't be run at the same time.
72
-
73
- ```
74
- Parsing benchmarks
75
- user system total real
76
- feedjira 1.560000 0.000000 1.560000 ( 1.573555)
77
- simple-rss 43.140000 0.150000 43.290000 ( 43.421603)
78
- feed-normalizer 39.870000 0.130000 40.000000 ( 40.404832)
79
- feed_parser 0.240000 0.000000 0.240000 ( 0.249771)
80
- feed_me 0.220000 0.010000 0.230000 ( 0.229034)
81
-
82
- Fetch and parse benchmarks
83
- user system total real
84
- feedjira 2.250000 0.320000 2.570000 ( 11.224833)
85
- feed_parser 1.700000 0.290000 1.990000 ( 28.941270)
86
- ```
87
-
88
- See the [other benchmark code][other_benchmark] for more details.
89
-
90
- [other_benchmark]: https://github.com/feedjira/feedjira/blob/master/benchmarks/other_libraries.rb
data/benchmarks/basic.rb DELETED
@@ -1,31 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../lib/feedjira')
2
-
3
- require 'benchmark'
4
-
5
- iterations = 10
6
- urls = File.readlines(File.dirname(__FILE__) + '/feed_list.txt')
7
- files = Dir.glob(File.dirname(__FILE__) + '/feed_xml/*.xml')
8
- xmls = files.map { |file| File.open(file).read }
9
- feeds = Feedjira::Feed.fetch_and_parse(urls).values
10
-
11
- Benchmark.bm(15) do |b|
12
- b.report('parse') do
13
- iterations.times do
14
- xmls.each { |xml| Feedjira::Feed.parse xml }
15
- end
16
- end
17
-
18
- b.report('fetch_and_parse') do
19
- iterations.times { Feedjira::Feed.fetch_and_parse urls }
20
- end
21
-
22
- # curb caches the DNS lookups for 60 seconds, so to make things fair we have
23
- # to wait for the cache to expire
24
- 65.times { sleep 1 }
25
-
26
- b.report('update') do
27
- iterations.times do
28
- feeds.each { |feed| Feedjira::Feed.update feed }
29
- end
30
- end
31
- end
@@ -1,10 +0,0 @@
1
- http://daringfireball.net/index.xml
2
- http://feeds.gawker.com/gizmodo/full
3
- http://images.apple.com/main/rss/hotnews/hotnews.rss
4
- http://rss.cnn.com/rss/cnn_topstories.rss
5
- http://weblog.rubyonrails.org/feed/atom.xml
6
- http://www.engadget.com/rss.xml
7
- http://www.loopinsight.com/feed/
8
- http://www.whitehouse.gov/feed/blog/white-house
9
- http://xkcd.com/atom.xml
10
- https://github.com/feedjira/feedjira/commits/master.atom