feedjira 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +8 -0
  4. data/.travis.yml +31 -12
  5. data/CHANGELOG.md +15 -1
  6. data/Dangerfile +1 -0
  7. data/Gemfile +2 -1
  8. data/Rakefile +6 -1
  9. data/feedjira.gemspec +16 -14
  10. data/fixtures/vcr_cassettes/fetch_failure.yml +62 -0
  11. data/fixtures/vcr_cassettes/parse_error.yml +222 -0
  12. data/fixtures/vcr_cassettes/success.yml +281 -0
  13. data/lib/feedjira.rb +9 -0
  14. data/lib/feedjira/core_ext.rb +3 -3
  15. data/lib/feedjira/core_ext/date.rb +2 -1
  16. data/lib/feedjira/core_ext/string.rb +1 -1
  17. data/lib/feedjira/core_ext/time.rb +19 -16
  18. data/lib/feedjira/date_time_utilities.rb +24 -0
  19. data/lib/feedjira/date_time_utilities/date_time_language_parser.rb +22 -0
  20. data/lib/feedjira/date_time_utilities/date_time_pattern_parser.rb +29 -0
  21. data/lib/feedjira/feed.rb +27 -18
  22. data/lib/feedjira/feed_entry_utilities.rb +15 -17
  23. data/lib/feedjira/feed_utilities.rb +26 -21
  24. data/lib/feedjira/parser/atom.rb +9 -8
  25. data/lib/feedjira/parser/atom_entry.rb +10 -13
  26. data/lib/feedjira/parser/atom_feed_burner.rb +8 -10
  27. data/lib/feedjira/parser/atom_feed_burner_entry.rb +11 -14
  28. data/lib/feedjira/parser/atom_youtube.rb +20 -0
  29. data/lib/feedjira/parser/atom_youtube_entry.rb +29 -0
  30. data/lib/feedjira/parser/google_docs_atom.rb +6 -6
  31. data/lib/feedjira/parser/google_docs_atom_entry.rb +11 -11
  32. data/lib/feedjira/parser/itunes_rss.rb +39 -22
  33. data/lib/feedjira/parser/itunes_rss_category.rb +38 -0
  34. data/lib/feedjira/parser/itunes_rss_item.rb +28 -20
  35. data/lib/feedjira/parser/itunes_rss_owner.rb +3 -4
  36. data/lib/feedjira/parser/podlove_chapter.rb +20 -0
  37. data/lib/feedjira/parser/rss.rb +10 -8
  38. data/lib/feedjira/parser/rss_entry.rb +17 -21
  39. data/lib/feedjira/parser/rss_feed_burner.rb +4 -6
  40. data/lib/feedjira/parser/rss_feed_burner_entry.rb +23 -28
  41. data/lib/feedjira/parser/rss_image.rb +15 -0
  42. data/lib/feedjira/preprocessor.rb +2 -2
  43. data/lib/feedjira/version.rb +1 -1
  44. data/spec/feedjira/date_time_utilities_spec.rb +41 -0
  45. data/spec/feedjira/feed_entry_utilities_spec.rb +23 -19
  46. data/spec/feedjira/feed_spec.rb +109 -74
  47. data/spec/feedjira/feed_utilities_spec.rb +65 -63
  48. data/spec/feedjira/parser/atom_entry_spec.rb +54 -34
  49. data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +27 -20
  50. data/spec/feedjira/parser/atom_feed_burner_spec.rb +32 -30
  51. data/spec/feedjira/parser/atom_spec.rb +50 -48
  52. data/spec/feedjira/parser/atom_youtube_entry_spec.rb +86 -0
  53. data/spec/feedjira/parser/atom_youtube_spec.rb +43 -0
  54. data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +5 -4
  55. data/spec/feedjira/parser/google_docs_atom_spec.rb +6 -6
  56. data/spec/feedjira/parser/itunes_rss_item_spec.rb +33 -29
  57. data/spec/feedjira/parser/itunes_rss_owner_spec.rb +10 -9
  58. data/spec/feedjira/parser/itunes_rss_spec.rb +83 -30
  59. data/spec/feedjira/parser/podlove_chapter_spec.rb +37 -0
  60. data/spec/feedjira/parser/rss_entry_spec.rb +50 -33
  61. data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +55 -33
  62. data/spec/feedjira/parser/rss_feed_burner_spec.rb +31 -26
  63. data/spec/feedjira/parser/rss_spec.rb +56 -24
  64. data/spec/feedjira/preprocessor_spec.rb +11 -3
  65. data/spec/sample_feeds.rb +29 -21
  66. data/spec/sample_feeds/AmazonWebServicesBlog.xml +797 -797
  67. data/spec/sample_feeds/AtomEscapedHTMLInPreTag.xml +13 -0
  68. data/spec/sample_feeds/CRE.xml +5849 -0
  69. data/spec/sample_feeds/FeedBurnerXHTML.xml +400 -400
  70. data/spec/sample_feeds/ITunesWithSingleQuotedAttributes.xml +67 -0
  71. data/spec/sample_feeds/PaulDixExplainsNothing.xml +175 -175
  72. data/spec/sample_feeds/PaulDixExplainsNothingAlternate.xml +175 -175
  73. data/spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml +16 -16
  74. data/spec/sample_feeds/PaulDixExplainsNothingWFW.xml +174 -174
  75. data/spec/sample_feeds/TenderLovemaking.xml +12 -2
  76. data/spec/sample_feeds/TrotterCashionHome.xml +611 -611
  77. data/spec/sample_feeds/TypePadNews.xml +368 -368
  78. data/spec/sample_feeds/itunes.xml +18 -2
  79. data/spec/sample_feeds/pet_atom.xml +229 -229
  80. data/spec/sample_feeds/youtube_atom.xml +395 -0
  81. data/spec/spec_helper.rb +6 -0
  82. metadata +112 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a75fe90b3327d3110c7ba5e5ebe8acdbfc9e4c10
4
- data.tar.gz: d4313aca74f021751d583f61c140a18aea2381b7
3
+ metadata.gz: 7962491408ccbd8bbb0574f66ea50ba074171688
4
+ data.tar.gz: 9b5ad12bb4e13a32dd38bbb5f63c4b84328eea29
5
5
  SHA512:
6
- metadata.gz: 4004f548a5b6a3215294d5b8ebd81496c4603eaab3ba3c2f1b269815010fcbdc12cef8660a10ddd398159a09cb30443131e9c83b6973bf9cad9a746d78728c29
7
- data.tar.gz: f426881efa2533cdef5bb34eb0ff57bc86259abfd26eb916fadc79dea1b30f4b95262ffc53d1539494fc306a845b4b68cd35377d79d41bcfd73976a8387fa12d
6
+ metadata.gz: 7b6aed4014dd8e47d3f694dc8d02e0553ca2f30c3769cba409288d6541f23d2b7ff13ba6284c9815f0eaf14c4657ec55b5c89dbf0c4ca736a6d2c9cc5d0970ec
7
+ data.tar.gz: 8a6675eab97c9e0bb71823f1aa75033d0560c6a78dd359be6962d1c72816ad178aa74ea422ae72b8109e5a58e2b9705cbfe890d91e39726bbcee3f994c8fb166
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  .bundle
2
+ .projections.json
2
3
  .ruby-gemset
3
4
  .ruby-version
4
5
  Gemfile.lock
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.1
3
+
4
+ Documentation:
5
+ Enabled: false
6
+
7
+ Style/ClassAndModuleChildren:
8
+ Enabled: false
@@ -1,18 +1,37 @@
1
1
  language: ruby
2
2
 
3
- bundler_args: --without tools
4
-
5
- branches:
6
- only:
7
- - master
3
+ cache: bundler
8
4
 
9
5
  rvm:
10
- - 1.9.3
11
- - 2.0.0
12
- - 2.1.0
13
- - rbx-2
6
+ - 2.1
7
+ - 2.2
8
+ - 2.3
9
+ - jruby-9
10
+ - ruby-head
14
11
 
15
12
  env:
16
- matrix:
17
- - HANDLER="nokogiri"
18
- - HANDLER="ox"
13
+ - HANDLER=nokogiri
14
+ - HANDLER=ox
15
+ - HANDLER=oga
16
+
17
+ matrix:
18
+ fast_finish: true
19
+ allow_failures:
20
+ - rvm: jruby-9
21
+ - rvm: ruby-head
22
+ exclude:
23
+ - rvm: jruby-9
24
+ env: HANDLER=ox
25
+
26
+ before_install:
27
+ - gem update bundler
28
+
29
+ script:
30
+ - bundle exec rake
31
+ - bundle exec danger
32
+
33
+ notifications:
34
+ email: false
35
+ webhooks:
36
+ urls:
37
+ secure: XjoUz2rPXFHnitw//jN4qA92jq7bH19iOI/5KnuptLzz5HrWq1VAXxAr/Fh0KxYZT29G/9i5szaHX1QacfO7he4xa2tZKudRL70Dw3KRLgqLi70G6kFuZYlh+MgMHZy6KwZ/4/250wO31fpv24PCb2M56iTsev2g2uporeobO0Q=
@@ -1,10 +1,24 @@
1
1
  # Feedjira Changelog
2
2
 
3
+ ## 2.1.0
4
+
5
+ * Enhancements
6
+ * AtomYoutube is now a supported parser [#337][] (@jfiorato)
7
+ * Oga parsing is now supported [#331][] (@krasnoukhov)
8
+ * DateTime Handler now supports localized dates [#313][] (@PascalTurbo)
9
+ * RSS now supports language attribute [#344][] (@PascalTurbo)
10
+ * ITunesRSS added support for:
11
+ * `ttl` and `last_built` [#343][] (@sferik)
12
+ * `itunes_category` and `itunes_category_paths` [#329][] (@knu)
13
+ * `itunes_complete` [#328][] (@knu)
14
+ * single quoted attributes [#326][] (@sferik)
15
+ * Add image attribute [#349][] (@sferik)
16
+
3
17
  ## 2.0.0
4
18
 
5
19
  * General
6
20
  * Replaced curb with faraday
7
- * Removed update funcionality
21
+ * Removed update functionality
8
22
 
9
23
  ## 1.6.0
10
24
 
@@ -0,0 +1 @@
1
+ commit_lint.check
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gemspec
5
5
  gem 'pry'
6
6
 
7
7
  group :test do
8
+ gem 'oga'
9
+ gem 'ox', platforms: [:mri, :rbx]
8
10
  gem 'rake'
9
- gem 'ox'
10
11
  end
data/Rakefile CHANGED
@@ -1,7 +1,12 @@
1
1
  require 'rspec/core/rake_task'
2
+ require 'rubocop/rake_task'
2
3
 
3
4
  RSpec::Core::RakeTask.new(:spec) do |t|
4
5
  t.verbose = false
5
6
  end
6
7
 
7
- task default: :spec
8
+ RuboCop::RakeTask.new(:rubocop) do |t|
9
+ t.options = ['--display-cop-names']
10
+ end
11
+
12
+ task default: [:spec, :rubocop]
@@ -2,27 +2,29 @@
2
2
  require File.expand_path('../lib/feedjira/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = 'feedjira'
6
- s.version = Feedjira::VERSION
7
- s.license = 'MIT'
8
-
9
5
  s.authors = ['Paul Dix', 'Julien Kirch', 'Ezekiel Templin', 'Jon Allured']
10
6
  s.email = 'feedjira@gmail.com'
11
7
  s.homepage = 'http://feedjira.com'
12
-
13
- s.summary = 'A feed fetching and parsing library'
14
- s.description = 'A library designed to retrieve and parse feeds as quickly as possible'
8
+ s.license = 'MIT'
9
+ s.name = 'feedjira'
10
+ s.platform = Gem::Platform::RUBY
11
+ s.summary = 'A feed fetching and parsing library'
12
+ s.version = Feedjira::VERSION
15
13
 
16
14
  s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
15
  s.require_paths = ['lib']
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
17
 
20
- s.platform = Gem::Platform::RUBY
18
+ s.required_ruby_version = '>=1.9.3'
21
19
 
22
- s.add_dependency 'sax-machine', '~> 1.0'
23
- s.add_dependency 'faraday', '~> 0.9'
24
- s.add_dependency 'faraday_middleware', '~> 0.9'
25
- s.add_dependency 'loofah', '~> 2.0'
20
+ s.add_dependency 'faraday', '>= 0.9'
21
+ s.add_dependency 'faraday_middleware', '>= 0.9'
22
+ s.add_dependency 'loofah', '>= 2.0'
23
+ s.add_dependency 'sax-machine', '>= 1.0'
26
24
 
27
- s.add_development_dependency 'rspec', '~> 3.0'
25
+ s.add_development_dependency 'danger'
26
+ s.add_development_dependency 'danger-commit_lint'
27
+ s.add_development_dependency 'rspec'
28
+ s.add_development_dependency 'rubocop'
29
+ s.add_development_dependency 'vcr'
28
30
  end
@@ -0,0 +1,62 @@
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
@@ -0,0 +1,222 @@
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