feedparser 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ {
2
+ "version": "https://jsonfeed.org/version/1",
3
+ "title": "My Example Feed",
4
+ "home_page_url": "https://example.org/",
5
+ "feed_url": "https://example.org/feed.json",
6
+ "items": [
7
+ {
8
+ "id": "2",
9
+ "content_text": "This is a second item.",
10
+ "url": "https://example.org/second-item"
11
+ },
12
+ {
13
+ "id": "1",
14
+ "content_html": "<p>Hello, world!</p>",
15
+ "url": "https://example.org/initial-post"
16
+ }
17
+ ]
18
+ }
19
+
20
+ ---
21
+
22
+ feed.format: json
23
+ feed.title: My Example Feed
24
+ feed.url: https://example.org/
25
+ feed.feed_url: https://example.org/feed.json
26
+
27
+ feed.items.size: >>> 2
28
+
29
+ feed.items[0].id: 2
30
+ feed.items[0].content_text: This is a second item.
31
+ feed.items[0].url: https://example.org/second-item
32
+
33
+
34
+ feed.items[1].id: 1
35
+ feed.items[1].content_html: <p>Hello, world!</p>
36
+ feed.items[1].url: https://example.org/initial-post
@@ -0,0 +1,34 @@
1
+ {
2
+ "version": "https://jsonfeed.org/version/1",
3
+ "user_comment": "This is a microblog feed. You can add this to your feed reader using the following URL: https://example.org/feed.json",
4
+ "title": "Brent Simmons’s Microblog",
5
+ "home_page_url": "https://example.org/",
6
+ "feed_url": "https://example.org/feed.json",
7
+ "author": {
8
+ "name": "Brent Simmons",
9
+ "url": "http://example.org/",
10
+ "avatar": "https://example.org/avatar.png"
11
+ },
12
+ "items": [
13
+ {
14
+ "id": "2347259",
15
+ "url": "https://example.org/2347259",
16
+ "content_text": "Cats are neat. \n\nhttps://example.org/cats",
17
+ "date_published": "2016-02-09T14:22:00-07:00"
18
+ }
19
+ ]
20
+ }
21
+
22
+ ---
23
+
24
+ feed.format: json
25
+ feed.title: Brent Simmons’s Microblog
26
+ feed.url: https://example.org/
27
+ feed.feed_url: https://example.org/feed.json
28
+
29
+ feed.items.size: >>> 1
30
+
31
+ feed.items[0].id: 2347259
32
+ feed.items[0].url: https://example.org/2347259
33
+ feed.items[0].content_text: Cats are neat. \n\nhttps://example.org/cats
34
+ feed.items[0].published: >>> DateTime.new( 2016, 2, 9, 14, 22, 0, '-7')
@@ -0,0 +1,48 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
3
+ <title>xkcd.com</title>
4
+ <link href="https://xkcd.com/" rel="alternate"></link>
5
+ <id>https://xkcd.com/</id>
6
+ <updated>2017-05-22T00:00:00Z</updated>
7
+ <entry>
8
+ <title>Genetic Testing Results</title>
9
+ <link href="https://xkcd.com/1840/" rel="alternate"></link>
10
+ <updated>2017-05-22T00:00:00Z</updated>
11
+ <id>https://xkcd.com/1840/</id>
12
+ <summary type="html">&lt;img src="https://imgs.xkcd.com/comics/genetic_testing_results.png" title="That's very exciting! The bad news is that it's a risk factor for a lot of things." alt="That's very exciting! The bad news is that it's a risk factor for a lot of things." /&gt;</summary>
13
+ </entry>
14
+ <entry>
15
+ <title>Doctor Visit</title>
16
+ <link href="https://xkcd.com/1839/" rel="alternate"></link>
17
+ <updated>2017-05-19T00:00:00Z</updated>
18
+ <id>https://xkcd.com/1839/</id>
19
+ <summary type="html">&lt;img src="https://imgs.xkcd.com/comics/doctor_visit.png" title="According to these blood tests, you're like 30% cereal." alt="According to these blood tests, you're like 30% cereal." /&gt;</summary>
20
+ </entry>
21
+ <entry>
22
+ <title>Machine Learning</title>
23
+ <link href="https://xkcd.com/1838/" rel="alternate"></link>
24
+ <updated>2017-05-17T00:00:00Z</updated>
25
+ <id>https://xkcd.com/1838/</id>
26
+ <summary type="html">&lt;img src="https://imgs.xkcd.com/comics/machine_learning.png" title="The pile gets soaked with data and starts to get mushy over time, so it's technically recurrent." alt="The pile gets soaked with data and starts to get mushy over time, so it's technically recurrent." /&gt;</summary>
27
+ </entry>
28
+ <entry>
29
+ <title>Rental Car</title>
30
+ <link href="https://xkcd.com/1837/" rel="alternate"></link>
31
+ <updated>2017-05-15T00:00:00Z</updated>
32
+ <id>https://xkcd.com/1837/</id>
33
+ <summary type="html">&lt;img src="https://imgs.xkcd.com/comics/rental_car.png" title="Technically, both cars are haunted, but the murder ghosts can't stand listening to the broken GPS for more than a few minutes." alt="Technically, both cars are haunted, but the murder ghosts can't stand listening to the broken GPS for more than a few minutes." /&gt;</summary>
34
+ </entry>
35
+ </feed>
36
+
37
+ ---
38
+
39
+ feed.format: atom
40
+ feed.title: xkcd.com
41
+ feed.url: https://xkcd.com/
42
+ feed.updated: >>> DateTime.new( 2017, 5, 22 )
43
+ feed.items.size: >>> 4
44
+
45
+ feed.items[0].title: Genetic Testing Results
46
+ feed.items[0].url: https://xkcd.com/1840/
47
+ feed.items[0].guid: https://xkcd.com/1840/
48
+ feed.items[0].updated: >>> DateTime.new( 2017, 5, 22 )
@@ -0,0 +1,55 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <rss version="2.0">
3
+ <channel>
4
+ <title>xkcd.com</title>
5
+ <link>https://xkcd.com/</link>
6
+ <description>xkcd.com: A webcomic of romance and math humor.</description>
7
+ <language>en</language>
8
+ <item>
9
+ <title>Genetic Testing Results</title>
10
+ <link>https://xkcd.com/1840/</link>
11
+ <description>&lt;img src="https://imgs.xkcd.com/comics/genetic_testing_results.png" title="That's very exciting! The bad news is that it's a risk factor for a lot of things." alt="That's very exciting! The bad news is that it's a risk factor for a lot of things." /&gt;</description>
12
+ <pubDate>Mon, 22 May 2017 04:00:00 -0000</pubDate>
13
+ <guid>https://xkcd.com/1840/</guid>
14
+ </item>
15
+ <item>
16
+ <title>Doctor Visit</title>
17
+ <link>https://xkcd.com/1839/</link>
18
+ <description>&lt;img src="https://imgs.xkcd.com/comics/doctor_visit.png" title="According to these blood tests, you're like 30% cereal." alt="According to these blood tests, you're like 30% cereal." /&gt;</description>
19
+ <pubDate>Fri, 19 May 2017 04:00:00 -0000</pubDate>
20
+ <guid>https://xkcd.com/1839/</guid>
21
+ </item>
22
+ <item>
23
+ <title>Machine Learning</title>
24
+ <link>https://xkcd.com/1838/</link>
25
+ <description>&lt;img src="https://imgs.xkcd.com/comics/machine_learning.png" title="The pile gets soaked with data and starts to get mushy over time, so it's technically recurrent." alt="The pile gets soaked with data and starts to get mushy over time, so it's technically recurrent." /&gt;</description>
26
+ <pubDate>Wed, 17 May 2017 04:00:00 -0000</pubDate>
27
+ <guid>https://xkcd.com/1838/</guid>
28
+ </item>
29
+ <item>
30
+ <title>Rental Car</title>
31
+ <link>https://xkcd.com/1837/</link>
32
+ <description>&lt;img src="https://imgs.xkcd.com/comics/rental_car.png" title="Technically, both cars are haunted, but the murder ghosts can't stand listening to the broken GPS for more than a few minutes." alt="Technically, both cars are haunted, but the murder ghosts can't stand listening to the broken GPS for more than a few minutes." /&gt;</description>
33
+ <pubDate>Mon, 15 May 2017 04:00:00 -0000</pubDate>
34
+ <guid>https://xkcd.com/1837/</guid>
35
+ </item>
36
+ </channel>
37
+ </rss>
38
+
39
+ ---
40
+
41
+ feed.format: rss 2.0
42
+ feed.title: xkcd.com
43
+ feed.summary: xkcd.com: A webcomic of romance and math humor.
44
+ feed.url: https://xkcd.com/
45
+ feed.items.size: >>> 4
46
+
47
+ feed.items[0].title: Genetic Testing Results
48
+ feed.items[0].url: https://xkcd.com/1840/
49
+ feed.items[0].guid: https://xkcd.com/1840/
50
+ feed.items[0].updated: >>> DateTime.new( 2017, 5, 22, 4, 0 )
51
+
52
+ feed.items[1].title: Doctor Visit
53
+ feed.items[1].url: https://xkcd.com/1839/
54
+ feed.items[1].guid: https://xkcd.com/1839/
55
+ feed.items[1].updated: >>> DateTime.new( 2017, 5, 19, 4, 0 )
data/test/helper.rb CHANGED
@@ -43,7 +43,20 @@ class Test
43
43
  expr = line[0...pos].strip ## NOTE: do NOT include colon (thus, use tree dots ...)
44
44
  value = line[pos+1..-1].strip
45
45
 
46
- code="assert_equal '#{value}', #{expr}"
46
+
47
+ ## for ruby code use |> or >> or >>> or => or $ or | or RUN or ????
48
+ ## otherwise assume "literal" string
49
+
50
+ if value.start_with? '>>>'
51
+ value = value[3..-1].strip
52
+ code="assert_equal #{value}, #{expr}"
53
+ elsif value.start_with? 'DateTime' ## todo/fix: remove; use >>> style
54
+ code="assert_equal #{value}, #{expr}"
55
+ else # assume value is a "plain" string
56
+ ## note use %{ } so value can include quotes ('') etc.
57
+ code="assert_equal %{#{value}}, #{expr}"
58
+ end
59
+
47
60
  puts "eval #{code}"
48
61
  eval( code )
49
62
  end # each line
@@ -59,4 +72,3 @@ def fetch_and_parse_feed( url )
59
72
 
60
73
  FeedParser::Parser.parse( xml )
61
74
  end
62
-
@@ -0,0 +1,52 @@
1
+ ###
2
+ # to run use
3
+ # ruby -I ./lib -I ./test test/test_dates.rb
4
+ # or better
5
+ # rake test
6
+
7
+ require 'helper'
8
+
9
+
10
+ class TestDates < MiniTest::Test
11
+
12
+ def test_iso8601 # used by atom, json feed
13
+
14
+ recs = [
15
+ [ '2017-05-20T19:23:06Z', DateTime.new(2017, 5,20,19,23, 6) ], # from daringfireball.json
16
+ [ '2017-05-20T19:23:08Z', DateTime.new(2017, 5,20,19,23, 8) ],
17
+ [ '2017-05-17T08:02:12-07:00', DateTime.new(2017, 5,17, 8, 2,12,'-7') ], # from jsonfeed.json
18
+ [ '2017-05-18T21:08:49+00:00', DateTime.new(2017, 5,18,21, 8,49) ], # from byparker.json
19
+ [ '2017-05-18T21:08:49.123+00:00', DateTime.new(2017, 5,18,21, 8,49.123) ], ### try with usec e.g. 49.124
20
+ [ '2017-05-17T08:02:12.567-07:00', DateTime.new(2017, 5,17, 8, 2,12.567,'-7') ],
21
+ ]
22
+
23
+ recs.each do |rec|
24
+ d = DateTime.iso8601( rec[0] )
25
+ puts "class: #{d.class.name} - #{d.utc} (#{d.usec}) <= iso8601 #{rec[0]}"
26
+ pp d
27
+ assert_equal rec[1], d
28
+ end
29
+ end # test_iso8601
30
+
31
+
32
+ def test_rfc822 # used by rss 2.0
33
+
34
+ recs = [
35
+ [ 'Sat, 17 Jan 2015 11:57:47 +0000', DateTime.new( 2015, 1,17,11,57,47) ], # from sitepoint.rss2
36
+ [ 'Thu, 15 Jan 2015 15:00:56 +0000', DateTime.new( 2015, 1,15,15,00,56) ],
37
+ [ 'Fri, 16 Jan 2015 17:33:47 +0100', DateTime.new( 2015, 1,16,17,33,47,'+1') ], # from rubyflow.rss2
38
+ [ 'Fri, 16 Jan 2015 09:33:57 +0100', DateTime.new( 2015, 1,16, 9,33,57,'+1') ],
39
+ [ 'Wed, 17 Dec 2014 12:30:48 +0000', DateTime.new( 2014,12,17,12,30,48) ], # from rubymine.rss2
40
+ ]
41
+
42
+ recs.each do |rec|
43
+ d = DateTime.rfc822( rec[0] )
44
+ puts "class: #{d.class.name} - #{d.utc} (#{d.usec}) <= rfc822 #{rec[0]}"
45
+ pp d
46
+ assert_equal rec[1], d
47
+ end
48
+
49
+ end # test_rfc822
50
+
51
+
52
+ end # class TestDates
@@ -0,0 +1,27 @@
1
+ ###
2
+ # to run use
3
+ # ruby -I ./lib -I ./test test/test_feeds.rb
4
+ # or better
5
+ # rake test
6
+
7
+ require 'helper'
8
+
9
+
10
+ class TestFeeds < MiniTest::Test
11
+
12
+ def test_all
13
+ names = [
14
+ 'learnenough.atom',
15
+ 'xkcd.atom',
16
+ 'xkcd.rss2',
17
+ 'daringfireball.atom',
18
+ 'intertwingly.atom',
19
+ ]
20
+
21
+ names.each do |name|
22
+ assert_feed_tests_for( name )
23
+ end
24
+ end
25
+
26
+
27
+ end # class TestFeeds
data/test/test_json.rb CHANGED
@@ -13,6 +13,10 @@ class TestJson < MiniTest::Test
13
13
  names = [
14
14
  'jsonfeed.json',
15
15
  'byparker.json',
16
+ 'daringfireball.json',
17
+ 'inessential.json',
18
+ 'spec/json/example.json',
19
+ 'spec/json/microblog.json',
16
20
  ]
17
21
 
18
22
  names.each do |name|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-20 00:00:00.000000000 Z
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils
@@ -66,8 +66,8 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.16'
69
- description: feedparser - web feed parser and normalizer (RSS 2.0, Atom, etc.)
70
- email: feedreader@googlegroups.com
69
+ description: feedparser - web feed parser and normalizer (RSS 2.0, Atom, JSON, etc.)
70
+ email: wwwmake@googlegroups.com
71
71
  executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files:
@@ -88,23 +88,34 @@ files:
88
88
  - lib/feedparser/parser.rb
89
89
  - lib/feedparser/version.rb
90
90
  - test/feeds/byparker.json
91
+ - test/feeds/daringfireball.atom
92
+ - test/feeds/daringfireball.json
91
93
  - test/feeds/googlegroups.atom
92
94
  - test/feeds/googlegroups2.atom
93
95
  - test/feeds/headius.atom
96
+ - test/feeds/inessential.json
97
+ - test/feeds/intertwingly.atom
94
98
  - test/feeds/jsonfeed.json
95
99
  - test/feeds/lambdatheultimate.rss2
100
+ - test/feeds/learnenough.atom
96
101
  - test/feeds/railstutorial.atom
97
102
  - test/feeds/rubyflow.rss2
98
103
  - test/feeds/rubymine.rss2
99
104
  - test/feeds/rubyonrails.atom
100
105
  - test/feeds/sitepoint.rss2
106
+ - test/feeds/spec/json/example.json
107
+ - test/feeds/spec/json/microblog.json
108
+ - test/feeds/xkcd.atom
109
+ - test/feeds/xkcd.rss2
101
110
  - test/helper.rb
102
111
  - test/test_atom.rb
103
112
  - test/test_atom_live.rb
113
+ - test/test_dates.rb
114
+ - test/test_feeds.rb
104
115
  - test/test_json.rb
105
116
  - test/test_rss.rb
106
117
  - test/test_rss_live.rb
107
- homepage: https://github.com/feedreader/feed.parser
118
+ homepage: https://github.com/feedreader/feedparser
108
119
  licenses:
109
120
  - Public Domain
110
121
  metadata: {}
@@ -129,5 +140,5 @@ rubyforge_project:
129
140
  rubygems_version: 2.6.7
130
141
  signing_key:
131
142
  specification_version: 4
132
- summary: feedparser - web feed parser and normalizer (RSS 2.0, Atom, etc.)
143
+ summary: feedparser - web feed parser and normalizer (RSS 2.0, Atom, JSON, etc.)
133
144
  test_files: []