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
@@ -0,0 +1,156 @@
1
+ {
2
+ "version": "https://jsonfeed.org/version/1",
3
+ "title": "inessential.com",
4
+ "description": "Brent Simmons’s weblog.",
5
+ "home_page_url": "http://inessential.com/",
6
+ "feed_url": "http://inessential.com/feed.json",
7
+ "user_comment": "This feed allows you to read the posts from this site in any feed reader that supports the JSON Feed format. To add this feed to your reader, copy the following URL — http://inessential.com/feed.json — and add it your reader.",
8
+ "favicon": "http://inessential.com/favicon.ico",
9
+ "author": {
10
+ "name": "Brent Simmons",
11
+ "url": "http://inessential.com/",
12
+ "avatar": "http://ranchero.com/downloads/brent_avatar.png"
13
+ },
14
+ "items": [
15
+ {
16
+ "id": "http://inessential.com/2017/06/02/james_dempsey_and_the_breakpoints_benefi",
17
+ "url": "http://inessential.com/2017/06/02/james_dempsey_and_the_breakpoints_benefi",
18
+ "title": "James Dempsey and the Breakpoints Benefit App Camp for Girls",
19
+ "content_html": "<p>On Wednesday night I know where I’ll be — playing keyboard for a few songs at the James Dempsey and the Breakpoints concert benefitting App Camp for Girls.</p>\n\n<p><a href=\"https://www.classy.org/events/-/e126329\">You should get tickets</a>. It’s a fun time for a great cause.</p>\n\n<p>Bonus: James writes about how <a href=\"http://jamesdempsey.net/2017/06/02/wwdc-in-san-jose-full-circle/\">this concert is full circle for him</a>. It’s a special night.</p>",
20
+ "date_published": "2017-06-02T22:05:47-07:00"
21
+ },
22
+ {
23
+ "id": "http://inessential.com/2017/06/01/evergreen_diary_1_open_source",
24
+ "url": "http://inessential.com/2017/06/01/evergreen_diary_1_open_source",
25
+ "title": "Evergreen Diary #1: Open Source",
26
+ "content_html": "<p><a href=\"https://ranchero.com/evergreen/\">Evergreen</a> is a new feed reader for Macs. It’s not actually <em>done</em> yet — in fact, it’s not even alpha yet, much less beta. It’s still in the painful-to-use stage, for sure.</p>\n\n<p>I’ve been working on it (<a href=\"http://inessential.com/frontierdiary\">among other things</a>) on nights and weekends for a couple years. For much of the time I planned to make it a for-pay app — the plan was a free Lite version and a for-pay version.</p>\n\n<p>But as time went on I was less and less motivated to make a for-pay app. Doing all that stuff — dealing with licenses, money, a store, support, and everything else that goes along with a commercial app — just didn’t sound like any fun, and it would have taken time away from actually working on the app, which is all I really want to do. I just don’t have time to spare.</p>\n\n<p>So I decided to make it free and open source. (The <a href=\"https://github.com/brentsimmons/Evergreen\">code is up on GitHub</a>.) This fits with my goals:</p>\n\n<ul>\n<li>Promoting feed-reading as part of promoting the open web.</li>\n<li>Publishing a bunch of feed-reading code and an example Mac app that other developers can use.</li>\n<li>Giving me something to write about on this blog.</li>\n</ul>\n\n\n<p>I like developing in public. Publishing the code makes it feel like a performance, a kind of <a href=\"https://www.youtube.com/watch?v=d2Z9qN8R9Bg\">tightwire act</a>. Which suits me.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>The one thing that almost held me back from making it open source was the effect on other developers. There are for-pay Mac feed readers, after all, and I don’t want to take anything away from them.</p>\n\n<p>And I don’t want to send the message that software ought to cost nothing.</p>\n\n<p>I think that making it open source makes it an obvious special case. There is at least <a href=\"https://github.com/ViennaRSS/vienna-rss\">one other open source Mac feed reader</a>, and there are other open source Mac apps, and I don’t think that these projects are fueling the race to the bottom with app pricing.</p>\n\n<p>I went over and over this decision for months. It wasn’t easy! But in the end I decided it’s a good thing, and there are always good reasons not to do a good thing.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>The app doesn’t have any icons yet. <a href=\"https://twitter.com/BradEllis\">Brad Ellis</a>, who I’ve worked with before on some versions of my previous feed reader, and who is my favorite designer, is working on icons.</p>\n\n<p>Brad is not only my favorite designer, he’s the favorite designer of people who thought they might be my favorite designer. :)</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>At some point it will sync with some existing systems (such as <a href=\"https://feedly.com/\">Feedly</a>, <a href=\"https://feedbin.com/\">FeedBin</a>, and similar) — but probably not till after 1.0, though as top priority.</p>\n\n<p>I have no plans to make an iOS version (though anything could happen). The plan is to make it a great Mac app. Period. But if it syncs with Feedly and so on, then you could use some other reader on iOS and it would sync with Evergreen.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>There is a road not taken here that’s worth exploring, though probably not by me (for reasons of time).</p>\n\n<p>I would love to see a casual feed reader (as opposed to productivity-style) that just provides a timeline, with new stuff at the top. The idea is to make something like a Twitter client but for feeds. You’d get a list of articles, and when you want to read something you’d click (or whatever) to open the article in your browser.</p>\n\n<p>Such an app wouldn’t have per-article read/unread status — instead it would maintain a high-water mark, the date of the newest item you’ve seen in the timeline.</p>\n\n<p>For a little while I was planning to do <em>both</em> styles of reader, since so much of the code would be shared. But that was overly ambitious, so I dropped the idea.</p>\n\n<p>But <em>you</em> could do it.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>I made a Twitter account: <a href=\"https://twitter.com/evergreen_mac\">evergreen_mac</a>. Though I have no fondness for Twitter, it seems like app makers need to be accessible that way. Most Evergreen users will probably be on Twitter.</p>\n\n<p>But you don’t have to use it: you can <a href=\"https://github.com/brentsimmons/Evergreen/issues\">report bugs and make feature requests</a> via GitHub. And that way they’re in the system, which is good.</p>\n\n<p>You can also email me: I’m brent at the domain name that appears in the link that starts the first sentence of this post.</p>",
27
+ "date_published": "2017-06-01T17:27:32-07:00"
28
+ },
29
+ {
30
+ "id": "http://inessential.com/2017/05/26/app_the_human_story_screening_in_san_",
31
+ "url": "http://inessential.com/2017/05/26/app_the_human_story_screening_in_san_",
32
+ "title": "“App: The Human Story” Screening in San Jose",
33
+ "content_html": "<p>Here’s the <a href=\"https://medium.com/altconf/altconf-layers-present-app-the-human-story-3c2b3cb8fc4c\">scoop</a>. It’s Sunday, June 4 at 5 pm. There’s a panel afterward with a bunch of people from the movie (including me).</p>\n\n<p><a href=\"https://www.classy.org/san-jose/events/app-human-story-documentary-screening-presented-by-altconf-layers/e128096\">You can get tickets</a>. You <em>should</em> get tickets — the event benefits <a href=\"http://appcamp4girls.com/\">App Camp for Girls</a>.</p>\n\n<p>Plus I think you’ll enjoy it. :)</p>",
34
+ "date_published": "2017-05-26T12:57:19-07:00"
35
+ },
36
+ {
37
+ "id": "http://inessential.com/2017/05/17/json_feed",
38
+ "url": "http://inessential.com/2017/05/17/json_feed",
39
+ "title": "JSON Feed",
40
+ "content_html": "<p>I was hesitant, even up to this morning, to publish the <a href=\"https://jsonfeed.org/version/1\">JSON Feed spec</a>.</p>\n\n<p>If you read Dave Winer’s <a href=\"http://scripting.com/2017/05/09/rulesForStandardsmakers.html\">Rules for standards-makers</a>, you’ll see that we did a decent job with some of the rules — the spec is written in plain English, for example — but a strict application of the rules would have meant not publishing at all, since “Fewer formats is better.”</p>\n\n<p>I agree completely — but I also believe that developers (particularly Mac and iOS developers, the group I know best) are so loath to work with XML that they won’t even consider building software that needs an XML parser. Which says to me that JSON Feed is needed for the survival of syndication.</p>\n\n<p>I could be wrong, of course. I admit.</p>\n\n<h4>Feed Reader Starter Kit</h4>\n\n<p>See my <a href=\"https://github.com/brentsimmons/RSXML\">RSXML repository</a> for Objective-C code that reads RSS, Atom, and OPML. I’ve done the work for you of supporting those formats. Go write a feed reader! Seriously. Do it.</p>\n\n<p>I planned to have a JSON Feed parser for Swift done for today, but other things got in the way. It’s coming soon. But you probably don’t actually need any sample code, since JSON is so easy to handle.</p>\n\n<h4>Feedback so far</h4>\n\n<p>Feedback has been interesting so far. Some <a href=\"https://github.com/brentsimmons/JSONFeed\">questions</a> on the GitHub repo need answering.</p>\n\n<p>Some people have said this should have happened ten years ago, and other people have said that they hate how developers jump on the latest fad (JSON).</p>\n\n<p>And some people really like the icon:</p>\n\n<p><img src=\"http://jsonfeed.org/graphics/icon.png\" height=70 width=70 /></p>\n\n<h4>Microformats</h4>\n\n<p>One of the more serious criticisms was this: why not just support the <a href=\"http://microformats.org/wiki/hatom\">hAtom microformat</a> instead? Why do another side-file?</p>\n\n<p>My thinking:</p>\n\n<p>My experience as a feed reader author tells me that people screw up XML, badly, all the time — and they do even less well with HTML. So embedding info in HTML is just plain too difficult. In practice it would be even buggier than XML-based feeds.</p>\n\n<p>And there are other advantages to decoupling: a side-file can have 100 entries where there are only 10 on an HTML page, for instance. A side-file can have extra information that you wouldn’t put on an HTML page. And yet, despite the extra information, a side-file can be much smaller than an HTML page, and it can often be easier to cache (since it’s not different based on a logged-in user, for instance).</p>\n\n<p>Microformats sounds elegant, but I don’t prize elegance as much as I value things that work well.</p>",
41
+ "date_published": "2017-05-17T13:22:14-07:00"
42
+ },
43
+ {
44
+ "id": "http://inessential.com/2017/05/01/frontier_diary_8_when_worlds_collide",
45
+ "url": "http://inessential.com/2017/05/01/frontier_diary_8_when_worlds_collide",
46
+ "title": "Frontier Diary #8: When Worlds Collide",
47
+ "content_html": "<p>I spent the weekend making a bunch of progress on the compiler. It has two pieces: a <a href=\"https://github.com/brentsimmons/Frontier/blob/master/UserTalk/UserTalk/Compiler/Tokenizer.swift\">tokenizer</a>, which I created by rewriting the original C code (<a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierOrigFork/Common/source/langscan.c\">langscan.c</a>) in Swift, and a parser.</p>\n\n<p>The parser in OrigFrontier was generated by MacYacc, which is similar to Yacc, which is similar to <a href=\"https://www.gnu.org/software/bison/\">Bison</a>, which is on my Mac. The thing about the parser is that it’s C code, and the rest of the app is Swift.</p>\n\n<p>How do you bridge the two worlds? Easy answer: with Objective-C, which is a superset of C and which plays nicely (enough) with Swift.</p>\n\n<p>So I renamed langparser.y — the rules file that the parser generator uses — to <a href=\"https://github.com/brentsimmons/Frontier/blob/master/UserTalk/UserTalk/Compiler/langparser.ym\">langparser.ym</a> so that Xcode would know to treat the generated parser source as Objective-C. I edited it slightly, not to change the grammar rules but to change how nodes are created (as return values rather than via inout).</p>\n\n<p>I also made my <a href=\"https://github.com/brentsimmons/Frontier/blob/master/UserTalk/UserTalk/CodeTreeNode.swift\">CodeTreeNode</a> class, written in Swift, an Objective-C class so that it would be visible to my Objective-C code.</p>\n\n<p>And then, finally, I started a build…</p>\n\n<p>…and then it stopped with an error because the parser places my <code>CodeTreeNode</code> in a C union, which isn’t allowed in ARC.</p>\n\n<p>Crushed.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>I think I have three options:</p>\n\n<ol>\n<li>Go down the rabbit hole of figuring out how to get the parser to work with ARC.</li>\n<li>Go with the flow: have the parser generate nodes that are, as in OrigFrontier, C structs. The last compilation step would be Objective-C code that translates that tree of C structs into a tree of <code>CodeTreeNode</code> objects, and then disposes the C-struct-node-tree.</li>\n<li>Write the parser by hand, in Swift.</li>\n</ol>\n\n\n<p>My thinking:</p>\n\n<p>I could waste a ton of time on #1, and bending tools in that way can be pretty frustrating work when they refuse to bend.</p>\n\n<p>With #2 I’d feel a bit weird about the redundancy: building a tree and then building a copy of that tree with a different type of object.</p>\n\n<p>My heart tells me #3 is the answer. After all, I’ve already done the tokenizer. How hard would it be to parse those tokens into a code tree? I could skip C and Objective-C altogether and stay in Swift. And it would be <em>so fun</em>. (Because that’s precisely the style of weirdo I am.)</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>But the real answer is #2. Writing a parser by hand would take way longer than I think. Given enough tests, it shouldn’t be a huge source of bugs, but still.</p>\n\n<p>The thing about #2 is that yes, it’s redundant, it’s doing more work than it needs to, ideally — but my bet is that it would still be so fast that you wouldn’t be able to tell the difference. Computers are so good at this kind of thing. It’s not like reading files or networking; it’s just in-memory traversal and creating/releasing things.</p>\n\n<p>You remember in Indiana Jones that guy with the twirling swords, and Indy gives that look and then just shoots him? The second option is the Indiana Jones solution.</p>\n\n<p><i>Update 2:05 pm</i>: Two people have already written me to recommend <a href=\"http://www.antlr.org\">ANTLR</a>. So I will definitely give that a look. It might be exactly what I need.</p>",
48
+ "date_published": "2017-05-01T13:34:23-07:00"
49
+ },
50
+ {
51
+ "id": "http://inessential.com/2017/04/27/frontier_diary_7_pretty_much_everythin",
52
+ "url": "http://inessential.com/2017/04/27/frontier_diary_7_pretty_much_everythin",
53
+ "title": "Frontier Diary #7: Pretty Much Everything Throws",
54
+ "content_html": "<p>A script can throw an error, either intentionally (via the <code>scriptError</code> verb) or by doing something, such as referencing an undefined object, that generates an error.</p>\n\n<p>OrigFrontier was written in C, which has no error-throwing mechanism, and so it worked like this: most runtime functions returned a boolean (for success or failure), and the return value was passed in by reference. If there was an error, the function would set a global error variable and return false. The caller would then have to check that global to see if there was an error, and then do the right thing.</p>\n\n<p>This was not unreasonable, given the language and the times (early ’90s) and also given the need to be very careful about unwinding memory allocations.</p>\n\n<p>But, these days, it seems to me that Swift’s error system is the way to go. There’s just one downside to that, and it’s that I have to do that do/try/catch dance all over the place, since pretty much any runtime function can throw an error.</p>\n\n<p>Even the coercions can throw, so last night I changed the <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierData/FrontierData/Value/ValueProtocol.swift\">Value</a> protocol so that <code>asInt</code> and so on are now functions, since properties can’t throw (at least not yet).</p>\n\n<p>The extra housekeeping — the do/try/catch stuff — kind of bugs me, but it’s honest. I considered making script errors just another type of Value — but that meant that all those callers have to check the returned Value to see if it’s an error, and then do the right thing. Better to just use Swift’s error system, because it makes for more consistent code, and it makes sure I’m catching errors in every case.</p>\n\n<p>It also means I’m not multiplying entities. A Swift error is a script error, and vice versa.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>Working on this code is like applying the last 25 years of programming history all at once.</p>\n\n<p>A completely different type of error is a <em>bug</em>, and I’m certain to write a bunch of them, because that’s how programming goes.</p>\n\n<p>That’s where unit tests come in. Frontier has long had a stress-test suite of scripts — you’d launch the app, run that suite, wait a while, and see if there are any errors. This was critically helpful.</p>\n\n<p>But OrigFontier didn’t have unit tests at the C code level. The new version does. (Well, <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierVerbs/FrontierVerbsTests/Math.swift\">I’ve started them anyway</a>.) This means I can more easily follow <a href=\"http://scripting.com/2002/09/29.html#rule1\">Rule 1</a> — the no-breakage rule — and can also more easily follow Rule 1b — the don’t-break-Dave rule.</p>\n\n<p>PS I’ve added a <a href=\"http://inessential.com/frontierdiary\">collection page for the Frontier Diary</a>, as I did with earlier diaries. There’s a link to it in the footer of every page on the blog.</p>",
55
+ "date_published": "2017-04-27T13:30:42-07:00"
56
+ },
57
+ {
58
+ "id": "http://inessential.com/2017/04/26/frontier_diary_6_ballard_from_the_par",
59
+ "url": "http://inessential.com/2017/04/26/frontier_diary_6_ballard_from_the_par",
60
+ "title": "Frontier Diary #6: Ballard, from the Parallel Universe",
61
+ "content_html": "<p>In another universe I didn’t decide to port Frontier — instead, I started over from scratch on an app <em>inspired</em> by Frontier.</p>\n\n<p>In that universe, the new scripting language, descended from UserTalk, is called Ballard. <a href=\"http://inessential.com/ballard_lang\">And it’s documented</a>.</p>",
62
+ "date_published": "2017-04-26T13:04:04-07:00"
63
+ },
64
+ {
65
+ "id": "http://inessential.com/2017/04/25/my_microblog",
66
+ "url": "http://inessential.com/2017/04/25/my_microblog",
67
+ "title": "My Microblog",
68
+ "content_html": "<p>I’m on Manton‘s cool new microblogs system. Here’s where you can follow me, once you’re on the system: <a href=\"http://micro.blog/brentsimmons\">http://micro.blog/brentsimmons</a>.</p>\n\n<p>And here’s my microblog: <a href=\"http://brent.micro.blog/\">http://brent.micro.blog/</a>. (Which you can read using RSS, whether you’re on the system or not.)</p>\n\n<p>I wrote about three-quarters of my own single-user microblog system — and then stopped because I didn’t feel like running a server and because Manton’s service is so good.</p>",
69
+ "date_published": "2017-04-25T14:27:28-07:00"
70
+ },
71
+ {
72
+ "id": "http://inessential.com/2017/04/25/frontier_diary_5_values_and_progress_o",
73
+ "url": "http://inessential.com/2017/04/25/frontier_diary_5_values_and_progress_o",
74
+ "title": "Frontier Diary #5: Values and Progress on the Language",
75
+ "content_html": "<p>I put the <a href=\"https://github.com/brentsimmons/Frontier\">Frontier repository</a> up on GitHub.</p>\n\n<p>(The build is currently broken. This is bad discipline, but since it’s still just me, I forgive myself. Sometimes I run out of time and I just commit what I have.)</p>\n\n<p>The repo has my new code and it also contains <a href=\"https://github.com/brentsimmons/Frontier/tree/master/FrontierOrigFork\">FrontierOrigFork</a>, which is the original Frontier source with a bunch of deletions and some changes. The point is to give me 1) code to read and 2) a project that builds and runs on <a href=\"http://inessential.com/2017/04/03/frontier_diary_1_vm_life\">my 10.6.8 virtual machine</a>.</p>\n\n<p>The original code is in C, and the port is, at least so far, all in Swift. In the end it should be <em>almost</em> all in Swift, but I anticipate a couple places where I may need to use Objective-C.</p>\n\n<p>Here’s one of the Swift wins:</p>\n\n<h4>Values</h4>\n\n<p>Since Frontier contains a database and scripting language, there’s a need for some kind of value object that could be a boolean, integer, string, date, and so on.</p>\n\n<p>Original Frontier used a <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierOrigFork/Common/headers/lang.h\">tyvaluedata</a> union, with fields for the various types of values.</p>\n\n<p>This is a perfectly reasonably approach in C. It’s great because you can pass the same type of value object everywhere.</p>\n\n<p>Were I writing this in Objective-C, however, I’d create a <code>Value</code> protocol, and then create new value objects for some types and also extend existing objects (<code>NSNumber</code>, <code>NSString</code>, etc.) to conform to the <code>Value</code> protocol. This would still give me the upside — passing a <code>Value</code> type everywhere — while reducing the amount of boxing.</p>\n\n<p>But: this still means I have an <code>NSNumber</code> when I really want a BOOL. Luckily, in Swift I can go one better: I can extend types such as <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierData/FrontierData/Value/ValueBool.swift\">Bool</a> and <code>Int</code> to conform to a <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierData/FrontierData/Value/ValueProtocol.swift\">Value</a> protocol.</p>\n\n<p>This means passing around an <em>actual</em> <code>Bool</code> rather than a boxed boolean. I like this a ton. It feels totally right.</p>\n\n<p>Other topic:</p>\n\n<h4>Language Progress</h4>\n\n<p>I’m still in architectural mode, where I’m writing just enough code to validate and refine my decisions. A couple days ago I started on the <a href=\"https://github.com/brentsimmons/Frontier/blob/master/UserTalk/UserTalk/LangEvaluator.swift\">language evaluator</a> — the thing that actually runs scripts.</p>\n\n<p>It works as you expect: it takes a compiled code tree and recursively evaluates it. It’s not difficult — it’s just that it’s going to end up being a fair amount of code.</p>\n\n<p>I’ve done just enough to know that I’m on the right path. (The Swift code looks a lot like the C code in OrigFrontier’s <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierOrigFork/Common/source/langevaluate.c\">langevaluate.c</a>. See <code>evaluateList</code>, for instance.)</p>\n\n<p>The next step is for me to build the parser. I thought about writing a parser by hand, because it sounds like fun, and it would give me some extra control — but, really, it would slow me way down, so forget it.</p>\n\n<p>OrigFrontier generated its parser by passing a grammar file — <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierOrigFork/Common/source/langparser.y\">langparser.y</a> — to MacYacc (there was such a thing!), which generated <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierOrigFork/Common/source/langparser.c\">langparser.c</a>.</p>\n\n<p>I’ll do a similar thing, except using <a href=\"https://www.gnu.org/software/bison/\">Bison</a> (which is compatible with Yacc). Or, possibly, using the <a href=\"http://www.hwaci.com/sw/lemon/\">Lemon parser generator</a> instead. Either way, I’ll want the generated code to be Objective-C. (Well, mostly C, but with Objective-C objects instead of structs.) (I don’t know of a generator that would create Swift code.)</p>\n\n<p>This is completely new territory for me, and is exciting.</p>\n\n<p>(Almost forgot to mention: I’ll need to write a tokenizer. This means porting <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierOrigFork/Common/source/langscan.c\">langscan.c</a>. I’ll need to do this first, since the parser generator needs it. So this is the real next step.)</p>",
76
+ "date_published": "2017-04-25T13:26:33-07:00"
77
+ },
78
+ {
79
+ "id": "http://inessential.com/2017/04/14/save_300_on_coccoaconf_next_door",
80
+ "url": "http://inessential.com/2017/04/14/save_300_on_coccoaconf_next_door",
81
+ "title": "Save $300 on CocoaConf Next Door",
82
+ "content_html": "<p>My pals at CocoaConf asked me to remind you that the <a href=\"https://twitter.com/cocoaconf/status/852898192035282944\">Early Bird sale ends in two weeks</a> for CocoaConf Next Door — the one taking place in San Jose during WWDC.</p>\n\n<p>I’ll be there. At least in the afternoons.</p>\n\n<p>Check out the <a href=\"http://cocoaconf.com/nextdoor/speakers\">speakers list</a>. Yummy, chewy, nutty speakers list.</p>",
83
+ "date_published": "2017-04-14T13:53:02-07:00"
84
+ },
85
+ {
86
+ "id": "http://inessential.com/2017/04/14/frontier_diary_4_the_quickdraw_problem",
87
+ "url": "http://inessential.com/2017/04/14/frontier_diary_4_the_quickdraw_problem",
88
+ "title": "Frontier Diary #4: The QuickDraw Problem and Where It Led Me",
89
+ "content_html": "<p>In my fork of Frontier there are still over 600 deprecation warnings. A whole bunch of these are due to <a href=\"https://en.wikipedia.org/wiki/QuickDraw\">QuickDraw</a> calls.</p>\n\n<p>For those who don’t know: QuickDraw was how, in the old days, you drew things to the Mac’s screen. It was amazing for its time and pretty easy to work with. Functions included things like <code>MoveTo</code>, <code>LineTo</code>, <code>DrawLine</code>, <code>FrameOval</code>, and so on. All pretty straightforward.</p>\n\n<p>These days we have Core Graphics instead, and we have higher-level things like <code>NSBezierPath</code>. QuickDraw was simpler — though yes, sure, that was partly because it did less.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>I was looking at all these deprecation warnings for QuickDraw functions and wondering how I’m ever going to get through them.</p>\n\n<p>I could, after all, convert all or most of them to the equivalent Core Graphics thing. But sheesh, what a bunch of work.</p>\n\n<p>And, in the end, it would still be a Carbon app, but with modern drawing.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>So I thought about it from another angle. The goal is to get to the point where it’s a 64-bit Cocoa app. All these QuickDraw calls are in the service of UI — so why not just start over with a Cocoa UI?</p>\n\n<p>The app has some outlines (database browser, script editor, etc.), a basic text editor, and a handful of small dialogs. <em>And all of that is super-easy in Cocoa.</em></p>\n\n<p>Use an <code>NSOutlineView</code>, <code>NSTextView</code>, and some xibs for the dialogs, and we’re done. (Well, after <em>some</em> work, but not nearly the same amount of work as actually writing an outliner from scratch.)</p>\n\n<p>In other words, instead of going from the bottom up — porting the existing source code — I decided to start from the top down.</p>\n\n<p>I started a new workspace and started a new Frontier project: a Cocoa app with Swift as the default language.</p>\n\n<p>Then I looked at the existing source and thought about how to organize things. I came up with this:</p>\n\n<ul>\n<li>Frontier — App UI</li>\n<li>UserTalk.framework — the language</li>\n<li>FrontierVerbs.framework - the standard library</li>\n<li>FrontierDB.framework — the object database</li>\n<li>FrontierCore.framework — common utility functions and extensions</li>\n</ul>\n\n\n<p>I like using frameworks, because it helps enforce separation, and it helps in doing unit testing. And frameworks are so easy with Swift these days.</p>\n\n<p>Hardly any of this is filled-in yet. I’ve got the barest start on FrontierVerbs. <a href=\"https://twitter.com/tedchoward\">Ted Howard</a>, my partner in all this, is taking UserTalk.framework and FrontierDB.framework.</p>\n\n<p>In the end, it’s possible that no code from the original code base survives. Which is totally fine. But it also means that this is no quick project.</p>\n\n<p>At this point I should probably put it up on GitHub, since it’s easier to write about it if I can link to the code. I’ll do that soon, possibly on the weekend.</p>",
90
+ "date_published": "2017-04-14T13:14:20-07:00"
91
+ },
92
+ {
93
+ "id": "http://inessential.com/2017/04/13/frontier_diary_3_built-in_verbs_config",
94
+ "url": "http://inessential.com/2017/04/13/frontier_diary_3_built-in_verbs_config",
95
+ "title": "Frontier Diary #3: Built-in Verbs Configuration",
96
+ "content_html": "<p>Frontier’s standard library is known as its built-in verbs. There are a number of different tables: <code>file</code>, <code>clock</code>, <code>xml</code>, and so on. Each contains a number of verbs: <code>file.readWholeFile</code>, <code>clock.now</code>, and so on.</p>\n\n<p>Most of these verbs are implemented in C, in the kernel, rather than as scripts. At the moment, to add one of these kernel verbs, you have to jump through a few hoops: edit a resource, add an integer ID, add to a switch statement, etc. It’s a pain and is error-prone.</p>\n\n<p>So I want to re-do this in Swift, because I’m all about Swift. And I want adding verbs to be fool-proof: I don’t want to remember how to configure this every single time I add a verb. Adding a verb needs to be <em>easy</em>.</p>\n\n<p>My thinking:</p>\n\n<ul>\n<li>Give each table its own class: ClockVerbs, FileVerbs, etc.</li>\n<li>Have each class report the names of the verbs it supports. These need to be strings, because we get a string at runtime.</li>\n<li>Run a verb simply by looking up the selector, performing it, and returning the result.</li>\n</ul>\n\n\n<p>To make things easy and obvious, I think it should work like this: the selector for a given verb is its name plus a parameter. Then there’s not even a lookup step.</p>\n\n<p>Each verb will take a VerbParameters object and return a VerbResult object.</p>\n\n<pre><code>dynamic func readWholeFile(_ params: VerbParameters) -&gt; VerbResult\n</code></pre>\n\n<p>The flow goes like this:</p>\n\n<ol>\n<li>We have the string <code>file.readWholeFile</code>.</li>\n<li>We see the <code>file</code> suffix and so we know we need a <code>FileVerbs</code> object.</li>\n<li>We check <code>fileVerbs.supportedVerbs</code> (an array) to see if <code>readWholeFile</code> is in the list. It is.</li>\n<li>We construct a selector using the <code>readWholeFile</code> part of the string and we add a <code>:</code> character: <code>NSSelectorFromString(verbName + \":\")</code></li>\n</ol>\n\n\n<p>This is great! We’re almost home free. Then we run the verb:</p>\n\n<pre><code>if let result = perform(selector, with: params) as? VerbResult {\n return result\n}\n</code></pre>\n\n<p>That doesn’t work. We get:</p>\n\n<pre><code>Cast from 'Unmanaged&lt;AnyObject&gt;! to unrelated type 'VerbResult' always fails\n</code></pre>\n\n<p>Nuts.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p>It was <em>so</em> close.</p>\n\n<p>In Objective-C this would have worked. And obviously, apparently, I still think in Objective-C.</p>\n\n<p>I investigated some other options. At one point enums were abused, because there’s <em>always</em>, in Swift, an enum-abuse step. But everything I tried was more code and was more error-prone, and my goal here is to improve the situation.</p>\n\n<p>I think, in the end, I’m going to do something that looks kind of ugly: a switch statement where the cases are string literals.</p>\n\n<pre><code>switch(verbName) {\ncase \"readWholeFile\":\n return readWholeFile(params)\n…\n}\n</code></pre>\n\n<p>“Nooooo!” you cry. I hear ya.</p>\n\n<p>My experience as an object-oriented programmer tells me this: if I write a <code>switch</code> statement, I blew it.</p>\n\n<p>And my experience as a programmer tells me that string literals are a bad idea.</p>\n\n<p>But the above may actually be the easiest to configure and maintain. Each string literal appears only in that one switch statement and nowhere else in the code. And the mapping between a verb name and its function couldn’t be more clear — it’s right there.</p>\n\n<p>(Yes, instead of using a string literal, I could create a String enum and switch on that. But that’s actually more code and more room for error. I’m going to have to type those string literals <em>somewhere</em>, so why not right where they’re used?)</p>\n\n<p>It does mean that <code>readWholeFile</code> appears three times in the code (the string literal, the call, and the function itself), and in an Objective-C version it would appear only twice (in a <code>supportedVerbs</code> array and the method itself).</p>\n\n<p>But. Well.</p>\n\n<p>I’m torn between shuddering in abject and complete horror at this solution and thinking, “Hey, that’s pretty straightforward. Anybody could read it. Anybody could edit it.” Which was the plan all along.</p>\n\n<p>And I get to stick with Swift, so there’s that.</p>\n\n<p>But, sure as shootin’, some day someone’s going to come across this code and say, “Brent, dude, are ya <em>new</em>?” And I’ll send them the link to this page.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p><i>Update the next day:</i> well, the <code>performSelector</code> thing <em>would</em> work, if only I’d known about Swift Unmanaged objects.</p>\n\n<p><a href=\"https://twitter.com/jckarter\">Joe Groff</a> told me how this works.</p>\n\n<p>Here’s the gist: the <code>Unmanaged&lt;AnyObject&gt;</code> just needs to be unwrapped by calling <code>takeRetainedValue</code> or <code>takeUnretainedValue</code>. Once unwrapped, it can be cast to <code>VerbResult</code>.</p>\n\n<p>All this means that I can use my original design, which is great news.</p>\n\n<p style=\"text-align:center\">* * *</p>\n\n\n<p><i>Update April 25, 2017:</i> I ended up using enums after all. See <a href=\"https://github.com/brentsimmons/Frontier/blob/master/FrontierVerbs/FrontierVerbs/VerbTables/MathVerbs.swift\">MathVerbs.swift</a> for an example.</p>",
97
+ "date_published": "2017-04-13T22:25:41-07:00"
98
+ },
99
+ {
100
+ "id": "http://inessential.com/2017/04/11/frontier_diary_2_two_good_ideas_that_a",
101
+ "url": "http://inessential.com/2017/04/11/frontier_diary_2_two_good_ideas_that_a",
102
+ "title": "Frontier Diary #2: Two Good Ideas that Aren’t Good Anymore",
103
+ "content_html": "<p>Strings in <a href=\"http://inessential.com/2017/04/03/frontier_diary_1_vm_life\">Frontier</a> are usually either Pascal strings or Handles.</p>\n\n<p>You probably don’t know what I’m talking about. I’ll explain.</p>\n\n<h4>Pascal Strings</h4>\n\n<p>Frontier is a Mac Toolbox app that’s been Carbonized just enough to run on OS X. You may recall that the Mac Toolbox was written so long ago that the <a href=\"https://developer.apple.com/legacy/library/documentation/mac/pdf/MacintoshToolboxEssentials.pdf\">original API</a> was in Pascal. That Pascal heritage lived on in many ways, even after everyone switched to C — and one of those ways was Pascal strings.</p>\n\n<p>A Pascal string is n bytes long, and the first byte specifies the length of the string, which leaves the rest of the bytes for the actual string. <code>Str255</code> was probably most common, and certainly is most common in Frontier, but there are also smaller sizes: <code>Str63</code> and <code>Str31</code>, for instance.</p>\n\n<p>Unlike C strings, they’re not zero-terminated, since there’s no need to calculate the length: you always know it from that first byte.</p>\n\n<p>You create a literal Pascal string like this…</p>\n\n<pre><code>Str255 s = \"\\pThis is a string\";\n</code></pre>\n\n<p>…and the compiler turns the <code>\\p</code> into the correct length (16 in this case).</p>\n\n<p>Now, I bet you’re saying to yourself, “Self, those Pascal strings are too small to be useful.”</p>\n\n<p>But consider this: every menu item name can fit into a Pascal string. You can fit a window title or a file name into a Pascal string (in fact, memory suggests that file names were even shorter, were <code>Str31</code> Pascal strings). Any label or message on any bit of UI is probably short enough to fit into a Pascal string. (Especially if you assume English.)</p>\n\n<p>So for GUI apps these were terrifically useful, and the 255-byte limit was no problem. (You can fit a tweet in a Pascal string, after all, with a bunch of room left over. [Well, depending on the size of the characters.])</p>\n\n<p>Frontier still uses them internally a ton. (For some reason, in the Frontier code, <code>Str255</code> strings are called <code>bigstring</code>, which sounds ironic, since they’re so small, but I think it was to differentiate them from even smaller Pascal strings such as <code>Str31</code>.)</p>\n\n<p>You might ask what the text encoding was for these strings.</p>\n\n<p>“Text whatzit?” I’d reply. “Oh, I see. Just regular.” (<a href=\"https://en.wikipedia.org/wiki/Mac_OS_Roman\">MacRoman</a>.)</p>\n\n<p>It was a good idea, but its time has come and gone. We have better strings these days.</p>\n\n<h4>Handles</h4>\n\n<p>Frontier includes a scripting language and a database, which means it certainly has a need for strings much larger than 255 bytes.</p>\n\n<p>It also needs heap storage for other things — binary data, structs, etc. — that could be much larger than 255 bytes.</p>\n\n<p>Enter the Handle. A Handle points to a pointer <em>that might move</em>: the memory you access via a Handle is <em>relocatable</em>.</p>\n\n<p>Which sounds awful, I know, but it was a smart optimization in the days when your Mac’s memory would be a single-digit number of megabytes, or even less than that.</p>\n\n<p>Here’s the problem: your application’s heap space can become fragmented. It could have a whole bunch of gaps in it after a while. So, to regain that memory, the system could compact the heap — it would remove those gaps, which means relocating the memory pointed to via a Handle.</p>\n\n<p>This is better than running out of memory, obviously. But it means that you have to be careful when dereferencing a Handle: you have to actually lock it first — <code>HLock(h)</code> — so that it can’t be moved while you’re using it. (And then you unlock it — <code>HUnlock(h)</code> — when finished.)</p>\n\n<p>Handles are also resizable — <code>SetHandleSize(h, size)</code> — and resizing a Handle can result in it needing to move, if there’s not enough space where it is. Or other Handles might move. You don’t ever know, and don’t care, and you think this is elegant because the system handles it all for you.</p>\n\n<p>All you have to deal with is an additional level of indirection (<code>**h</code> instead of <code>*p</code>), locking and unlocking it when needed, and disposing of it — <code>DisposeHandle(h)</code> — when finished. (No, there’s no reference counting, slacker.)</p>\n\n<p>Nowadays, on OS X, Handles don’t ever move and there’s no heap compaction. So there’s no reason for them whatsoever. And they are, as expected, deprecated.</p>\n\n<p>Nevertheless, Frontier, a Mac Toolbox app written in C, uses Handles everywhere.</p>\n\n<p>(I remember being shocked, when I first started learning Cocoa 15 years ago, that there were no Handles. It seemed <em>incredibly</em> daring that objects were just pointers. It made me nervous!)</p>\n\n<h4>The Size of the Job</h4>\n\n<p>Almost all the Mac APIs that Frontier uses are deprecated. That’s one thing.</p>\n\n<p>But it’s worse than just that: the ways Frontier handles strings and <em>pretty much every single thing it stores on the heap</em> are also deprecated.</p>\n\n<p>So: what to do?</p>\n\n<p>The end goal is a Cocoa app, which means I’ll be able to use Foundation, CoreFoundation, and Swift data types: NSString and Swift String, for instance. There are a number of different structs in the code, and those will be turned into Objective-C and Swift objects and Swift structs.</p>\n\n<p>The tricky part, though, is getting from here to there. I think the first step is to start with Objective-C and Foundation types and use them where possible. I can do that without actually turning it into a Cocoa app (the app will still have its own WaitNextEvent event loop and Carbon windows) — which means I’ll have to bracket all Objective-C code in autorelease pools, and I’ll have to use manual retains and releases. I’m not sure how far that will get me, but it will get me closer.</p>\n\n<p>PS Here are a couple articles by Gwynne Raskind on the Mac Toolbox you might enjoy: <a href=\"https://mikeash.com/pyblog/friday-qa-2012-01-13-the-mac-toolbox.html\">Friday Q&amp;A 2012-01-13: The Mac Toolbox</a> and <a href=\"https://mikeash.com/pyblog/the-mac-toolbox-followup.html\">The Mac Toolbox: Followup</a>.</p>",
104
+ "date_published": "2017-04-11T13:01:55-07:00"
105
+ },
106
+ {
107
+ "id": "http://inessential.com/2017/04/05/two_little-known_and_completely_unrelate",
108
+ "url": "http://inessential.com/2017/04/05/two_little-known_and_completely_unrelate",
109
+ "title": "Two Little-Known and Completely Unrelated Facts",
110
+ "content_html": "<p>One. <a href=\"https://www.omnigroup.com/omnioutliner\">OmniOutliner</a>’s outline view is implemented as CALayers rather than as a view with subviews. (I don’t think I’m giving away a trade secret here.)</p>\n\n<p>Two. If you eat fenugreek, your <a href=\"https://www.theatlantic.com/health/archive/2010/06/the-mystery-of-the-maple-syrup-smell/57980/\">armpits will smell like maple syrup</a>.</p>",
111
+ "date_published": "2017-04-05T16:57:59-07:00"
112
+ },
113
+ {
114
+ "id": "http://inessential.com/2017/04/05/ios_javascript_and_object_hierarchies",
115
+ "url": "http://inessential.com/2017/04/05/ios_javascript_and_object_hierarchies",
116
+ "title": "iOS, JavaScript, and Object Hierarchies",
117
+ "content_html": "<p><a href=\"http://iam.fahrni.me/2017/03/25/scripting-ios/\">Rob Fahrni</a>:</p>\n\n<blockquote><p>Given x-callback-url and App URL schemes in general it would be extremely cool to use those to create object hierarchies using JavaScript. Why JavaScript? Well, it’s native to iOS and applications can use the runtime.</p></blockquote>",
118
+ "date_published": "2017-04-05T14:53:01-07:00"
119
+ },
120
+ {
121
+ "id": "http://inessential.com/2017/04/05/cocoaconf_near_wwdc",
122
+ "url": "http://inessential.com/2017/04/05/cocoaconf_near_wwdc",
123
+ "title": "CocoaConf Near WWDC",
124
+ "content_html": "<p>There are a bunch of things happening near WWDC this year. Me, I’ll be at <a href=\"http://cocoaconf.com/blog/nextdoor\">CocoaConf Next Door</a>. I’m not preparing a talk, but I’ll probably be on a panel. And hanging out.</p>\n\n<p>Check out the <a href=\"http://cocoaconf.com/nextdoor/speakers\">speakers list</a>, which includes Omni’s own <a href=\"http://cocoaconf.com/nextdoor/speakers/162\">Liz Marley</a>. And a bunch of other people you totally want to see — Manton Reece, Jean MacDonald, Laura Savino, and plenty more.</p>\n\n<p>Also… <a href=\"http://altconf.com/\">AltConf</a> and <a href=\"https://layers.is/\">Layers</a> will be near WWDC. If you could be in three places at once, you would. Well, four, including WWDC itself, I suppose. :)</p>",
125
+ "date_published": "2017-04-05T14:35:05-07:00"
126
+ },
127
+ {
128
+ "id": "http://inessential.com/2017/04/05/omnioutliner_5_0_for_mac",
129
+ "url": "http://inessential.com/2017/04/05/omnioutliner_5_0_for_mac",
130
+ "title": "OmniOutliner 5.0 for Mac",
131
+ "content_html": "<p>I’ve been on the OmniOutliner team for over a year now. Though we don’t have positions like junior and senior developer, I enjoy calling myself the junior developer on the Outliner team, since I’m newest.</p>\n\n<p>I may be a new developer, but I’m not a new user — I’ve been using the app since the days when OmniOutliner 3 came installed on every Mac.</p>\n\n<p>Every time I start a talk, I outline it first. I organize the work I need to do in my side-project apps in OmniOutliner. And — don’t tell the OmniFocus guys, who are literally right here — sometimes I even use it for to-do management in general. I’d be lost without a great outliner.</p>\n\n<p>Anyway… <a href=\"https://www.omnigroup.com/blog/omnioutliner-5-is-now-available\">there’s a new version: OmniOutliner 5.0</a>. It’s my first dot-oh release at Omni, and I’m proud of it and proud of the team.</p>\n\n<p>As is common with our apps, we have two levels: a regular level and a Pro level. The regular level is called “Essentials” and is just $9.99. There’s a demo so you can try it out first.</p>\n\n<p>It syncs with iOS and with other Macs, by the way. Sync is free. And of course it comes with extensive documentation, and Omni’s awesome support humans are standing by.</p>\n\n<p><a href=\"https://www.omnigroup.com/omnioutliner/\">Get it while it’s hot</a>!</p>",
132
+ "date_published": "2017-04-05T10:44:45-07:00"
133
+ },
134
+ {
135
+ "id": "http://inessential.com/2017/04/03/frontier_diary_1_vm_life",
136
+ "url": "http://inessential.com/2017/04/03/frontier_diary_1_vm_life",
137
+ "title": "Frontier Diary #1: VM Life",
138
+ "content_html": "<p>It’s been years since I could build the <a href=\"http://frontierkernel.org\">Frontier kernel</a> — but I finally got it building.</p>\n\n<p>It’s really a ’90s Mac app that’s been Carbonized just enough to run on MacOS, but it’s by no means modern: it uses QuickDraw and early Carbon APIs. It’s written entirely in C.</p>\n\n<p>I got it building by installing MacOS 10.6.8 Server in VMWare. Installed Xcode 3.2.6. And now, finally, I can build and run it.</p>\n\n<h4>What is Frontier?</h4>\n\n<p>Frontier — as some of you know — was a UserLand Software product in the ’90s and 2000s. I worked there for about six years.</p>\n\n<p>The app is a development environment and runtime: a persistent, hierarchical database with a scripting language and a GUI for browsing and editing the database and for writing, debugging, and running scripts.</p>\n\n<p>The <a href=\"http://scripting.com/frontier/snippets/nerdsguide.html\">Nerd’s Guide to Frontier</a> gives some idea of what it’s like, though it was written before many of the later advances.</p>\n\n<p>Maybe you’ve never heard of it. But here’s the thing: it was in Frontier that the following were either invented or popularized and fleshed-out: scripted and templated websites, weblogs, hosted weblogs, web services over http, RSS, RSS readers, and OPML. (And things I’m forgetting.)</p>\n\n<p>Those innovations were due to the person — <a href=\"http://scripting.com/\">Dave Winer</a> — and to the times, the relatively early web days. But they were also in part due to the tool: Frontier was a fantastic tool for implementing and iterating quickly.</p>\n\n<h4>The Goal</h4>\n\n<p>The high-level goal is to make that tool available again, because I think we need it.</p>\n\n<p>The plan is to turn it into a modern Mac app, a 64-bit Cocoa app, and then add new features that make sense these days. (There are so many!) But that first step is a big one.</p>\n\n<p>The first part of the first step is simple, and it’s where I am now: mass deletions of code. Every reference to THINK_C and MPWC has to go. All references to the 68K and PPC versions must go. There was a Windows port, and all that code is getting tossed. And then I’ll see the scale of what needs to be done.</p>\n\n<p>(Note: my repo is a fork, and it’s not even on the web yet. The code I’m deleting is never really gone.)</p>\n\n<p>I’m doing a blog diary on it because it helps keep me focused. Otherwise I’m jumping around on my side projects. But if I have to write about it, then I’ll stay on target.</p>",
139
+ "date_published": "2017-04-03T13:44:34-07:00"
140
+ },
141
+ {
142
+ "id": "http://inessential.com/2017/03/31/the_goal",
143
+ "url": "http://inessential.com/2017/03/31/the_goal",
144
+ "title": "The Goal",
145
+ "content_html": "<p>The goal isn’t specifically impeachment and conviction. It’s for Trump to leave office.</p>\n\n<p>The stretch goal is that he dies broke and in prison.</p>\n\n<p>But we could settle for him going down in history as our worst President, as the worst person ever to become President, with the name Trump held in less esteem than that of Benedict Arnold, with Trumpism — that pseudo-populist white nationalism for the benefit of the super-rich — thoroughly loathed and seen for the brutish scam that it is.</p>\n\n<p>I think there comes a point before an actual trial in the Senate where Republican leaders — in Congress, in the Cabinet, wherever — realize that Trump can no longer govern, and they tell him so and urge him to resign.</p>\n\n<p>And I think he actually does resign at that point. He’s been through bankruptcy, and he’s shown that when there’s no path to winning, he’ll take the easiest route out of the situation, the route that leaves him the most status. He doesn’t have the stick-to-it-iveness to go to trial in the Senate: he’d quit.</p>\n\n<p>I don’t know what it will take to bring Republican leaders to this point. Their ongoing cowardice is the real scandal — when faced with a threat to our democracy, they play along because they’re hoping for some goodies.</p>\n\n<p>I don’t think they get to this point unless the public gets to this point, and so I look to the approval polls. If it gets below 30%, it’s probably there because of further revelations in the Russia affair, and it’s probably at the point where even cowards feel safe in doing the right thing — even if only to save their own necks, which will need saving.</p>\n\n<p>But right now Speaker Ryan won’t even replace Devin Nunes as chair of the house intelligence committee. So there’s still a long way to go.</p>",
146
+ "date_published": "2017-03-31T13:47:44-07:00"
147
+ },
148
+ {
149
+ "id": "http://inessential.com/2017/03/25/my_cocoaconf_yosemite_2017_talk",
150
+ "url": "http://inessential.com/2017/03/25/my_cocoaconf_yosemite_2017_talk",
151
+ "title": "My CocoaConf Yosemite 2017 Talk",
152
+ "content_html": "<p><a href=\"http://cocoaconf.com/yosemite\">Yosemite 2017</a> was so great. It always is.</p>\n\n<p>Below is the rough draft of my first-night talk. A few notes…</p>\n\n<p>The actual spoken version is probably not even close to the text, which was written before any rehearsal, and of course it’s never my intent to memorize it exactly.</p>\n\n<p>The bit with Laura Savino was a quick three-chord rock medley. We both played acoustic guitar and sang. It went like this:</p>\n\n<p>B: Louie Louie, oh baby, we gotta go<br />\nL: Yeah yeah yeah yeah yeah<br />\nB: Louie Louie, oh baby, we gotta go<br />\nL: Yeah yeah yeah yeah yeah<br />\nB: I live on an apartment on the 99th floor of my block<br />\nL: Hang on Sloopy, Sloopy hang on<br />\nB: I look out my window imagining the world has stopped</br />\nL: Hang on Sloopy, Sloopy hang on<br />\n[Slight change of chords]<br />\nB &amp; L: Teenage wasteland, oh yeah, only teenage wasteland [repeated]</p>\n\n<p>Here’s my <a href=\"https://www.youtube.com/watch?v=RzBz7p0A3-Y\">favorite video for Brimful of Asha</a>.</p>\n\n<p>During the Squirrel Picture interlude (slide #3) I told the <a href=\"http://inessential.com/2001/06/07/2001_06_07\">Squirrel Story</a>, which wasn’t planned or recently rehearsed, but I’ve told it often enough that it didn’t really need rehearsal.</p>\n\n<p>I dedicated the performance of Hallelujah to <a href=\"https://twitter.com/dori\">Dori Smith</a>.</p>\n\n<p>The talk was meant to be about 20 minutes long. Afterward I went around the room with a microphone and each person introduced themselves. (The talk’s job is to be a first-night ice-breaker talk.)</p>\n\n<p>I spent about 10 hours on rehearsal for those 20 minutes.</p>\n\n<p>Here’s the talk:</p>\n\n<h4>Slide #1: Three Chord Rock</h4>\n\n<p>Hi. I’m Brent.</p>\n\n<p>Before I get started — seeing my friend Brad Ellis reminded me of the most rock-n-roll moment of my life. Where’s Brad? Hi Brad. Anyway — I was at a party at my friend Chris’s house, and he let me borrow his guitar and do a sing-along. I think we did White Rabbit and Me and Bobby McGee and Hotel California.</p>\n\n<p>Well, here’s the problem — I have a hard time hanging on to a guitar pick. Especially after a few beers. So at one point the pick goes flying, and I’m strumming with my fingers.</p>\n\n<p>But I had a hangnail, and it got a bit aggravated as I was strumming. At the end I noticed that there was my actual blood on the guitar. I felt bad about it, but Chris was gracious, of course, and I thought that right then: that’s rock and roll.</p>\n\n<p>You can use this as metaphor. Bleeding? Keep right on playing. Maybe you won’t even notice that you’re bleeding, at least not until you stop.</p>\n\n<p>Chris told me later that the guitar cleaned up fine, so all was well.</p>\n\n<p>Okay. On to the actual talk…</p>\n\n<p>I bet most of you have heard the phrase “three chord rock n roll.” Or have heard that “rock is so great because you only need three chords.”</p>\n\n<p>What you may not realize is that it’s even easier than that: it’s three specific chords. Always the same three chords.</p>\n\n<p>They might be in any key but they’re the first, fourth, and fifth. In the key of C, the first is C, the fourth is F, and the fifth is G. In the key of A it’s A, D, and E.</p>\n\n<p>And when a song <em>does</em> have more than those three chords, it has at least those three chords. They’re the foundation for almost all pop and rock.</p>\n\n<p>One part of music is building tension and then resolving it. I’ll demonstrate on guitar.</p>\n\n<p>[On guitar] Play the first .... and you’re fine. You’re home. Play the fourth .... and there’s a little tension. Not a ton, but some. But you want to go back to the first, to home.</p>\n\n<p>Then play the fifth ... and you have maximum tension. You definitely want to go back home to the first.</p>\n\n<p>So with those three chords you have everything you need to write a thousand songs.</p>\n\n<p>Now for a little demo, I’d like to invite Laura Savino up to help me out.</p>\n\n<p>[music]</p>\n\n<p>Thanks, Laura!</p>\n\n<p>SO LET ME MAKE TWO POINTS VERY CLEAR.</p>\n\n<ol>\n<li><p>ONE. If you’re writing apps or a website or doing a podcast or whatever — if you’re just starting out and only know the equivalent of three chords, don’t worry — you can create a masterpiece with just three chords.</p></li>\n<li><p>TWO. If you do know more than three chords, you might want to consider just using those three chords anyway. People <em>love</em> those three chords. They’re appealing. They’re accessible and intimate. They work.</p></li>\n</ol>\n\n\n<h4>Slide #2: “Brimful of Asha“ by Cornershop, Asha Bhosle, and You</h4>\n\n<p>One of my personal favorite three-chord-rock songs came out in the mid-90s. Brimful of Asha by Cornershop.</p>\n\n<p>Who here knows this song?</p>\n\n<p>Let me explain what it’s about:</p>\n\n<p>Asha Bhosle sang songs for Bollywood musicals. The actresses would lip-sync, but it was her singing. She did this for over a thousand movies. Over 12,000 songs.</p>\n\n<p>Some of those songs would be released as singles. Years ago a single would come out on vinyl, as a 45. A 45 is smaller than a regular album, and it has one song on each side. The number 45 means 45 revolutions-per-minute — you’d have to set your turntable to 45 instead of the usual 33 1/3. So: a 45 is a single.</p>\n\n<p>So here’s a little bit from the song:</p>\n\n<p>[There’s dancing, behind movie screens…]</p>\n\n<p>I <em>love</em> that image. That Asha is not just singing but <em>dancing</em> as she’s singing. We never see her dancing, but that joy and engagement shows up in her performance.</p>\n\n<p>And so this song is about hope. It’s about how a song can bring some consolation and hope when people need it.</p>\n\n<p>And her name Asha actually <em>means</em> hope. Brimful of Asha — brimful of hope.</p>\n\n<p>HERE’S MY POINT.</p>\n\n<p>We're in the same business. People form an emotional connection to whatever we’re making. The things we make can bring hope to other people. Knowing that, it’s our job to be as engaged and joyful as she is as we make our things. Maybe we’re not literally dancing, but it should be the metaphorical equivalent.</p>\n\n<h4>Slide #3: Squirrel Picture</h4>\n\n<p>Squirrel!</p>\n\n<p>When I was a kid we went to a Methodist church. I haven’t been to church hardly at all since I was a kid, but I remember one cool thing from church services: the minister would pause and ask people to shake hands with the people around them.</p>\n\n<p>So here are the rules. Tell people to have a good conference, and shake hands with at least one person from another table. Stand up!</p>\n\n<h4>Slide #4: “Hallelujah” by Leonard Cohen, with Singing by James Dempsey</h4>\n\n<p>A few weeks ago I found myself in a hotel bar with a bunch of other nerds. I also found a piano. If there’s a piano, I’m going to play it. So I talked a few people — James Dempsey, Jean McDonald, Curt Clifton, and Jim Correia, into singing some songs.</p>\n\n<p>I forget who suggested Hallelujah. Might have been James. I didn’t know it very well, but I did my best. James sang, and he was awesome.</p>\n\n<p>So when I was thinking about this talk, I was thinking of doing the most beautiful possible thing I could do. So I remembered James singing this song.</p>\n\n<p>I may not be religious, but I think it’s plain that there is awesome magnificence greater than anything any human could make. It’s right outside.</p>\n\n<p>I’m not sure bears feel humble at the sight of these mountains; I’m not sure birds are awed at the vistas they fly over.</p>\n\n<p>But we do. Humans do. And knowing that we can’t measure up, it doesn’t stop us. Intead, we’re <em>inspired</em>.</p>\n\n<p>So here’s what I love about Hallelujah. It’s about trying and failing, and loving and losing — and singing Hallelujah anyway. In Cohen’s words, it may be a broken Hallelujah, but it’s still on our lips.</p>\n\n<p>James Dempsey please report to the stage.</p>\n\n<p>Everybody is encouraged to sing along. Especially to the chorus.</p>\n\n<p>[Hallelujah]</p>\n\n<h4>Slide #5: Picture of my cat Papa</h4>\n\n<p>I’m going to go around the room and have everyone introduce themselves. RULE: if anyone can’t hear, yell out.</p>",
153
+ "date_published": "2017-03-25T11:55:21-07:00"
154
+ }
155
+ ]
156
+ }
@@ -1,11 +1,11 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../lib/feedjira')
2
- require 'sample_feeds'
3
- require 'vcr'
1
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/feedjira")
2
+ require "sample_feeds"
3
+ require "vcr"
4
4
 
5
- SAXMachine.handler = ENV['HANDLER'].to_sym if ENV['HANDLER']
5
+ SAXMachine.handler = ENV["HANDLER"].to_sym if ENV["HANDLER"]
6
6
 
7
7
  VCR.configure do |config|
8
- config.cassette_library_dir = 'fixtures/vcr_cassettes'
8
+ config.cassette_library_dir = "fixtures/vcr_cassettes"
9
9
  config.hook_into :faraday
10
10
  end
11
11
 
metadata CHANGED
@@ -1,46 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedjira
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
- - Paul Dix
8
- - Julien Kirch
7
+ - Adam Hess
9
8
  - Ezekiel Templin
10
9
  - Jon Allured
10
+ - Julien Kirch
11
+ - Michael Stock
12
+ - Paul Dix
11
13
  autorequire:
12
14
  bindir: bin
13
15
  cert_chain: []
14
- date: 2018-09-01 00:00:00.000000000 Z
16
+ date: 2017-12-22 00:00:00.000000000 Z
15
17
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: faraday
18
- requirement: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: '0.9'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '0.9'
30
- - !ruby/object:Gem::Dependency
31
- name: faraday_middleware
32
- requirement: !ruby/object:Gem::Requirement
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: '0.9'
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '0.9'
44
18
  - !ruby/object:Gem::Dependency
45
19
  name: loofah
46
20
  requirement: !ruby/object:Gem::Requirement
@@ -115,16 +89,16 @@ dependencies:
115
89
  name: rubocop
116
90
  requirement: !ruby/object:Gem::Requirement
117
91
  requirements:
118
- - - '='
92
+ - - ">="
119
93
  - !ruby/object:Gem::Version
120
- version: '0.46'
94
+ version: '0'
121
95
  type: :development
122
96
  prerelease: false
123
97
  version_requirements: !ruby/object:Gem::Requirement
124
98
  requirements:
125
- - - '='
99
+ - - ">="
126
100
  - !ruby/object:Gem::Version
127
- version: '0.46'
101
+ version: '0'
128
102
  - !ruby/object:Gem::Dependency
129
103
  name: vcr
130
104
  requirement: !ruby/object:Gem::Requirement
@@ -143,16 +117,16 @@ dependencies:
143
117
  name: yard
144
118
  requirement: !ruby/object:Gem::Requirement
145
119
  requirements:
146
- - - "~>"
120
+ - - ">="
147
121
  - !ruby/object:Gem::Version
148
- version: '0.9'
122
+ version: '0'
149
123
  type: :development
150
124
  prerelease: false
151
125
  version_requirements: !ruby/object:Gem::Requirement
152
126
  requirements:
153
- - - "~>"
127
+ - - ">="
154
128
  - !ruby/object:Gem::Version
155
- version: '0.9'
129
+ version: '0'
156
130
  description:
157
131
  email: feedjira@gmail.com
158
132
  executables: []
@@ -164,15 +138,13 @@ files:
164
138
  - ".rubocop.yml"
165
139
  - ".travis.yml"
166
140
  - CHANGELOG.md
141
+ - CODE_OF_CONDUCT.md
167
142
  - Dangerfile
168
143
  - Gemfile
169
144
  - LICENSE
170
145
  - README.md
171
146
  - Rakefile
172
147
  - feedjira.gemspec
173
- - fixtures/vcr_cassettes/fetch_failure.yml
174
- - fixtures/vcr_cassettes/parse_error.yml
175
- - fixtures/vcr_cassettes/success.yml
176
148
  - lib/feedjira.rb
177
149
  - lib/feedjira/configuration.rb
178
150
  - lib/feedjira/core_ext.rb
@@ -199,6 +171,8 @@ files:
199
171
  - lib/feedjira/parser/itunes_rss_category.rb
200
172
  - lib/feedjira/parser/itunes_rss_item.rb
201
173
  - lib/feedjira/parser/itunes_rss_owner.rb
174
+ - lib/feedjira/parser/json_feed.rb
175
+ - lib/feedjira/parser/json_feed_item.rb
202
176
  - lib/feedjira/parser/podlove_chapter.rb
203
177
  - lib/feedjira/parser/rss.rb
204
178
  - lib/feedjira/parser/rss_entry.rb
@@ -223,12 +197,15 @@ files:
223
197
  - spec/feedjira/parser/itunes_rss_item_spec.rb
224
198
  - spec/feedjira/parser/itunes_rss_owner_spec.rb
225
199
  - spec/feedjira/parser/itunes_rss_spec.rb
200
+ - spec/feedjira/parser/json_feed_item_spec.rb
201
+ - spec/feedjira/parser/json_feed_spec.rb
226
202
  - spec/feedjira/parser/podlove_chapter_spec.rb
227
203
  - spec/feedjira/parser/rss_entry_spec.rb
228
204
  - spec/feedjira/parser/rss_feed_burner_entry_spec.rb
229
205
  - spec/feedjira/parser/rss_feed_burner_spec.rb
230
206
  - spec/feedjira/parser/rss_spec.rb
231
207
  - spec/feedjira/preprocessor_spec.rb
208
+ - spec/feedjira_spec.rb
232
209
  - spec/sample_feeds.rb
233
210
  - spec/sample_feeds/AmazonWebServicesBlog.xml
234
211
  - spec/sample_feeds/AmazonWebServicesBlogFirstEntryContent.xml
@@ -243,9 +220,9 @@ files:
243
220
  - spec/sample_feeds/GoogleDocsList.xml
244
221
  - spec/sample_feeds/HREFConsideredHarmful.xml
245
222
  - spec/sample_feeds/HREFConsideredHarmfulFirstEntry.xml
223
+ - spec/sample_feeds/HuffPostCanada.xml
246
224
  - spec/sample_feeds/ITunesWithSingleQuotedAttributes.xml
247
225
  - spec/sample_feeds/ITunesWithSpacesInAttributes.xml
248
- - spec/sample_feeds/InvalidDateFormat.xml
249
226
  - spec/sample_feeds/PaulDixExplainsNothing.xml
250
227
  - spec/sample_feeds/PaulDixExplainsNothingAlternate.xml
251
228
  - spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml
@@ -260,6 +237,7 @@ files:
260
237
  - spec/sample_feeds/TypePadNews.xml
261
238
  - spec/sample_feeds/atom_with_link_tag_for_url_unmarked.xml
262
239
  - spec/sample_feeds/itunes.xml
240
+ - spec/sample_feeds/json_feed.json
263
241
  - spec/sample_feeds/pet_atom.xml
264
242
  - spec/sample_feeds/youtube_atom.xml
265
243
  - spec/spec_helper.rb
@@ -278,15 +256,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
278
256
  version: 1.9.3
279
257
  required_rubygems_version: !ruby/object:Gem::Requirement
280
258
  requirements:
281
- - - ">="
259
+ - - ">"
282
260
  - !ruby/object:Gem::Version
283
- version: '0'
261
+ version: 1.3.1
284
262
  requirements: []
285
263
  rubyforge_project:
286
- rubygems_version: 2.7.6
264
+ rubygems_version: 2.6.13
287
265
  signing_key:
288
266
  specification_version: 4
289
- summary: A feed fetching and parsing library
267
+ summary: A feed parsing library
290
268
  test_files:
291
269
  - spec/feedjira/configuration_spec.rb
292
270
  - spec/feedjira/date_time_utilities_spec.rb
@@ -304,12 +282,15 @@ test_files:
304
282
  - spec/feedjira/parser/itunes_rss_item_spec.rb
305
283
  - spec/feedjira/parser/itunes_rss_owner_spec.rb
306
284
  - spec/feedjira/parser/itunes_rss_spec.rb
285
+ - spec/feedjira/parser/json_feed_item_spec.rb
286
+ - spec/feedjira/parser/json_feed_spec.rb
307
287
  - spec/feedjira/parser/podlove_chapter_spec.rb
308
288
  - spec/feedjira/parser/rss_entry_spec.rb
309
289
  - spec/feedjira/parser/rss_feed_burner_entry_spec.rb
310
290
  - spec/feedjira/parser/rss_feed_burner_spec.rb
311
291
  - spec/feedjira/parser/rss_spec.rb
312
292
  - spec/feedjira/preprocessor_spec.rb
293
+ - spec/feedjira_spec.rb
313
294
  - spec/sample_feeds.rb
314
295
  - spec/sample_feeds/AmazonWebServicesBlog.xml
315
296
  - spec/sample_feeds/AmazonWebServicesBlogFirstEntryContent.xml
@@ -324,9 +305,9 @@ test_files:
324
305
  - spec/sample_feeds/GoogleDocsList.xml
325
306
  - spec/sample_feeds/HREFConsideredHarmful.xml
326
307
  - spec/sample_feeds/HREFConsideredHarmfulFirstEntry.xml
308
+ - spec/sample_feeds/HuffPostCanada.xml
327
309
  - spec/sample_feeds/ITunesWithSingleQuotedAttributes.xml
328
310
  - spec/sample_feeds/ITunesWithSpacesInAttributes.xml
329
- - spec/sample_feeds/InvalidDateFormat.xml
330
311
  - spec/sample_feeds/PaulDixExplainsNothing.xml
331
312
  - spec/sample_feeds/PaulDixExplainsNothingAlternate.xml
332
313
  - spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml
@@ -341,6 +322,7 @@ test_files:
341
322
  - spec/sample_feeds/TypePadNews.xml
342
323
  - spec/sample_feeds/atom_with_link_tag_for_url_unmarked.xml
343
324
  - spec/sample_feeds/itunes.xml
325
+ - spec/sample_feeds/json_feed.json
344
326
  - spec/sample_feeds/pet_atom.xml
345
327
  - spec/sample_feeds/youtube_atom.xml
346
328
  - spec/spec_helper.rb
@@ -1,62 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://www.example.com/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: 404
15
- message:
16
- headers:
17
- cache-control:
18
- - max-age=604800
19
- content-type:
20
- - text/html
21
- date:
22
- - Mon, 31 Oct 2016 02:29:13 GMT
23
- etag:
24
- - '"359670651+gzip"'
25
- expires:
26
- - Mon, 07 Nov 2016 02:29:13 GMT
27
- last-modified:
28
- - Fri, 09 Aug 2013 23:54:35 GMT
29
- server:
30
- - ECS (oxr/83C7)
31
- vary:
32
- - Accept-Encoding
33
- x-cache:
34
- - HIT
35
- x-ec-custom-error:
36
- - '1'
37
- content-length:
38
- - '606'
39
- connection:
40
- - close
41
- body:
42
- encoding: ASCII-8BIT
43
- string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
44
- \ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
45
- charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
46
- initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
47
- #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: \"Open
48
- Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n
49
- \ div {\n width: 600px;\n margin: 5em auto;\n padding:
50
- 50px;\n background-color: #fff;\n border-radius: 1em;\n }\n
51
- \ a:link, a:visited {\n color: #38488f;\n text-decoration:
52
- none;\n }\n @media (max-width: 700px) {\n body {\n background-color:
53
- #fff;\n }\n div {\n width: auto;\n margin:
54
- 0 auto;\n border-radius: 0;\n padding: 1em;\n }\n
55
- \ }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
56
- \ <p>This domain is established to be used for illustrative examples in
57
- documents. You may use this\n domain in examples without prior coordination
58
- or asking for permission.</p>\n <p><a href=\"http://www.iana.org/domains/example\">More
59
- information...</a></p>\n</div>\n</body>\n</html>\n"
60
- http_version:
61
- recorded_at: Mon, 31 Oct 2016 02:29:13 GMT
62
- recorded_with: VCR 3.0.3
@@ -1,222 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://feedjira.com/
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:50:31 GMT
23
- etag:
24
- - '"3678-53e47882c0305-gzip"'
25
- accept-ranges:
26
- - bytes
27
- vary:
28
- - Accept-Encoding
29
- content-length:
30
- - '3519'
31
- connection:
32
- - close
33
- content-type:
34
- - text/html
35
- body:
36
- encoding: ASCII-8BIT
37
- string: |
38
- <!DOCTYPE html>
39
- <html>
40
- <head>
41
- <meta charset='utf-8'>
42
- <meta content='IE=edge;chrome=1' http-equiv='X-UA-Compatible'>
43
- <meta content='width=device-width, initial-scale=.7, maximum-scale=1' name='viewport'>
44
- <title>Feedjira</title>
45
- <link href="http://fonts.googleapis.com/css?family=Merriweather+Sans:400,300,400italic,700,700italic,300italic" rel="stylesheet" type="text/css" media="screen" />
46
- <link href="/css/syntax.css" media="screen" rel="stylesheet" type="text/css" />
47
- <link href="/css/style.css" media="screen" rel="stylesheet" type="text/css" />
48
- <link rel="alternate" type="application/atom+xml" title="Atom Feed" href="/blog/feed.xml" />
49
- </head>
50
- <body>
51
- <div id='content'>
52
- <header>
53
- <h1><a href="/">Feedjira</a></h1>
54
- </header>
55
- <nav>
56
- <ul>
57
- <li><a href="/">Home</a></li>
58
- <li><a href="/blog/">Blog</a></li>
59
- <li><a target="_blank" href="https://github.com/feedjira/feedjira">Source</a></li>
60
- </ul>
61
- </nav>
62
- <section><h1>The Feedjira Ruby Gem</h1>
63
-
64
- <p><a href="https://github.com/feedjira/feedjira">Feedjira</a> (formerly Feedzirra) is a Ruby gem for fetching and parsing
65
- RSS feeds. Version 2.0 <a href="/blog/2015/06/05/feedjira-two-point-oh.html">was recently released</a>.</p>
66
-
67
- <h2>Getting Started</h2>
68
-
69
- <p>Feedjira is tested with Ruby version 1.9.3 and 2.x so like any Ruby gem, the
70
- first step is to install the gem:</p>
71
- <pre class="highlight text"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div></td><td class="code">$ gem install feedjira
72
- </td></tr></tbody></table></pre>
73
- <p>Or add it to your Gemfile:</p>
74
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div></td><td class="code"><span class="n">gem</span> <span class="s1">&#39;feedjira&#39;</span>
75
- </td></tr></tbody></table></pre>
76
- <h2>Fetching and Parsing</h2>
77
-
78
- <p>For many users, the <code>fetch_and_parse</code> method is what they use Feedjira for. This
79
- method takes a url and returns a Parser object:</p>
80
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div><div class="lineno">2</div><div class="lineno">3</div></td><td class="code"><span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;http://feedjira.com/blog/feed.xml&quot;</span>
81
- <span class="n">feed</span> <span class="o">=</span> <span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.fetch_and_parse</span> <span class="n">url</span>
82
- <span class="c1"># =&gt; #&lt;Feedjira::Parser::Atom...&gt;</span>
83
- </td></tr></tbody></table></pre>
84
- <p>These feed objects have both the meta data for a feed and an <code>entries</code>
85
- collection that contains all the entries that were found:</p>
86
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div><div class="lineno">2</div><div class="lineno">3</div><div class="lineno">4</div><div class="lineno">5</div><div class="lineno">6</div></td><td class="code"><span class="n">feed</span><span class="nf">.title</span>
87
- <span class="c1"># =&gt; &quot;Feedjira Blog&quot;</span>
88
- <span class="n">feed</span><span class="nf">.url</span>
89
- <span class="c1"># =&gt; &quot;http://feedjira.com/blog&quot;</span>
90
- <span class="n">feed</span><span class="nf">.entries</span> <span class="c1"># returns an array of Entry objects</span>
91
- <span class="c1"># =&gt; [&lt;Feedjira::Feed::Entry ...&gt;, &lt;Feedjira::Feed::Entry ...&gt;, ...]</span>
92
- </td></tr></tbody></table></pre>
93
- <p>These entry objects contain the data parsed from the feed XML:</p>
94
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div><div class="lineno">2</div><div class="lineno">3</div><div class="lineno">4</div><div class="lineno">5</div></td><td class="code"><span class="n">entry</span> <span class="o">=</span> <span class="n">feed</span><span class="nf">.entries.first</span>
95
- <span class="n">entry</span><span class="nf">.title</span>
96
- <span class="c1"># =&gt; &quot;Announcing verison 1.0&quot;</span>
97
- <span class="n">entry</span><span class="nf">.url</span>
98
- <span class="c1"># =&gt; &quot;http://feedjira.com/blog/2014-02-12-announcing-version-10.html&quot;</span>
99
- </td></tr></tbody></table></pre>
100
- <h2>Just Parsing</h2>
101
-
102
- <p>The parsing functionality of Feedjira has been exposed so that it can be used in
103
- isolation:</p>
104
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div><div class="lineno">2</div><div class="lineno">3</div><div class="lineno">4</div></td><td class="code"><span class="n">xml</span> <span class="o">=</span> <span class="no">Faraday</span><span class="nf">.get</span><span class="p">(</span><span class="n">url</span><span class="p">)</span><span class="nf">.body</span>
105
- <span class="n">feed</span> <span class="o">=</span> <span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.parse</span> <span class="n">xml</span>
106
- <span class="n">feed</span><span class="nf">.entries.first.title</span>
107
- <span class="c1"># =&gt; &quot;Announcing verison 1.0&quot;</span>
108
- </td></tr></tbody></table></pre>
109
- <h2>Adding a feed parsing class</h2>
110
-
111
- <p>When determining which parser to use for a given XML document, the following
112
- list of parser classes is used:</p>
113
-
114
- <ul>
115
- <li><code>Feedjira::Parser::RSSFeedBurner</code></li>
116
- <li><code>Feedjira::Parser::GoogleDocsAtom</code></li>
117
- <li><code>Feedjira::Parser::AtomFeedBurner</code></li>
118
- <li><code>Feedjira::Parser::Atom</code></li>
119
- <li><code>Feedjira::Parser::ITunesRSS</code></li>
120
- <li><code>Feedjira::Parser::RSS</code></li>
121
- </ul>
122
-
123
- <p>You can insert your own parser at the front of this stack by calling
124
- <code>add_feed_class</code>, like this:</p>
125
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div></td><td class="code"><span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.add_feed_class</span> <span class="no">MyAwesomeParser</span>
126
- </td></tr></tbody></table></pre>
127
- <p>Now when you <code>fetch_and_parse</code>, <code>MyAwesomeParser</code> will be the first one to get a
128
- chance to parse the feed.</p>
129
-
130
- <p>If you have the XML and just want to provide a parser class for one parse, you
131
- can specify that using <code>parse_with</code>:</p>
132
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div></td><td class="code"><span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.parse_with</span> <span class="no">MyAwesomeParser</span><span class="p">,</span> <span class="n">xml</span>
133
- </td></tr></tbody></table></pre>
134
- <h2>Adding attributes to all feeds types / all entries types</h2>
135
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div><div class="lineno">2</div><div class="lineno">3</div><div class="lineno">4</div><div class="lineno">5</div><div class="lineno">6</div><div class="lineno">7</div><div class="lineno">8</div><div class="lineno">9</div><div class="lineno">10</div></td><td class="code"><span class="c1"># Add the generator attribute to all feed types</span>
136
- <span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.add_common_feed_element</span><span class="p">(</span><span class="s1">&#39;generator&#39;</span><span class="p">)</span>
137
- <span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.fetch_and_parse</span><span class="p">(</span><span class="s2">&quot;http://www.pauldix.net/atom.xml&quot;</span><span class="p">)</span><span class="nf">.generator</span> <span class="c1"># =&gt; &#39;TypePad&#39;</span>
138
-
139
- <span class="c1"># Add some GeoRss information</span>
140
- <span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.add_common_feed_entry_element</span><span class="p">(</span><span class="s1">&#39;geo:lat&#39;</span><span class="p">,</span> <span class="ss">:as</span> <span class="o">=&gt;</span> <span class="ss">:lat</span><span class="p">)</span>
141
- <span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.fetch_and_parse</span><span class="p">(</span><span class="s2">&quot;http://www.earthpublisher.com/georss.php&quot;</span><span class="p">)</span><span class="nf">.entries.each</span> <span class="k">do</span> <span class="o">|</span><span class="n">e</span><span class="o">|</span>
142
- <span class="nb">p</span> <span class="s2">&quot;lat: #[e.lat}, long: </span><span class="si">#{</span><span class="n">e</span><span class="nf">.long</span><span class="o">]</span><span class="s2">&quot;
143
- end
144
- </span></td></tr></tbody></table></pre>
145
- <h2>Adding attributes to only one class</h2>
146
-
147
- <p>If you want to add attributes for only one class you simply have to declare them
148
- in the class</p>
149
- <pre class="highlight ruby"><table><tbody><tr><td class="gutter gl"><div class="lineno">1</div><div class="lineno">2</div><div class="lineno">3</div><div class="lineno">4</div><div class="lineno">5</div><div class="lineno">6</div><div class="lineno">7</div><div class="lineno">8</div><div class="lineno">9</div><div class="lineno">10</div><div class="lineno">11</div><div class="lineno">12</div></td><td class="code"><span class="c1"># Add some GeoRss information</span>
150
- <span class="nb">require</span> <span class="s1">&#39;lib/feedzirra/parser/rss_entry&#39;</span>
151
-
152
- <span class="k">class </span><span class="nc">Feedjira</span><span class="o">::</span><span class="no">Parser</span><span class="o">::</span><span class="no">RSSEntry</span>
153
- <span class="n">element</span> <span class="s1">&#39;geo:lat&#39;</span><span class="p">,</span> <span class="ss">:as</span> <span class="o">=&gt;</span> <span class="ss">:lat</span>
154
- <span class="n">element</span> <span class="s1">&#39;geo:long&#39;</span><span class="p">,</span> <span class="ss">:as</span> <span class="o">=&gt;</span> <span class="ss">:long</span>
155
- <span class="k">end</span>
156
-
157
- <span class="c1"># Fetch a feed containing GeoRss info and print them</span>
158
- <span class="no">Feedjira</span><span class="o">::</span><span class="no">Feed</span><span class="nf">.fetch_and_parse</span><span class="p">(</span><span class="s2">&quot;http://www.earthpublisher.com/georss.php&quot;</span><span class="p">)</span><span class="nf">.entries.each</span> <span class="k">do</span> <span class="o">|</span><span class="n">e</span><span class="o">|</span>
159
- <span class="nb">p</span> <span class="s2">&quot;lat: </span><span class="si">#{</span><span class="n">e</span><span class="nf">.lat</span><span class="si">}</span><span class="s2">, long: </span><span class="si">#{</span><span class="n">e</span><span class="nf">.long</span><span class="si">}</span><span class="s2">&quot;</span>
160
- <span class="k">end</span>
161
- </td></tr></tbody></table></pre>
162
- <h2>Testing</h2>
163
-
164
- <p>Feedjira uses <a href="https://github.com/lostisland/faraday">faraday</a> to perform requests, so testing Feedjira is really
165
- about <a href="https://github.com/lostisland/faraday#using-faraday-for-testing">stubbing out faraday requests</a>.</p>
166
-
167
- <h2>Projects that use Feedjira</h2>
168
-
169
- <p>Feedjira is used in some awesome projects around the web - from RSS readers to
170
- add-ons and everything in between. Here are some of them:</p>
171
-
172
- <ul>
173
- <li><p><a href="https://feedbin.com/">Feedbin</a>: Feedbin bills itself as a fast, simple RSS reader that delivers a
174
- great reading experience. It&rsquo;s a paid RSS reader that integrates with mobile
175
- apps and it even has a fully featured API!</p></li>
176
- <li><p><a href="https://github.com/swanson/stringer">Stringer</a>: Stringer is a self-hosted, anti-social RSS reader. It&rsquo;s an
177
- open-source project that&rsquo;s easy to deploy to any host, there&rsquo;s even a
178
- one-click button to deploy on Heroku.</p></li>
179
- <li><p><a href="https://apps.shopify.com/blogfeeder">BlogFeeder</a>: BlogFeeder is a paid Shopify App that makes it easy for you to
180
- import any external blog into your Shopify store. It helps improve your
181
- store&rsquo;s SEO and keeps your blogs in sync, plus a lot more.</p></li>
182
- <li><p><a href="https://github.com/amatriain/feedbunch">Feedbunch</a>: Feedbunch is an open source feed reader built to fill the hole
183
- left by Google Reader. It aims to support all features of Google Reader and
184
- actually improve on others.</p></li>
185
- <li><p><a href="http://theoldreader.com/">The Old Reader</a>: The Old Reader advertises as the ultimate social RSS
186
- reader. It&rsquo;s free to start and also has a paid premium version. There&rsquo;s an API
187
- and it integrates with many different mobile apps.</p></li>
188
- <li><p><a href="https://solveforall.com/">Solve for All</a>: Solve for All combines search engine and feed parsing
189
- while protecting your privacy. It&rsquo;s even extendable by the community!</p></li>
190
- </ul>
191
-
192
- <p>Note: to get your project on this list, simply <a href="mailto:feedjira@gmail.com">send an email</a>
193
- with your project&rsquo;s details.</p>
194
- </section>
195
- </div>
196
- <footer>
197
- <div class='column'>
198
- <ul>
199
- <li><a href="/">Home</a></li>
200
- <li><a href="/blog/">Blog</a></li>
201
- <li><a href="/blog/feed.xml">Feed</a></li>
202
- <li><a target="_blank" href="https://github.com/feedjira/feedjira">Source</a></li>
203
- <li><a target="_blank" href="https://twitter.com/feedjira">@feedjira</a></li>
204
- </ul>
205
- <p>Maintained by <a href="http://jonallured.com">Jon Allured</a>, Created by <a href="http://www.pauldix.net">Paul Dix</a>, Site design by <a href="http://danielariza.com">Daniel Ariza</a></p>
206
- </div>
207
- </footer>
208
- <script type="text/javascript">
209
- var _gaq = _gaq || [];
210
- _gaq.push(["_setAccount", "UA-3137727-7"]);
211
- _gaq.push(["_trackPageview"]);
212
- (function() {
213
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
214
- ga.src = ('https:' == document.location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
215
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
216
- })();
217
- </script>
218
- </body>
219
- </html>
220
- http_version:
221
- recorded_at: Mon, 31 Oct 2016 02:29:13 GMT
222
- recorded_with: VCR 3.0.3