feedjira 2.2.0 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +635 -6
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +6 -12
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +5 -5
  7. data/README.md +37 -99
  8. data/Rakefile +5 -5
  9. data/feedjira.gemspec +27 -19
  10. data/lib/feedjira.rb +69 -41
  11. data/lib/feedjira/configuration.rb +3 -8
  12. data/lib/feedjira/core_ext.rb +3 -3
  13. data/lib/feedjira/core_ext/date.rb +1 -1
  14. data/lib/feedjira/core_ext/time.rb +2 -2
  15. data/lib/feedjira/date_time_utilities.rb +2 -2
  16. data/lib/feedjira/date_time_utilities/date_time_pattern_parser.rb +2 -2
  17. data/lib/feedjira/feed.rb +10 -80
  18. data/lib/feedjira/feed_entry_utilities.rb +4 -4
  19. data/lib/feedjira/parser.rb +4 -1
  20. data/lib/feedjira/parser/atom.rb +3 -3
  21. data/lib/feedjira/parser/atom_entry.rb +1 -1
  22. data/lib/feedjira/parser/atom_feed_burner.rb +4 -4
  23. data/lib/feedjira/parser/atom_feed_burner_entry.rb +1 -1
  24. data/lib/feedjira/parser/atom_youtube.rb +2 -2
  25. data/lib/feedjira/parser/atom_youtube_entry.rb +1 -1
  26. data/lib/feedjira/parser/google_docs_atom.rb +3 -3
  27. data/lib/feedjira/parser/google_docs_atom_entry.rb +1 -1
  28. data/lib/feedjira/parser/itunes_rss_item.rb +1 -1
  29. data/lib/feedjira/parser/json_feed.rb +39 -0
  30. data/lib/feedjira/parser/json_feed_item.rb +51 -0
  31. data/lib/feedjira/parser/podlove_chapter.rb +1 -1
  32. data/lib/feedjira/parser/rss.rb +1 -1
  33. data/lib/feedjira/parser/rss_entry.rb +5 -1
  34. data/lib/feedjira/parser/rss_feed_burner.rb +1 -1
  35. data/lib/feedjira/preprocessor.rb +1 -1
  36. data/lib/feedjira/version.rb +1 -1
  37. data/spec/feedjira/configuration_spec.rb +9 -16
  38. data/spec/feedjira/date_time_utilities_spec.rb +20 -20
  39. data/spec/feedjira/feed_entry_utilities_spec.rb +18 -18
  40. data/spec/feedjira/feed_spec.rb +15 -229
  41. data/spec/feedjira/feed_utilities_spec.rb +72 -72
  42. data/spec/feedjira/parser/atom_entry_spec.rb +34 -34
  43. data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +16 -16
  44. data/spec/feedjira/parser/atom_feed_burner_spec.rb +121 -119
  45. data/spec/feedjira/parser/atom_spec.rb +78 -76
  46. data/spec/feedjira/parser/atom_youtube_entry_spec.rb +38 -38
  47. data/spec/feedjira/parser/atom_youtube_spec.rb +15 -15
  48. data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +8 -8
  49. data/spec/feedjira/parser/google_docs_atom_spec.rb +23 -21
  50. data/spec/feedjira/parser/itunes_rss_item_spec.rb +37 -37
  51. data/spec/feedjira/parser/itunes_rss_owner_spec.rb +5 -5
  52. data/spec/feedjira/parser/itunes_rss_spec.rb +118 -116
  53. data/spec/feedjira/parser/json_feed_item_spec.rb +79 -0
  54. data/spec/feedjira/parser/json_feed_spec.rb +53 -0
  55. data/spec/feedjira/parser/podlove_chapter_spec.rb +12 -12
  56. data/spec/feedjira/parser/rss_entry_spec.rb +30 -30
  57. data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +32 -32
  58. data/spec/feedjira/parser/rss_feed_burner_spec.rb +47 -45
  59. data/spec/feedjira/parser/rss_spec.rb +36 -36
  60. data/spec/feedjira/preprocessor_spec.rb +6 -6
  61. data/spec/feedjira_spec.rb +145 -0
  62. data/spec/sample_feeds.rb +27 -26
  63. data/spec/sample_feeds/HuffPostCanada.xml +279 -0
  64. data/spec/sample_feeds/json_feed.json +156 -0
  65. data/spec/spec_helper.rb +5 -5
  66. metadata +31 -49
  67. data/fixtures/vcr_cassettes/fetch_failure.yml +0 -62
  68. data/fixtures/vcr_cassettes/parse_error.yml +0 -222
  69. data/fixtures/vcr_cassettes/success.yml +0 -281
  70. data/spec/sample_feeds/InvalidDateFormat.xml +0 -20
@@ -1,281 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://feedjira.com/blog/feed.xml
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.9.2
12
- response:
13
- status:
14
- code: 200
15
- message:
16
- headers:
17
- date:
18
- - Mon, 31 Oct 2016 02:29:13 GMT
19
- server:
20
- - Apache/2.4.18 (Ubuntu)
21
- last-modified:
22
- - Fri, 07 Oct 2016 14:37:00 GMT
23
- etag:
24
- - '"393e-53e4757c9db00-gzip"'
25
- accept-ranges:
26
- - bytes
27
- vary:
28
- - Accept-Encoding
29
- content-length:
30
- - '5051'
31
- connection:
32
- - close
33
- content-type:
34
- - application/xml
35
- body:
36
- encoding: ASCII-8BIT
37
- string: |
38
- <?xml version="1.0" encoding="UTF-8"?>
39
- <feed xmlns="http://www.w3.org/2005/Atom">
40
- <title>Feedjira Blog</title>
41
- <subtitle>A Blog for Feedjira</subtitle>
42
- <id>http://feedjira.com/blog</id>
43
- <link href="http://feedjira.com/blog"/>
44
- <link href="http://feedjira.com/blog/feed.xml" rel="self"/>
45
- <updated>2015-06-05T00:00:00Z</updated>
46
- <author>
47
- <name>Jon Allured</name>
48
- </author>
49
- <entry>
50
- <title>Feedjira Two-Point-Oh</title>
51
- <link rel="alternate" href="http://feedjira.com/blog/2015/06/05/feedjira-two-point-oh.html"/>
52
- <id>http://feedjira.com/blog/2015/06/05/feedjira-two-point-oh.html</id>
53
- <published>2015-06-05T00:00:00Z</published>
54
- <updated>2015-04-17T16:16:07-05:00</updated>
55
- <author>
56
- <name>Jon Allured</name>
57
- </author>
58
- <content type="html">&lt;p&gt;About a year ago, I took Feedjira to &lt;a href="http://feedjira.com/blog/2014/03/17/feedjira-goes-one-point-oh.html"&gt;version 1.0&lt;/a&gt; and today I&amp;rsquo;m releasing
59
- version 2.0. Not much has changed actually - the biggest difference is that
60
- &lt;code&gt;curb&lt;/code&gt; has been replaced with &lt;code&gt;faraday&lt;/code&gt;. For many users, upgrading to version
61
- 2.0 won&amp;rsquo;t require anything more than a &lt;code&gt;bundle update feedjira&lt;/code&gt;.&lt;/p&gt;
62
-
63
- &lt;p&gt;The other big change is that the &lt;code&gt;Feedjira#update&lt;/code&gt; method was removed. It was
64
- unreliable and mostly just caused issues. To read more about why this was
65
- removed, check out &lt;a href="https://github.com/feedjira/feedjira/issues/218#issuecomment-40282091"&gt;this comment&lt;/a&gt; on a GitHub issue that was opened
66
- about it not working as expected.&lt;/p&gt;
67
-
68
- &lt;p&gt;I&amp;rsquo;ve also updated the site to reflect the changes in this version. I took the
69
- opportunity to greatly simply things and got just about all the documentation to
70
- fit on one page.&lt;/p&gt;
71
-
72
- &lt;p&gt;I hope you like version 2.0 - feel free to hit me up &lt;a href="https://twitter.com/feedjira"&gt;on Twitter&lt;/a&gt; or if
73
- you have any trouble, open a &lt;a href="https://github.com/feedjira/feedjira/issues"&gt;GitHub issue&lt;/a&gt; and I&amp;rsquo;ll give you a hand.&lt;/p&gt;
74
-
75
- &lt;p&gt;Finally, thanks to those that gave me feedback on either my thoughts on version
76
- 2.0 or the release candidate - I really appreciate it!&lt;/p&gt;
77
- </content>
78
- </entry>
79
- <entry>
80
- <title>Thoughts on Version Two-Point-Oh</title>
81
- <link rel="alternate" href="http://feedjira.com/blog/2014/04/14/thoughts-on-version-two-point-oh.html"/>
82
- <id>http://feedjira.com/blog/2014/04/14/thoughts-on-version-two-point-oh.html</id>
83
- <published>2014-04-14T00:00:00Z</published>
84
- <updated>2014-09-05T12:15:28-05:00</updated>
85
- <author>
86
- <name>Jon Allured</name>
87
- </author>
88
- <content type="html">&lt;p&gt;TLDR: development of version 2.0 is being done on the &lt;a href="https://github.com/feedjira/feedjira/tree/two-point-oh"&gt;two-point-oh branch&lt;/a&gt;
89
- and a &lt;a href="https://github.com/feedjira/feedjira/issues/221"&gt;GitHub issue&lt;/a&gt; is open for you to give feedback on its direction.&lt;/p&gt;
90
-
91
- &lt;p&gt;I&amp;rsquo;ve starting work on a rewrite for Feedjira and I wanted to try using a &lt;a href="https://github.com/feedjira/feedjira/issues/221"&gt;GitHub
92
- issue&lt;/a&gt; to discuss what I&amp;rsquo;d like to see in the new version. I&amp;rsquo;m very
93
- interested in what users think, so please chime in!!&lt;/p&gt;
94
-
95
- &lt;p&gt;In no particular order, here are some design goals for the new version:&lt;/p&gt;
96
-
97
- &lt;h2&gt;Change HTTP Library&lt;/h2&gt;
98
-
99
- &lt;p&gt;This gem depends on &lt;a href="https://github.com/taf2/curb"&gt;curb&lt;/a&gt;, but I&amp;rsquo;d like to switch that to something that will
100
- allow me to support JRuby. I did some experimenting and really liked working
101
- with &lt;a href="https://github.com/lostisland/faraday"&gt;Faraday&lt;/a&gt;, so that&amp;rsquo;s what I&amp;rsquo;m using at the moment.&lt;/p&gt;
102
-
103
- &lt;h2&gt;Forget Concurrency&lt;/h2&gt;
104
-
105
- &lt;p&gt;Throwing an array of feed urls at Feedjira and watching it concurrently fetch
106
- and parse them extremely quickly is cool in READMEs and demos, but I don&amp;rsquo;t think
107
- it&amp;rsquo;s reality. I think what&amp;rsquo;s much more likely is a single url being passed and
108
- concurrency being dealt with in the application, workers being the likely
109
- approach.&lt;/p&gt;
110
-
111
- &lt;h2&gt;More Objects&lt;/h2&gt;
112
-
113
- &lt;p&gt;Feedjira has a dirty little secret and it&amp;rsquo;s the &lt;code&gt;Feedjira::Feed&lt;/code&gt; class. If you
114
- open that sucker up, you&amp;rsquo;ll see 19 class methods and 0 instance methods. These
115
- class methods do everything from fetching and parsing to setting up curb and
116
- unzipping raw xml. Not only is &lt;a href="http://en.wikipedia.org/wiki/Single_responsibility_principle"&gt;SRP&lt;/a&gt; off in the corner crying, its a mess to
117
- test. I&amp;rsquo;d like to break this down into smaller objects that get instantiated and
118
- passed around in normal OO fashion.&lt;/p&gt;
119
-
120
- &lt;h2&gt;Fewer Parsers&lt;/h2&gt;
121
-
122
- &lt;p&gt;One of the things I like best about Feedjira is the ability for a user to define
123
- their own custom parsers and I think its under-used. What I&amp;rsquo;d like to see is
124
- Feedjira ship with a parser for Atom and a parser for RSS - the others are
125
- really just custom parsers.&lt;/p&gt;
126
-
127
- &lt;h2&gt;Custom Parser Project&lt;/h2&gt;
128
-
129
- &lt;p&gt;With version 1.2, I was able to spin off the benchmarks into &lt;a href="https://github.com/feedjira/feedjira-benchmarks"&gt;their own
130
- project&lt;/a&gt; and I was very happy with how it turned out - I&amp;rsquo;d like to see a
131
- similar thing happen with the custom parsers mentioned above. You should be able
132
- to easily grab these parsers and throw them in your application. If you write a
133
- particularly cool custom parser, then you could contribute it back and others
134
- could benefit from it.&lt;/p&gt;
135
-
136
- &lt;h2&gt;Raise Exceptions Instead of Callbacks&lt;/h2&gt;
137
-
138
- &lt;p&gt;Feedjira almost never raises an exception and instead provides the ability to
139
- register callbacks for success and failure situations, but this has proven
140
- brittle and painful. With the new version, I want to see sensible exceptions
141
- raised when something goes wrong and that pretty much removes the need for
142
- callbacks, so those will be cut.&lt;/p&gt;
143
-
144
- &lt;h2&gt;Feed Updating is Business Logic&lt;/h2&gt;
145
-
146
- &lt;p&gt;The updating functionality of Feedjira leaves a lot to be desired - its
147
- inconsistent and there are lots of edges. I tend to steer users away and
148
- encourage them to write this kind of code in their application instead. See
149
- &lt;a href="https://github.com/feedjira/feedjira/issues/218"&gt;this discussion&lt;/a&gt; for more, but needless to say, I&amp;rsquo;d like to see this entire
150
- feature set removed.&lt;/p&gt;
151
-
152
- &lt;h2&gt;Configuration&lt;/h2&gt;
153
-
154
- &lt;p&gt;I want configuration for Feedjira done in a proper config block like most gems.
155
- If you want to change the default parsers, that should be a config option. If
156
- you want to set the user agent, that should be a configuration option.&lt;/p&gt;
157
-
158
- &lt;h2&gt;Feedback Appreciated&lt;/h2&gt;
159
-
160
- &lt;p&gt;Do you have any other ideas to make Feedjira better? Please check out the
161
- &lt;a href="https://github.com/feedjira/feedjira/issues/221"&gt;GitHub issue&lt;/a&gt; and share what you&amp;rsquo;re thinking. I&amp;rsquo;m open to any feedback, so
162
- if I just threw your favorite feature on the chopping block, please tell me!&lt;/p&gt;
163
- </content>
164
- </entry>
165
- <entry>
166
- <title>A Separate Project For Benchmarks</title>
167
- <link rel="alternate" href="http://feedjira.com/blog/2014/04/11/a-separate-project-for-benchmarks.html"/>
168
- <id>http://feedjira.com/blog/2014/04/11/a-separate-project-for-benchmarks.html</id>
169
- <published>2014-04-11T00:00:00Z</published>
170
- <updated>2014-09-05T12:15:28-05:00</updated>
171
- <author>
172
- <name>Jon Allured</name>
173
- </author>
174
- <content type="html">&lt;p&gt;With the release of version 1.2.0, the benchmarks for Feedjira have been moved
175
- to a separate project: &lt;a href="https://github.com/feedjira/feedjira-benchmarks"&gt;https://github.com/feedjira/feedjira-benchmarks&lt;/a&gt;.&lt;/p&gt;
176
-
177
- &lt;p&gt;What&amp;rsquo;s nice about this is that it keeps things much more organized and allowed
178
- me to add a pretty neat new benchmark - more on that in a moment. I also rewrote
179
- the &lt;a href="/benchmarks.html"&gt;Benchmarks page&lt;/a&gt; on this site so please check that out.&lt;/p&gt;
180
-
181
- &lt;p&gt;One benchmark that I didn&amp;rsquo;t pull over to the new project is the fetching one. I
182
- left it out because it relied on the consistency of your network connection and
183
- that didn&amp;rsquo;t feel like it was scientific enough.&lt;/p&gt;
184
-
185
- &lt;p&gt;In its place I&amp;rsquo;ve added a benchmark for parsing speed that&amp;rsquo;s run against each
186
- version of the gem. Its pretty cool - when you clone down the
187
- feedjira-benchmarks project, you also clone down feedjira itself and then the
188
- script moves to each version tag in the git repo, runs the benchmark and records
189
- the results. It was pretty fun to write and works like a charm.&lt;/p&gt;
190
-
191
- &lt;p&gt;For the charts, I ended up learning some &lt;a href="http://www.r-project.org/"&gt;R&lt;/a&gt; so that I could have a little
192
- more control.&lt;/p&gt;
193
-
194
- &lt;p&gt;Benchmarks are really only valuable if they can be reproduced by others, so I&amp;rsquo;ve
195
- written up instructions in the README for setting things up and running them. If
196
- you&amp;rsquo;re interested, take a look and try running them yourself!&lt;/p&gt;
197
-
198
- &lt;p&gt;I&amp;rsquo;ll continue to use the benchmarks to ensure Feedjira stays fast, so you wont
199
- have to worry about your favorite Ruby feed library slowing down. If you have
200
- any feedback for me on the benchmarks, feel free to hit me up on Twitter
201
- (&lt;a href="https://twitter.com/feedjira"&gt;@feedjira&lt;/a&gt;) or &lt;a href="https://github.com/feedjira/feedjira-benchmarks/issues"&gt;open an issue&lt;/a&gt; on the project&amp;rsquo;s repo.&lt;/p&gt;
202
- </content>
203
- </entry>
204
- <entry>
205
- <title>Feedjira Goes One-Point-Oh</title>
206
- <link rel="alternate" href="http://feedjira.com/blog/2014/03/17/feedjira-goes-one-point-oh.html"/>
207
- <id>http://feedjira.com/blog/2014/03/17/feedjira-goes-one-point-oh.html</id>
208
- <published>2014-03-17T00:00:00Z</published>
209
- <updated>2014-09-05T12:15:28-05:00</updated>
210
- <author>
211
- <name>Jon Allured</name>
212
- </author>
213
- <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
214
- Feedzirra. My request was totally out of the blue, so I was pretty pumped when
215
- he got right back to me and said yes. He said that he didn&amp;rsquo;t have time to work
216
- on it anymore and so I should feel free to do whatever I thought was best.&lt;/p&gt;
217
-
218
- &lt;p&gt;Score!&lt;/p&gt;
219
-
220
- &lt;p&gt;My first order of business was to go through the many open issues and pull
221
- requests on GitHub. When I started there were over 60, a number that I&amp;rsquo;ve gotten
222
- down to just a few. I thought it was important to ensure that users saw me treat
223
- their issue as important and even if it was very old (which many were), I asked
224
- if there was anything I could do to help.&lt;/p&gt;
225
-
226
- &lt;p&gt;I was pleasantly surprised by the nice way many people responded and we got to
227
- work addressing their questions and issues.&lt;/p&gt;
228
-
229
- &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 -
230
- bug fixes in patch releases and backward-compatible changes in minor releases.
231
- But I also realized that it was past time for this project to be at version 1.0.
232
- In the SemVer FAQ, they talk about when to release version 1.0 and Feedzirra fit
233
- the bill: it was being used in production, there was a stable API and I was
234
- taking backwards compatibilty seriously.&lt;/p&gt;
235
-
236
- &lt;p&gt;So I treated it as a project at 1.0 and I did my best to release versions that
237
- were backward compatible and added deprecations for what I wanted to do in 1.0.
238
- I saw things that I wanted to completely rewrite, but I resisted the urge to
239
- burn it all down and start again.&lt;/p&gt;
240
-
241
- &lt;p&gt;When I was close to being caught up on the backlog of issues and pull requests,
242
- I started thinking about releasing version 1.0, and I knew I wanted to create a
243
- website for the project. I worked with &lt;a href="http://danielariza.com"&gt;Daniel Ariza&lt;/a&gt; to make it happen. I
244
- ripped apart the README and rewrote just about all the sections.&lt;/p&gt;
245
-
246
- &lt;p&gt;There was an open issue on the project about renaming the Gem and I knew that
247
- launching the website and releasing 1.0 would be the perfect opportunity, so I
248
- went for it. There was a suggestion to change the name to Feedzilla, but since
249
- that is already a thing, I went with Feedjira. I bought the domain and setup an
250
- organization by that name on GitHub.&lt;/p&gt;
251
-
252
- &lt;p&gt;With those things in place, I needed to actually update the code for these
253
- changes. I wanted to make this transition as easy as possible and devised a
254
- 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;
255
-
256
- &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
257
- page&lt;/a&gt; to help with a couple details. If you have any trouble upgrading,
258
- please let me know by &lt;a href="https://github.com/feedjira/feedjira/issues"&gt;opening an issue&lt;/a&gt;.&lt;/p&gt;
259
-
260
- &lt;p&gt;There are still lots of things I&amp;rsquo;d like to do with this Gem. I mentioned seeing
261
- things that I wanted to completely rewrite, so that&amp;rsquo;ll be something that I work
262
- on for a 2.0 release, but that&amp;rsquo;s a ways off. I&amp;rsquo;d like to officially support
263
- JRuby. Many people use Feedjira with Rails, so a separate project that helps
264
- those users get up and running quickly seems to have value.&lt;/p&gt;
265
-
266
- &lt;p&gt;The list goes on.&lt;/p&gt;
267
-
268
- &lt;p&gt;I do have a request before I finish this thing: I&amp;rsquo;d like to hear from users that
269
- have apps in production using Feedjira. If you&amp;rsquo;re using Feedjira for a
270
- commercial app, please &lt;a href="feedjira@gmail.com"&gt;email me&lt;/a&gt;!&lt;/p&gt;
271
-
272
- &lt;p&gt;Thanks to everyone who has helped me accomplish this, but especially &lt;a href="http://www.pauldix.net"&gt;Paul
273
- 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
274
- badass website design and the many people who opened issues or sent pull
275
- 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;
276
- </content>
277
- </entry>
278
- </feed>
279
- http_version:
280
- recorded_at: Mon, 31 Oct 2016 02:29:13 GMT
281
- recorded_with: VCR 3.0.3
@@ -1,20 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
2
- xmlns:dc="http://purl.org/dc/elements/1.1/">
3
-
4
- <channel>
5
- <title>Invalid date format feed</title>
6
- <link>http://example.com/feed</link>
7
- <language>en-US</language>
8
- <item>
9
- <title>Item 0 with an invalid date</title>
10
- <link>http://example.com/item0</link>
11
- <pubDate>Mon, 16 Oct 2017 15:10:00 +0000</pubDate>
12
- <dc:date>1518478934</dc:date>
13
- </item>
14
- <item>
15
- <title>Item 1 with all valid dates</title>
16
- <link>http://example.com/item1</link>
17
- <pubDate>Tue, 17 Oct 2017 12:17:00 +0000</pubDate>
18
- <dc:date>Tue, 17 Oct 2017 22:17:00 +0000</dc:date>
19
- </item>
20
- </channel>