feedparser 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +9 -2
- data/README.md +69 -27
- data/Rakefile +2 -1
- data/lib/feedparser.rb +7 -1
- data/lib/feedparser/builder/atom.rb +92 -42
- data/lib/feedparser/builder/rss.rb +70 -42
- data/lib/feedparser/feed.rb +7 -14
- data/lib/feedparser/item.rb +9 -12
- data/lib/feedparser/parser.rb +3 -2
- data/lib/feedparser/version.rb +3 -3
- data/test/feeds/googlegroups.atom +19 -0
- data/test/feeds/googlegroups2.atom +7 -0
- data/test/feeds/headius.atom +122 -0
- data/test/feeds/lambdatheultimate.rss2 +288 -0
- data/test/feeds/railstutorial.atom +655 -0
- data/test/feeds/rubyflow.rss2 +116 -0
- data/test/feeds/rubymine.rss2 +315 -0
- data/test/feeds/rubyonrails.atom +1241 -0
- data/test/feeds/sitepoint.rss2 +219 -0
- data/test/helper.rb +36 -9
- data/test/test_atom.rb +14 -32
- data/test/test_atom_live.rb +45 -0
- data/test/test_rss.rb +13 -25
- data/test/test_rss_live.rb +38 -0
- metadata +27 -5
- data/test/feeds/quirksblog.atom.v03 +0 -1098
- data/test/test_atom_from_file.rb +0 -28
@@ -0,0 +1,219 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
|
2
|
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
3
|
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
4
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
5
|
+
xmlns:atom="http://www.w3.org/2005/Atom"
|
6
|
+
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
|
7
|
+
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
|
8
|
+
xmlns:series="http://organizeseries.com/"
|
9
|
+
>
|
10
|
+
|
11
|
+
<channel>
|
12
|
+
<title>SitePoint » Ruby</title>
|
13
|
+
<atom:link href="http://www.sitepoint.com/ruby/feed/" rel="self" type="application/rss+xml" />
|
14
|
+
<link>http://www.sitepoint.com</link>
|
15
|
+
<description>Learn CSS | HTML5 | JavaScript | Wordpress | Tutorials-Web Development | Reference | Books and More</description>
|
16
|
+
<lastBuildDate>Sat, 17 Jan 2015 11:57:47 +0000</lastBuildDate>
|
17
|
+
<language>en-US</language>
|
18
|
+
<sy:updatePeriod>hourly</sy:updatePeriod>
|
19
|
+
<sy:updateFrequency>1</sy:updateFrequency>
|
20
|
+
<generator>http://wordpress.org/?v=4.0</generator>
|
21
|
+
<item>
|
22
|
+
<title>Rails Model Caching with Redis</title>
|
23
|
+
<link>http://www.sitepoint.com/rails-model-caching-redis/</link>
|
24
|
+
<comments>http://www.sitepoint.com/rails-model-caching-redis/#comments</comments>
|
25
|
+
<pubDate>Thu, 15 Jan 2015 15:00:56 +0000</pubDate>
|
26
|
+
<dc:creator><![CDATA[Vasu K]]></dc:creator>
|
27
|
+
<category><![CDATA[Ruby]]></category>
|
28
|
+
<category><![CDATA[Ruby on Rails]]></category>
|
29
|
+
<category><![CDATA[GlennG]]></category>
|
30
|
+
|
31
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=97720</guid>
|
32
|
+
<description><![CDATA[<p><p>Model level caching is something that's often ignored, even by seasoned developers. Much of it's due to the misconception that, when you cache the views, you don't need to cache at the lower levels. While it's true that much of a bottleneck in the Rails world lies in the View layer, that's not always the case.</p>
|
33
|
+
|
34
|
+
<p>Lower level caches are very flexible and can work anywhere in the application. In this tutorial, I'll demonstrate how to cache your models with Redis.</p></p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/rails-model-caching-redis/">Rails Model Caching with Redis</a>%</em></p>]]></description>
|
35
|
+
<wfw:commentRss>http://www.sitepoint.com/rails-model-caching-redis/feed/</wfw:commentRss>
|
36
|
+
<slash:comments>0</slash:comments>
|
37
|
+
</item>
|
38
|
+
<item>
|
39
|
+
<title>Tokaido: Quick Start with Rails</title>
|
40
|
+
<link>http://www.sitepoint.com/tokaido-quick-start-rails/</link>
|
41
|
+
<comments>http://www.sitepoint.com/tokaido-quick-start-rails/#comments</comments>
|
42
|
+
<pubDate>Thu, 15 Jan 2015 00:10:59 +0000</pubDate>
|
43
|
+
<dc:creator><![CDATA[Dhaivat Pandya]]></dc:creator>
|
44
|
+
<category><![CDATA[Ruby]]></category>
|
45
|
+
<category><![CDATA[Ruby on Rails]]></category>
|
46
|
+
<category><![CDATA[GlennG]]></category>
|
47
|
+
|
48
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=97183</guid>
|
49
|
+
<description><![CDATA[<p><img src="http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2014/12/1420303878Fotolia_22900249_Subscription_Monthly_M.jpg" alt="Head of the 500 Series Shinkansen" width="2206" height="861" class="aligncenter size-full wp-image-97343" /><p>There used to be a time when installing Ruby and the associated Ruby on Rails web framework was a complete pain. Since then, all sorts of solutions have sprung up to make this process a little bit less painful and tedious. One of the latest is called Tokaido and makes the installation a breeze. But, it abstracts away so much from the user that what Tokaido actually does on your system can be somewhat confusing for a beginner. In this article, we'll take a look at how to use Tokaido to get Ruby/Rails up and running, as well as what kind of stuff Tokaido brings along with it.</p></p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/tokaido-quick-start-rails/">Tokaido: Quick Start with Rails</a>%</em></p>]]></description>
|
50
|
+
<wfw:commentRss>http://www.sitepoint.com/tokaido-quick-start-rails/feed/</wfw:commentRss>
|
51
|
+
<slash:comments>2</slash:comments>
|
52
|
+
</item>
|
53
|
+
<item>
|
54
|
+
<title>Ruby on Medicine: Converting DICOM to JPG</title>
|
55
|
+
<link>http://www.sitepoint.com/ruby-on-medicine-converting-dicom-to-jpg/</link>
|
56
|
+
<comments>http://www.sitepoint.com/ruby-on-medicine-converting-dicom-to-jpg/#comments</comments>
|
57
|
+
<pubDate>Mon, 12 Jan 2015 15:00:42 +0000</pubDate>
|
58
|
+
<dc:creator><![CDATA[Abder-Rahman Ali]]></dc:creator>
|
59
|
+
<category><![CDATA[Gems]]></category>
|
60
|
+
<category><![CDATA[Ruby]]></category>
|
61
|
+
<category><![CDATA[GlennG]]></category>
|
62
|
+
|
63
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=97689</guid>
|
64
|
+
<description><![CDATA[<p><p>This article will be the first article in the Ruby on Medicine (RoM) series focused on how Ruby can be applied to the medical domain.</p>
|
65
|
+
|
66
|
+
<p>In this tutorial, I will show you how to convert a DICOM file to a JPG image, which allows us to perform different operations on that image, which we will see in upcoming articles of this series.</p>
|
67
|
+
</p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/ruby-on-medicine-converting-dicom-to-jpg/">Ruby on Medicine: Converting DICOM to JPG</a>%</em></p>]]></description>
|
68
|
+
<wfw:commentRss>http://www.sitepoint.com/ruby-on-medicine-converting-dicom-to-jpg/feed/</wfw:commentRss>
|
69
|
+
<slash:comments>0</slash:comments>
|
70
|
+
</item>
|
71
|
+
<item>
|
72
|
+
<title>Messaging with Rails and Mailboxer</title>
|
73
|
+
<link>http://www.sitepoint.com/messaging-rails-mailboxer/</link>
|
74
|
+
<comments>http://www.sitepoint.com/messaging-rails-mailboxer/#comments</comments>
|
75
|
+
<pubDate>Thu, 08 Jan 2015 15:00:40 +0000</pubDate>
|
76
|
+
<dc:creator><![CDATA[Ilya Bodrov]]></dc:creator>
|
77
|
+
<category><![CDATA[Gems]]></category>
|
78
|
+
<category><![CDATA[Ruby]]></category>
|
79
|
+
<category><![CDATA[Ruby on Rails]]></category>
|
80
|
+
<category><![CDATA[GlennG]]></category>
|
81
|
+
|
82
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=97356</guid>
|
83
|
+
<description><![CDATA[<p><p>Mailboxer is a Rails gem that is a part of the <a href="https://github.com/ging/social_stream">social_stream</a> framework for building social networks. It is a generic messaging system that allows any model to act "messageable", equipping it with some versatile methods. With Mailboxer, you can create conversations with one or more recipients (messages are organized into folders - sentbox, inbox, trash) and send notifications via email. It is even possible to send messages between different models and add attachments! The only drawback is the lack of documentation, so I hope this post will be useful.</p></p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/messaging-rails-mailboxer/">Messaging with Rails and Mailboxer</a>%</em></p>]]></description>
|
84
|
+
<wfw:commentRss>http://www.sitepoint.com/messaging-rails-mailboxer/feed/</wfw:commentRss>
|
85
|
+
<slash:comments>0</slash:comments>
|
86
|
+
</item>
|
87
|
+
<item>
|
88
|
+
<title>A Peek at Ruby in 2015</title>
|
89
|
+
<link>http://www.sitepoint.com/ruby-peek-2015/</link>
|
90
|
+
<comments>http://www.sitepoint.com/ruby-peek-2015/#comments</comments>
|
91
|
+
<pubDate>Mon, 29 Dec 2014 16:00:33 +0000</pubDate>
|
92
|
+
<dc:creator><![CDATA[Glenn Goodrich]]></dc:creator>
|
93
|
+
<category><![CDATA[Ruby]]></category>
|
94
|
+
<category><![CDATA[GlennG]]></category>
|
95
|
+
|
96
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=97178</guid>
|
97
|
+
<description><![CDATA[<p><img src="http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2014/12/1419703173Fotolia_70588864_Subscription_Monthly_M.jpg" alt="2015 new year" width="1592" height="1194" class="aligncenter size-full wp-image-97179" /><p>As 2014 comes to a close, I thought I'd take a quick look at what 2015 may offer in the land of Ruby. Much of how 2015 opens will, obviously, be based on the final words of 2014, so we'll start with some discussion of this year and try to extrapolate that into the future. Also, I am going to focus in on Ruby and Rails, more than anything else, mainly because it's what I know.</p></p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/ruby-peek-2015/">A Peek at Ruby in 2015</a>%</em></p>]]></description>
|
98
|
+
<wfw:commentRss>http://www.sitepoint.com/ruby-peek-2015/feed/</wfw:commentRss>
|
99
|
+
<slash:comments>0</slash:comments>
|
100
|
+
</item>
|
101
|
+
<item>
|
102
|
+
<title>What Editor Do Rubyists Use?</title>
|
103
|
+
<link>http://www.sitepoint.com/editor-rubyists-use/</link>
|
104
|
+
<comments>http://www.sitepoint.com/editor-rubyists-use/#comments</comments>
|
105
|
+
<pubDate>Mon, 22 Dec 2014 16:00:50 +0000</pubDate>
|
106
|
+
<dc:creator><![CDATA[Abder-Rahman Ali]]></dc:creator>
|
107
|
+
<category><![CDATA[Ruby]]></category>
|
108
|
+
<category><![CDATA[GlennG]]></category>
|
109
|
+
|
110
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=96963</guid>
|
111
|
+
<description><![CDATA[<p><p>Well, you've decided to learn Ruby, have you? That's great! Ruby is a wonderful language that aims to make programmers happy. Go for it! As you enter the world of Ruby he goes, you realize, "I need an editor". OK, Google, find me the best Ruby editor.</p>
|
112
|
+
|
113
|
+
<p>Holy smoke! There are a ton of editors, each with a community that swears by its features. "Use vim!" "Use Emacs!" "Use TextMate!" "Use Sublime Text!". You recoil in fear....what if you make the wrong choice???</p>
|
114
|
+
|
115
|
+
<p>This short story, which likely applied to many Rubyists, I decided to interview established Rubyists their best Ruby editor. If nothing else, this will show which editors are used by more Rubyists, with some data as to why. My hope is that it will serve as a guide for newcomers to Ruby, or possibly even those already working with Ruby, on which editors are popular.</p></p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/editor-rubyists-use/">What Editor Do Rubyists Use?</a>%</em></p>]]></description>
|
116
|
+
<wfw:commentRss>http://www.sitepoint.com/editor-rubyists-use/feed/</wfw:commentRss>
|
117
|
+
<slash:comments>0</slash:comments>
|
118
|
+
</item>
|
119
|
+
<item>
|
120
|
+
<title>Chruby and Rbenv Tips and Tricks</title>
|
121
|
+
<link>http://www.sitepoint.com/chruby-rbenv-tips-tricks/</link>
|
122
|
+
<comments>http://www.sitepoint.com/chruby-rbenv-tips-tricks/#comments</comments>
|
123
|
+
<pubDate>Thu, 18 Dec 2014 15:00:36 +0000</pubDate>
|
124
|
+
<dc:creator><![CDATA[Jesse Herrick]]></dc:creator>
|
125
|
+
<category><![CDATA[Best Practices]]></category>
|
126
|
+
<category><![CDATA[Ruby]]></category>
|
127
|
+
|
128
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=96712</guid>
|
129
|
+
<description><![CDATA[<p><img src="http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2014/12/1418748789multiple-268x300.png" alt="multiple" width="268" height="300" class="alignleft size-medium wp-image-96714" /><p><a href="https://github.com/sstephenson/rbenv">Rbenv</a> and <a href="https://github.com/postmodern/chruby">chruby</a> are the cool kids on the block now. Obviously, we want the most we can get out of our favorite tools. So this article isn't about which one to like more, nor is it an <a href="http://www.sitepoint.com/up-and-running-with-rbenv/">introduction</a> to either version manager. Instead, we're going to cover some advanced rbenv and chruby usage to maximize your productivity.</p>
|
130
|
+
</p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/chruby-rbenv-tips-tricks/">Chruby and Rbenv Tips and Tricks</a>%</em></p>]]></description>
|
131
|
+
<wfw:commentRss>http://www.sitepoint.com/chruby-rbenv-tips-tricks/feed/</wfw:commentRss>
|
132
|
+
<slash:comments>0</slash:comments>
|
133
|
+
</item>
|
134
|
+
<item>
|
135
|
+
<title>Advanced Search with Ransack</title>
|
136
|
+
<link>http://www.sitepoint.com/advanced-search-ransack/</link>
|
137
|
+
<comments>http://www.sitepoint.com/advanced-search-ransack/#comments</comments>
|
138
|
+
<pubDate>Mon, 15 Dec 2014 15:00:42 +0000</pubDate>
|
139
|
+
<dc:creator><![CDATA[Islam Wazery]]></dc:creator>
|
140
|
+
<category><![CDATA[Gems]]></category>
|
141
|
+
<category><![CDATA[Ruby]]></category>
|
142
|
+
<category><![CDATA[Ruby on Rails]]></category>
|
143
|
+
<category><![CDATA[GlennG]]></category>
|
144
|
+
|
145
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=96510</guid>
|
146
|
+
<description><![CDATA[<p><p>In this tutorial we will explore how to add complex search functionality into your Rails application. This task will be made easier by the awesome Ransack Ruby gem. Ransack provides excellent helpers and builders for handling advanced searches on your models. It has some really powerful features available out of the box without writing a lot of code, such as sorting or conditional search. </p></p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/advanced-search-ransack/">Advanced Search with Ransack</a>%</em></p>]]></description>
|
147
|
+
<wfw:commentRss>http://www.sitepoint.com/advanced-search-ransack/feed/</wfw:commentRss>
|
148
|
+
<slash:comments>0</slash:comments>
|
149
|
+
</item>
|
150
|
+
<item>
|
151
|
+
<title>Fun with Robots, Lita, and HipChat</title>
|
152
|
+
<link>http://www.sitepoint.com/fun-robots-lita-hipchat/</link>
|
153
|
+
<comments>http://www.sitepoint.com/fun-robots-lita-hipchat/#comments</comments>
|
154
|
+
<pubDate>Thu, 11 Dec 2014 15:00:26 +0000</pubDate>
|
155
|
+
<dc:creator><![CDATA[Ilya Bodrov]]></dc:creator>
|
156
|
+
<category><![CDATA[Gems]]></category>
|
157
|
+
<category><![CDATA[Ruby]]></category>
|
158
|
+
<category><![CDATA[Ruby on Rails]]></category>
|
159
|
+
|
160
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=96173</guid>
|
161
|
+
<description><![CDATA[<p>I bet you’ve watched some kind of a science fiction film where a hero boots up a super-duper PC and, instead of doing all the tasks manually with a keyboard and mouse, just uses voice commands (while drinking coffee or cleaning the superhero costume). That looks really cool. Couldn’t we create something similar, yet simpler, […]</p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/fun-robots-lita-hipchat/">Fun with Robots, Lita, and HipChat</a>%</em></p>]]></description>
|
162
|
+
<wfw:commentRss>http://www.sitepoint.com/fun-robots-lita-hipchat/feed/</wfw:commentRss>
|
163
|
+
<slash:comments>0</slash:comments>
|
164
|
+
</item>
|
165
|
+
<item>
|
166
|
+
<title>All I Want for Christmas: Rails 4 Test Prescriptions</title>
|
167
|
+
<link>http://www.sitepoint.com/want-christmas-rails-4-test-prescriptions/</link>
|
168
|
+
<comments>http://www.sitepoint.com/want-christmas-rails-4-test-prescriptions/#comments</comments>
|
169
|
+
<pubDate>Tue, 09 Dec 2014 15:00:52 +0000</pubDate>
|
170
|
+
<dc:creator><![CDATA[James Hibbard]]></dc:creator>
|
171
|
+
<category><![CDATA[Ruby]]></category>
|
172
|
+
<category><![CDATA[AdamR]]></category>
|
173
|
+
<category><![CDATA[all I want for christmas]]></category>
|
174
|
+
<category><![CDATA[test-driven development]]></category>
|
175
|
+
|
176
|
+
<guid isPermaLink="false">http://www.sitepoint.com/?p=96076</guid>
|
177
|
+
<description><![CDATA[<p><p><em>We asked SitePoint authors what developer toys they would want for Christmas, then managed to source them — without relying on Santa.</em></p>
|
178
|
+
|
179
|
+
<p>When I started with Rails, I was introduced to something called “Test-Driven Development”. The theory is simple: write tests for your code, so that you can make changes to it with confidence.</p>
|
180
|
+
|
181
|
+
<h2 id="why-i-wanted-this-book">Why I wanted this book</h2>
|
182
|
+
|
183
|
+
<p>Initially, that sounded like a no-brainer, but when I tried putting it into practice I was assailed with questions and doubts: What do I test? Which tools should I use? Am I even doing it right?</p>
|
184
|
+
|
185
|
+
<p>Fast forward several years and the situation hasn’t become much better. Sure, I write tests for my code, but as my apps get more complex, the questions and doubts remain. That’s why “Rails 4 Test Prescriptions” by Noel Rappin was high on my Christmas wish list.</p>
|
186
|
+
|
187
|
+
<h2 id="the-experience-so-far">The experience so far</h2>
|
188
|
+
|
189
|
+
<p>The book doesn’t disappoint. It starts off slowly by covering the basics of testing each part of a Rails app, as well as using mocks, stubs and helpful gems such as webrat. It then gathers pace, moving on to more advanced topics such as testing the security of an app, testing external services (which always caused me headaches) and testing JavaScript.</p>
|
190
|
+
|
191
|
+
<p>In summary, although rather dry in places, this book contains something for every Rails developer. Whether it’s getting up to speed with unfamiliar tools, focusing on what to test, or choosing the right tools for the job, this is a veritable must-have for your coding toolbox.</p>
|
192
|
+
|
193
|
+
<p><em>What would you build with more knowledge of Test Driven Development? Answer in the comments, we’ll pick the best answer and send you a copy of the book!</em></p></p><p><em>Continue reading %<a rel="nofollow" href="http://www.sitepoint.com/want-christmas-rails-4-test-prescriptions/">All I Want for Christmas: Rails 4 Test Prescriptions</a>%</em></p>]]></description>
|
194
|
+
<wfw:commentRss>http://www.sitepoint.com/want-christmas-rails-4-test-prescriptions/feed/</wfw:commentRss>
|
195
|
+
<slash:comments>0</slash:comments>
|
196
|
+
</item>
|
197
|
+
</channel>
|
198
|
+
</rss>
|
199
|
+
|
200
|
+
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/
|
201
|
+
|
202
|
+
Page Caching using memcached (Requested URI is rejected)
|
203
|
+
Object Caching 833/849 objects using memcached
|
204
|
+
Content Delivery Network via Amazon Web Services: CloudFront: dab1nmslvvntp.cloudfront.net
|
205
|
+
|
206
|
+
Served from: www.sitepoint.com @ 2015-01-17 04:23:15 by W3 Total Cache -->
|
207
|
+
|
208
|
+
---
|
209
|
+
|
210
|
+
feed.format: rss 2.0
|
211
|
+
feed.title: SitePoint » Ruby
|
212
|
+
feed.url: http://www.sitepoint.com
|
213
|
+
feed.summary: Learn CSS | HTML5 | JavaScript | Wordpress | Tutorials-Web Development | Reference | Books and More
|
214
|
+
feed.generator: http://wordpress.org/?v=4.0
|
215
|
+
|
216
|
+
feed.items[0].title: Rails Model Caching with Redis
|
217
|
+
feed.items[0].url: http://www.sitepoint.com/rails-model-caching-redis/
|
218
|
+
feed.items[0].guid: http://www.sitepoint.com/?p=97720
|
219
|
+
|
data/test/helper.rb
CHANGED
@@ -6,8 +6,10 @@
|
|
6
6
|
require 'minitest/autorun'
|
7
7
|
|
8
8
|
require 'logutils'
|
9
|
+
require 'textutils'
|
9
10
|
require 'fetcher'
|
10
11
|
|
12
|
+
|
11
13
|
## our own code
|
12
14
|
|
13
15
|
require 'feedparser'
|
@@ -15,21 +17,46 @@ require 'feedparser'
|
|
15
17
|
|
16
18
|
LogUtils::Logger.root.level = :debug
|
17
19
|
|
18
|
-
def parse_feed( url )
|
19
|
-
xml = Fetcher.read( url )
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
## add custom assert
|
22
|
+
module MiniTest
|
23
|
+
class Test
|
24
|
+
|
25
|
+
def assert_feed_tests_for( name )
|
26
|
+
b = BlockReader.from_file( "#{FeedParser.root}/test/feeds/#{name}" ).read
|
27
|
+
|
28
|
+
## puts " [debug] block.size: #{b.size}"
|
29
|
+
|
30
|
+
xml = b[0]
|
31
|
+
tests = b[1]
|
23
32
|
|
33
|
+
feed = FeedParser::Parser.parse( xml )
|
24
34
|
|
35
|
+
tests.each_line do |line|
|
36
|
+
if line =~ /^[ \t]*$/
|
37
|
+
next ## skip blank lines
|
38
|
+
end
|
39
|
+
|
40
|
+
line = line.strip
|
41
|
+
|
42
|
+
pos = line.index(':') ## assume first colon (:) is separator
|
43
|
+
expr = line[0...pos].strip ## NOTE: do NOT include colon (thus, use tree dots ...)
|
44
|
+
value = line[pos+1..-1].strip
|
45
|
+
|
46
|
+
code="assert_equal '#{value}', #{expr}"
|
47
|
+
puts "eval #{code}"
|
48
|
+
eval( code )
|
49
|
+
end # each line
|
50
|
+
end
|
25
51
|
|
26
|
-
def read_feed_from_file( name )
|
27
|
-
File.read( "#{FeedParser.root}/test/feeds/#{name}")
|
28
52
|
end
|
53
|
+
end # module MiniTest
|
54
|
+
|
29
55
|
|
30
|
-
def parse_feed_from_file( name )
|
31
|
-
xml = read_feed_from_file( name )
|
32
56
|
|
33
|
-
|
57
|
+
def fetch_and_parse_feed( url )
|
58
|
+
xml = Fetcher.read( url )
|
59
|
+
|
60
|
+
FeedParser::Parser.parse( xml )
|
34
61
|
end
|
35
62
|
|
data/test/test_atom.rb
CHANGED
@@ -6,40 +6,22 @@
|
|
6
6
|
|
7
7
|
require 'helper'
|
8
8
|
|
9
|
-
class TestAtom < MiniTest::Test
|
10
|
-
|
11
|
-
def test_rubyonrails
|
12
|
-
feed = parse_feed( 'http://weblog.rubyonrails.org/feed/atom.xml' )
|
13
|
-
|
14
|
-
assert_equal 'atom', feed.format
|
15
|
-
assert_equal 'http://weblog.rubyonrails.org/', feed.url
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
def test_railstutorial
|
20
|
-
feed = parse_feed( 'http://feeds.feedburner.com/railstutorial?format=xml' )
|
21
|
-
|
22
|
-
assert_equal 'atom', feed.format
|
23
|
-
assert_equal 'http://news.railstutorial.org/', feed.url
|
24
|
-
end
|
25
9
|
|
10
|
+
class TestAtom < MiniTest::Test
|
26
11
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
12
|
+
def test_all
|
13
|
+
names = [
|
14
|
+
'googlegroups.atom',
|
15
|
+
'googlegroups2.atom',
|
16
|
+
'rubyonrails.atom',
|
17
|
+
'railstutorial.atom',
|
18
|
+
'headius.atom',
|
19
|
+
]
|
20
|
+
|
21
|
+
names.each do |name|
|
22
|
+
assert_feed_tests_for( name )
|
23
|
+
end
|
32
24
|
end
|
33
25
|
|
34
26
|
|
35
|
-
|
36
|
-
feed = parse_feed( 'http://blog.headius.com/feeds/posts/default' )
|
37
|
-
|
38
|
-
assert_equal 'atom', feed.format
|
39
|
-
assert_equal 'Blogger', feed.generator
|
40
|
-
assert_equal 'Headius', feed.title
|
41
|
-
assert_equal 'Helping the JVM Into the 21st Century', feed.title2 # aka subtitle in atom
|
42
|
-
assert_equal 'http://blog.headius.com/', feed.url
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
27
|
+
end # class TestAtom
|
@@ -0,0 +1,45 @@
|
|
1
|
+
###
|
2
|
+
# to run use
|
3
|
+
# ruby -I ./lib -I ./test test/test_atom_live.rb
|
4
|
+
# or better
|
5
|
+
# rake test
|
6
|
+
|
7
|
+
require 'helper'
|
8
|
+
|
9
|
+
class TestAtomLive < MiniTest::Test
|
10
|
+
|
11
|
+
def test_rubyonrails
|
12
|
+
feed = fetch_and_parse_feed( 'http://weblog.rubyonrails.org/feed/atom.xml' )
|
13
|
+
|
14
|
+
assert_equal 'atom', feed.format
|
15
|
+
assert_equal 'http://weblog.rubyonrails.org/', feed.url
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def test_railstutorial
|
20
|
+
feed = fetch_and_parse_feed( 'http://feeds.feedburner.com/railstutorial?format=xml' )
|
21
|
+
|
22
|
+
assert_equal 'atom', feed.format
|
23
|
+
assert_equal 'http://news.railstutorial.org/', feed.url
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def test_googlegroup
|
28
|
+
feed = fetch_and_parse_feed( 'https://groups.google.com/forum/feed/beerdb/topics/atom.xml?num=15' )
|
29
|
+
|
30
|
+
assert_equal 'atom', feed.format
|
31
|
+
assert_equal 'https://groups.google.com/d/forum/beerdb', feed.url
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def test_headius
|
36
|
+
feed = fetch_and_parse_feed( 'http://blog.headius.com/feeds/posts/default' )
|
37
|
+
|
38
|
+
assert_equal 'atom', feed.format
|
39
|
+
assert_equal 'Blogger', feed.generator
|
40
|
+
assert_equal 'Headius', feed.title
|
41
|
+
assert_equal 'Helping the JVM Into the 21st Century', feed.summary # aka subtitle in atom
|
42
|
+
assert_equal 'http://blog.headius.com/', feed.url
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/test/test_rss.rb
CHANGED
@@ -6,33 +6,21 @@
|
|
6
6
|
|
7
7
|
require 'helper'
|
8
8
|
|
9
|
-
class TestRss < MiniTest::Test
|
10
|
-
|
11
|
-
|
12
|
-
def test_rubyflow
|
13
|
-
feed = parse_feed( 'http://feeds.feedburner.com/Rubyflow?format=xml' )
|
14
|
-
|
15
|
-
assert_equal 'rss 2.0', feed.format
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_sitepointruby
|
19
|
-
feed = parse_feed( 'http://www.sitepoint.com/ruby/feed/' )
|
20
9
|
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_lambdatheultimate
|
25
|
-
## check - has no item.guid - will use item.link for guid
|
26
|
-
feed = parse_feed( 'http://lambda-the-ultimate.org/rss.xml' )
|
10
|
+
class TestRss < MiniTest::Test
|
27
11
|
|
28
|
-
|
12
|
+
def test_all
|
13
|
+
names = [
|
14
|
+
'rubyflow.rss2',
|
15
|
+
'sitepoint.rss2',
|
16
|
+
'lambdatheultimate.rss2',
|
17
|
+
'rubymine.rss2',
|
18
|
+
]
|
19
|
+
|
20
|
+
names.each do |name|
|
21
|
+
assert_feed_tests_for( name )
|
22
|
+
end
|
29
23
|
end
|
30
24
|
|
31
|
-
def test_rubymine
|
32
|
-
# includes item/content:encoded
|
33
|
-
feed = parse_feed( 'http://feeds.feedburner.com/jetbrains_rubymine?format=xml' )
|
34
|
-
|
35
|
-
assert_equal 'rss 2.0', feed.format
|
36
|
-
end
|
37
25
|
|
38
|
-
end
|
26
|
+
end # class TestRss
|
@@ -0,0 +1,38 @@
|
|
1
|
+
###
|
2
|
+
# to run use
|
3
|
+
# ruby -I ./lib -I ./test test/test_rss_live.rb
|
4
|
+
# or better
|
5
|
+
# rake test
|
6
|
+
|
7
|
+
require 'helper'
|
8
|
+
|
9
|
+
class TestRssLive < MiniTest::Test
|
10
|
+
|
11
|
+
|
12
|
+
def test_rubyflow
|
13
|
+
feed = fetch_and_parse_feed( 'http://feeds.feedburner.com/Rubyflow?format=xml' )
|
14
|
+
|
15
|
+
assert_equal 'rss 2.0', feed.format
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_sitepointruby
|
19
|
+
feed = fetch_and_parse_feed( 'http://www.sitepoint.com/ruby/feed/' )
|
20
|
+
|
21
|
+
assert_equal 'rss 2.0', feed.format
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_lambdatheultimate
|
25
|
+
## check - has no item.guid - will use item.link for guid
|
26
|
+
feed = fetch_and_parse_feed( 'http://lambda-the-ultimate.org/rss.xml' )
|
27
|
+
|
28
|
+
assert_equal 'rss 2.0', feed.format
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_rubymine
|
32
|
+
# includes item/content:encoded
|
33
|
+
feed = fetch_and_parse_feed( 'http://feeds.feedburner.com/jetbrains_rubymine?format=xml' )
|
34
|
+
|
35
|
+
assert_equal 'rss 2.0', feed.format
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|