feedparser 2.1.2 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +1 -0
- data/Manifest.txt +2 -0
- data/Rakefile +3 -2
- data/lib/feedparser/attachment.rb +23 -17
- data/lib/feedparser/author.rb +39 -39
- data/lib/feedparser/builder/atom.rb +45 -5
- data/lib/feedparser/builder/json.rb +111 -111
- data/lib/feedparser/builder/microformats.rb +264 -264
- data/lib/feedparser/builder/rss.rb +43 -5
- data/lib/feedparser/generator.rb +36 -36
- data/lib/feedparser/parser.rb +4 -3
- data/lib/feedparser/tag.rb +23 -23
- data/lib/feedparser/thumbnail.rb +21 -0
- data/lib/feedparser/version.rb +2 -2
- data/lib/feedparser.rb +1 -0
- data/test/media_rss_example.txt +53 -0
- data/test/test_atom_live.rb +1 -1
- data/test/test_attachments_live.rb +69 -32
- data/test/test_dates.rb +52 -52
- data/test/test_microformats.rb +52 -52
- data/test/test_rss_live.rb +1 -1
- metadata +19 -12
data/lib/feedparser/parser.rb
CHANGED
@@ -28,7 +28,8 @@ class Parser
|
|
28
28
|
## check if starts with knownn xml prologs
|
29
29
|
@head.start_with?( '<?xml' ) ||
|
30
30
|
@head.start_with?( '<feed' ) ||
|
31
|
-
@head.start_with?( '<rss' )
|
31
|
+
@head.start_with?( '<rss' ) ||
|
32
|
+
@head.start_with?( '<rdf' ) # note - add support for rss 1.0 (aka rdf)
|
32
33
|
end
|
33
34
|
alias_method :xml?, :is_xml?
|
34
35
|
|
@@ -110,9 +111,9 @@ class Parser
|
|
110
111
|
logger.debug " feed.class=#{feed_wild.class.name}"
|
111
112
|
|
112
113
|
if feed_wild.is_a?( RSS::Atom::Feed )
|
113
|
-
feed = AtomFeedBuilder.build( feed_wild )
|
114
|
+
feed = AtomFeedBuilder.build( feed_wild, @text )
|
114
115
|
else # -- assume RSS::Rss::Feed
|
115
|
-
feed = RssFeedBuilder.build( feed_wild )
|
116
|
+
feed = RssFeedBuilder.build( feed_wild, @text )
|
116
117
|
end
|
117
118
|
|
118
119
|
logger.debug "== #{feed.format} / #{feed.title} =="
|
data/lib/feedparser/tag.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module FeedParser
|
4
|
-
|
5
|
-
class Tag
|
6
|
-
|
7
|
-
attr_accessor :name
|
8
|
-
## note: title n term are aliases for name
|
9
|
-
alias :title :name
|
10
|
-
alias :title= :name=
|
11
|
-
|
12
|
-
alias :term :name
|
13
|
-
alias :term= :name=
|
14
|
-
|
15
|
-
|
16
|
-
attr_accessor :scheme ## use scheme_url -why? why not? is it always a url/uri??
|
17
|
-
## note: domain (rss) is an alias for scheme (atom)
|
18
|
-
alias :domain :scheme
|
19
|
-
alias :domain= :scheme=
|
20
|
-
|
21
|
-
end # class Tag
|
22
|
-
|
23
|
-
end # module FeedParser
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module FeedParser
|
4
|
+
|
5
|
+
class Tag
|
6
|
+
|
7
|
+
attr_accessor :name
|
8
|
+
## note: title n term are aliases for name
|
9
|
+
alias :title :name
|
10
|
+
alias :title= :name=
|
11
|
+
|
12
|
+
alias :term :name
|
13
|
+
alias :term= :name=
|
14
|
+
|
15
|
+
|
16
|
+
attr_accessor :scheme ## use scheme_url -why? why not? is it always a url/uri??
|
17
|
+
## note: domain (rss) is an alias for scheme (atom)
|
18
|
+
alias :domain :scheme
|
19
|
+
alias :domain= :scheme=
|
20
|
+
|
21
|
+
end # class Tag
|
22
|
+
|
23
|
+
end # module FeedParser
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module FeedParser
|
4
|
+
|
5
|
+
class Thumbnail
|
6
|
+
|
7
|
+
attr_accessor :url
|
8
|
+
|
9
|
+
## note: uri is an alias for url
|
10
|
+
alias :uri :url ## add atom alias for uri - why? why not?
|
11
|
+
alias :uri= :url=
|
12
|
+
|
13
|
+
def width?() @width.nil? == false; end
|
14
|
+
attr_accessor :width
|
15
|
+
|
16
|
+
def height?() @height.nil? == false; end
|
17
|
+
attr_accessor :height # todo/check: use avatar_url ?? used by json feed -check if always a url
|
18
|
+
|
19
|
+
end # class Thumbnail
|
20
|
+
|
21
|
+
end # module FeedParser
|
data/lib/feedparser/version.rb
CHANGED
data/lib/feedparser.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
|
3
|
+
<channel>
|
4
|
+
<title>Calm Meditation</title>
|
5
|
+
<link>http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com</link>
|
6
|
+
<language>en-us</language>
|
7
|
+
<pubDate>Mon, 02 Apr 2018 16:19:56 -0700</pubDate>
|
8
|
+
<lastBuildDate>Mon, 02 Apr 2018 16:19:56 -0700</lastBuildDate>
|
9
|
+
<managingEditor>tomjoht@gmail.com (Tom Johnson)</managingEditor>
|
10
|
+
<description>Contains short videos capturing still scenes from nature with a music background, intended for calming or meditation purposes. When you're stressed out or upset, watch a few videos. As your mind focuses on the small details, let your worries and frustrations float away. The purpose is not to entertain or to distract, but to help calm, soothe, and surface your inner quiet. The videos contain scenes from the San Tomas Aquinas trail in Santa Clara, California.</description>
|
11
|
+
<image>
|
12
|
+
<link>http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com</link>
|
13
|
+
<title>Calm Meditation</title>
|
14
|
+
<url>http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com/images/calmmeditationlogo_small.png</url>
|
15
|
+
<description>Contains short videos capturing still scenes from nature with a music background, intended for calming or meditation purposes. When you're stressed out or upset, watch a few videos. As your mind focuses on the small details, let your worries and frustrations float away. The purpose is not to entertain or to distract, but to help calm, soothe, and surface your inner quiet. The videos contain scenes from the San Tomas Aquinas trail in Santa Clara, California.</description>
|
16
|
+
<height>114</height>
|
17
|
+
<width>114</width>
|
18
|
+
</image>
|
19
|
+
<atom:link href="http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com/feed.xml" rel="self" type="application/rss+xml" />
|
20
|
+
<item>
|
21
|
+
<title>Shade</title>
|
22
|
+
<pubDate>Mon, 23 Oct 2017 00:00:00 -0700</pubDate>
|
23
|
+
<link>http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com/shade/</link>
|
24
|
+
<description>Quiet the mind, and the soul will speak. - Ma Jaya Sati Bhagavati</description>
|
25
|
+
<guid isPermaLink="false">http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com/shade/</guid>
|
26
|
+
<media:category>All</media:category>
|
27
|
+
<media:category>Trail</media:category>
|
28
|
+
<media:content url="http://d1nixf144dcz0j.cloudfront.net/shade.mp4" language="en-us" fileSize="37000000" duration="120.0" medium="video" isDefault="true">
|
29
|
+
<media:title type="plain">Shade</media:title>
|
30
|
+
<media:description type="html">Quiet the mind, and the soul will speak. - Ma Jaya Sati Bhagavati</media:description>
|
31
|
+
<media:thumbnail url="http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com/images/thumbs/shade.jpg" />
|
32
|
+
<media:credit role="author" scheme="urn:ebu">Tom Johnson</media:credit>
|
33
|
+
<media:copyright url="https://creativecommons.org/licenses/by/4.0/" />
|
34
|
+
</media:content>
|
35
|
+
</item>
|
36
|
+
<item>
|
37
|
+
<title>Spectators</title>
|
38
|
+
<pubDate>Thu, 12 Oct 2017 00:00:00 -0700</pubDate>
|
39
|
+
<link>http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com/spectators/</link>
|
40
|
+
<description>"Your worst enemy cannot harm you as much as your own thoughts, unguarded." – Buddha</description>
|
41
|
+
<guid isPermaLink="false">http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com/spectators/</guid>
|
42
|
+
<media:category>All</media:category>
|
43
|
+
<media:category>Grass</media:category>
|
44
|
+
<media:content url="http://d1nixf144dcz0j.cloudfront.net/spectators.mp4" language="en-us" fileSize="19000000" duration="120.0" medium="video" isDefault="true">
|
45
|
+
<media:title type="plain">Spectators</media:title>
|
46
|
+
<media:description type="html">"Your worst enemy cannot harm you as much as your own thoughts, unguarded." – Buddha</media:description>
|
47
|
+
<media:thumbnail url="http://sample-firetv-web-app.s3-website-us-west-2.amazonaws.com/images/thumbs/spectators.jpg" />
|
48
|
+
<media:credit role="author" scheme="urn:ebu">Tom Johnson</media:credit>
|
49
|
+
<media:copyright url="https://creativecommons.org/licenses/by/4.0/" />
|
50
|
+
</media:content>
|
51
|
+
</item>
|
52
|
+
</channel>
|
53
|
+
</rss>
|
data/test/test_atom_live.rb
CHANGED
@@ -1,32 +1,69 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_attachments_live.rb
|
4
|
-
# or better
|
5
|
-
# rake test
|
6
|
-
|
7
|
-
require 'helper'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
assert_equal
|
26
|
-
assert_equal
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
1
|
+
###
|
2
|
+
# to run use
|
3
|
+
# ruby -I ./lib -I ./test test/test_attachments_live.rb
|
4
|
+
# or better
|
5
|
+
# rake test
|
6
|
+
|
7
|
+
require 'helper'
|
8
|
+
|
9
|
+
|
10
|
+
###
|
11
|
+
## note: needs to require oga gem (it's not required by default - it's a "soft" dependency)
|
12
|
+
|
13
|
+
require 'oga'
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
class TestAttachmentsLive < Minitest::Test
|
18
|
+
|
19
|
+
def test_atom_enclose
|
20
|
+
feed = fetch_and_parse_feed( 'http://www.lse.ac.uk/assets/richmedia/webFeeds/publicLecturesAndEvents_AtomAllMediaTypesLatest100.xml' )
|
21
|
+
|
22
|
+
assert_equal 'audio/mpeg', feed.items.first.attachment.type
|
23
|
+
assert_equal 'audio/mpeg', feed.items.first.enclosure.type
|
24
|
+
|
25
|
+
assert_equal true, feed.items.first.attachment?
|
26
|
+
assert_equal true, feed.items.first.enclosure?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_atom_media
|
30
|
+
feed = fetch_and_parse_feed( 'http://www.youtube.com/feeds/videos.xml?channel_id=UCZUT79WUUpZlZ-XMF7l4CFg' )
|
31
|
+
assert_equal true, feed.items.first.attachment?
|
32
|
+
assert feed.items.first.attachments.first.title
|
33
|
+
assert feed.items.first.attachments.first.url
|
34
|
+
assert feed.items.first.attachments.first.thumbnail
|
35
|
+
assert_instance_of FeedParser::Thumbnail, feed.items.first.attachments.first.thumbnail
|
36
|
+
assert feed.items.first.attachments.first.thumbnail.url
|
37
|
+
assert_equal 480, feed.items.first.attachments.first.thumbnail.width.to_i
|
38
|
+
assert_equal 360, feed.items.first.attachments.first.thumbnail.height.to_i
|
39
|
+
assert feed.items.first.attachments.first.description
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_rss_media
|
43
|
+
# tests an example RSS file from https://creator.amazon.com/documentation/ac/mrss.html. Not that unlike the Atom example, it does
|
44
|
+
# does not put everything under media:group
|
45
|
+
testpath = File.join(File.expand_path(File.dirname(__FILE__)), 'media_rss_example.txt')
|
46
|
+
feed_rss = File.read( testpath )
|
47
|
+
feed = FeedParser::Parser.parse( feed_rss )
|
48
|
+
assert_equal true, feed.items.first.attachment?
|
49
|
+
assert feed.items.first.attachments.first.title
|
50
|
+
assert feed.items.first.attachments.first.url
|
51
|
+
assert feed.items.first.attachments.first.thumbnail
|
52
|
+
assert_instance_of FeedParser::Thumbnail, feed.items.first.attachments.first.thumbnail
|
53
|
+
assert feed.items.first.attachments.first.thumbnail.url
|
54
|
+
assert_nil feed.items.first.attachments.first.thumbnail.width
|
55
|
+
assert_nil feed.items.first.attachments.first.thumbnail.height
|
56
|
+
assert feed.items.first.attachments.first.description
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_rss_enclosure
|
60
|
+
feed = fetch_and_parse_feed( 'http://www.radiofreesatan.com/category/featured/feed/' )
|
61
|
+
|
62
|
+
assert_equal 'audio/mpeg', feed.items.first.attachment.type
|
63
|
+
assert_equal 'audio/mpeg', feed.items.first.enclosure.type
|
64
|
+
|
65
|
+
assert_equal true, feed.items.first.attachment?
|
66
|
+
assert_equal true, feed.items.first.enclosure?
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
data/test/test_dates.rb
CHANGED
@@ -1,52 +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 <
|
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
|
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
|
data/test/test_microformats.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_microformats.rb
|
4
|
-
# or better
|
5
|
-
# rake test
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
###
|
12
|
-
## note: needs to require microformats gem (it's not required by default)
|
13
|
-
|
14
|
-
require 'microformats'
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
class TestMicroformats <
|
19
|
-
|
20
|
-
def test_hentry
|
21
|
-
|
22
|
-
text =<<HTML
|
23
|
-
<article class="h-entry">
|
24
|
-
<h1 class="p-name">Microformats are amazing</h1>
|
25
|
-
<p>Published by
|
26
|
-
<a class="p-author h-card" href="http://example.com">W. Developer</a>
|
27
|
-
on <time class="dt-published" datetime="2013-06-13 12:00:00">13<sup>th</sup> June 2013</time>
|
28
|
-
|
29
|
-
<p class="p-summary">In which I extoll the virtues of using microformats.</p>
|
30
|
-
|
31
|
-
<div class="e-content">
|
32
|
-
<p>Blah blah blah</p>
|
33
|
-
</div>
|
34
|
-
</article>
|
35
|
-
HTML
|
36
|
-
|
37
|
-
feed = FeedParser::Parser.parse( text )
|
38
|
-
|
39
|
-
assert_equal 'html', feed.format
|
40
|
-
assert_equal 1, feed.items.size
|
41
|
-
assert_equal 1, feed.items[0].authors.size
|
42
|
-
assert_equal '<p>Blah blah blah</p>', feed.items[0].content_html
|
43
|
-
assert_equal 'Blah blah blah', feed.items[0].content_text
|
44
|
-
assert_equal 'Microformats are amazing', feed.items[0].title
|
45
|
-
assert_equal 'In which I extoll the virtues of using microformats.', feed.items[0].summary
|
46
|
-
assert_equal DateTime.new( 2013, 6, 13, 12, 0, 0 ).utc, feed.items[0].published
|
47
|
-
|
48
|
-
assert_equal 'W. Developer', feed.items[0].authors[0].name
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
end # class TestMicroformats
|
1
|
+
###
|
2
|
+
# to run use
|
3
|
+
# ruby -I ./lib -I ./test test/test_microformats.rb
|
4
|
+
# or better
|
5
|
+
# rake test
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
###
|
12
|
+
## note: needs to require microformats gem (it's not required by default)
|
13
|
+
|
14
|
+
require 'microformats'
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
class TestMicroformats < Minitest::Test
|
19
|
+
|
20
|
+
def test_hentry
|
21
|
+
|
22
|
+
text =<<HTML
|
23
|
+
<article class="h-entry">
|
24
|
+
<h1 class="p-name">Microformats are amazing</h1>
|
25
|
+
<p>Published by
|
26
|
+
<a class="p-author h-card" href="http://example.com">W. Developer</a>
|
27
|
+
on <time class="dt-published" datetime="2013-06-13 12:00:00">13<sup>th</sup> June 2013</time>
|
28
|
+
|
29
|
+
<p class="p-summary">In which I extoll the virtues of using microformats.</p>
|
30
|
+
|
31
|
+
<div class="e-content">
|
32
|
+
<p>Blah blah blah</p>
|
33
|
+
</div>
|
34
|
+
</article>
|
35
|
+
HTML
|
36
|
+
|
37
|
+
feed = FeedParser::Parser.parse( text )
|
38
|
+
|
39
|
+
assert_equal 'html', feed.format
|
40
|
+
assert_equal 1, feed.items.size
|
41
|
+
assert_equal 1, feed.items[0].authors.size
|
42
|
+
assert_equal '<p>Blah blah blah</p>', feed.items[0].content_html
|
43
|
+
assert_equal 'Blah blah blah', feed.items[0].content_text
|
44
|
+
assert_equal 'Microformats are amazing', feed.items[0].title
|
45
|
+
assert_equal 'In which I extoll the virtues of using microformats.', feed.items[0].summary
|
46
|
+
assert_equal DateTime.new( 2013, 6, 13, 12, 0, 0 ).utc, feed.items[0].published
|
47
|
+
|
48
|
+
assert_equal 'W. Developer', feed.items[0].authors[0].name
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end # class TestMicroformats
|
data/test/test_rss_live.rb
CHANGED
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: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logutils
|
@@ -42,33 +42,39 @@ dependencies:
|
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '7'
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '4.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '7'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: hoe
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '4.2'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
74
|
+
version: '4.2'
|
69
75
|
description: feedparser - web feed parser and normalizer (RSS, Atom, JSON Feed, HTML
|
70
76
|
h-entry, etc.)
|
71
|
-
email:
|
77
|
+
email: gerald.bauer@gmail.com
|
72
78
|
executables: []
|
73
79
|
extensions: []
|
74
80
|
extra_rdoc_files:
|
@@ -92,8 +98,10 @@ files:
|
|
92
98
|
- lib/feedparser/item.rb
|
93
99
|
- lib/feedparser/parser.rb
|
94
100
|
- lib/feedparser/tag.rb
|
101
|
+
- lib/feedparser/thumbnail.rb
|
95
102
|
- lib/feedparser/version.rb
|
96
103
|
- test/helper.rb
|
104
|
+
- test/media_rss_example.txt
|
97
105
|
- test/test_atom_live.rb
|
98
106
|
- test/test_attachments_live.rb
|
99
107
|
- test/test_dates.rb
|
@@ -103,7 +111,7 @@ homepage: https://github.com/feedparser/feedparser
|
|
103
111
|
licenses:
|
104
112
|
- Public Domain
|
105
113
|
metadata: {}
|
106
|
-
post_install_message:
|
114
|
+
post_install_message:
|
107
115
|
rdoc_options:
|
108
116
|
- "--main"
|
109
117
|
- README.md
|
@@ -120,9 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
128
|
- !ruby/object:Gem::Version
|
121
129
|
version: '0'
|
122
130
|
requirements: []
|
123
|
-
|
124
|
-
|
125
|
-
signing_key:
|
131
|
+
rubygems_version: 3.5.22
|
132
|
+
signing_key:
|
126
133
|
specification_version: 4
|
127
134
|
summary: feedparser - web feed parser and normalizer (RSS, Atom, JSON Feed, HTML h-entry,
|
128
135
|
etc.)
|