feed-normalizer 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Rakefile +1 -1
- data/lib/parsers/rss.rb +3 -3
- data/lib/parsers/simple-rss.rb +4 -4
- data/lib/structures.rb +1 -1
- data/test/test_feednormalizer.rb +39 -5
- metadata +11 -7
data/History.txt
CHANGED
data/Rakefile
CHANGED
data/lib/parsers/rss.rb
CHANGED
@@ -36,7 +36,7 @@ module FeedNormalizer
|
|
36
36
|
:description => :description,
|
37
37
|
:copyright => :copyright,
|
38
38
|
:authors => :managingEditor,
|
39
|
-
:last_updated => [:lastBuildDate, :pubDate],
|
39
|
+
:last_updated => [:lastBuildDate, :pubDate, :dc_date],
|
40
40
|
:id => :guid
|
41
41
|
}
|
42
42
|
|
@@ -49,12 +49,12 @@ module FeedNormalizer
|
|
49
49
|
|
50
50
|
# item elements
|
51
51
|
item_mapping = {
|
52
|
-
:date_published => :pubDate,
|
52
|
+
:date_published => [:pubDate, :dc_date],
|
53
53
|
:urls => :link,
|
54
54
|
:description => :description,
|
55
55
|
:content => :description,
|
56
56
|
:title => :title,
|
57
|
-
:authors => :author
|
57
|
+
:authors => [:author, :dc_creator]
|
58
58
|
}
|
59
59
|
|
60
60
|
rss.items.each do |rss_item|
|
data/lib/parsers/simple-rss.rb
CHANGED
@@ -34,7 +34,7 @@ module FeedNormalizer
|
|
34
34
|
feed_mapping = {
|
35
35
|
:generator => :generator,
|
36
36
|
:title => :title,
|
37
|
-
:last_updated => [:updated, :lastBuildDate, :pubDate],
|
37
|
+
:last_updated => [:updated, :lastBuildDate, :pubDate, :dc_date],
|
38
38
|
:copyright => [:copyright, :rights],
|
39
39
|
:authors => [:author, :webMaster, :managingEditor, :contributor],
|
40
40
|
:urls => :link,
|
@@ -50,12 +50,12 @@ module FeedNormalizer
|
|
50
50
|
|
51
51
|
# entry elements
|
52
52
|
entry_mapping = {
|
53
|
-
:date_published => [:pubDate, :published],
|
53
|
+
:date_published => [:pubDate, :published, :dc_date],
|
54
54
|
:urls => :link,
|
55
55
|
:description => [:description, :summary],
|
56
56
|
:content => [:content, :description],
|
57
57
|
:title => :title,
|
58
|
-
:authors => [:author, :contributor]
|
58
|
+
:authors => [:author, :contributor, :dc_creator]
|
59
59
|
}
|
60
60
|
|
61
61
|
atomrss.entries.each do |atomrss_entry|
|
@@ -85,7 +85,7 @@ module FeedNormalizer
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def self.feed_id(parser)
|
88
|
-
overridden_value(parser, :id) || "#{parser.link}"
|
88
|
+
overridden_value(parser, :id) || ("#{parser.link}" if parser.respond_to?(:link))
|
89
89
|
end
|
90
90
|
|
91
91
|
# gets the value returned from the method if it overriden, otherwise nil.
|
data/lib/structures.rb
CHANGED
data/test/test_feednormalizer.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'feed-normalizer'
|
3
|
+
require 'yaml'
|
3
4
|
|
4
5
|
include FeedNormalizer
|
5
6
|
|
@@ -44,7 +45,7 @@ class FeedNormalizerTest < Test::Unit::TestCase
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def test_parser_failover_order
|
47
|
-
assert_equal SimpleRSS, FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom10], :force_parser => RubyRssParser).parser
|
48
|
+
assert_equal 'SimpleRSS', FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom10], :force_parser => RubyRssParser).parser
|
48
49
|
end
|
49
50
|
|
50
51
|
def test_force_parser_fail
|
@@ -56,8 +57,8 @@ class FeedNormalizerTest < Test::Unit::TestCase
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def test_correct_parser_used
|
59
|
-
assert_equal RSS::Parser, FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rss20]).parser
|
60
|
-
assert_equal SimpleRSS, FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom10]).parser
|
60
|
+
assert_equal 'RSS::Parser', FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rss20]).parser
|
61
|
+
assert_equal 'SimpleRSS', FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom10]).parser
|
61
62
|
end
|
62
63
|
|
63
64
|
def test_rss
|
@@ -68,6 +69,7 @@ class FeedNormalizerTest < Test::Unit::TestCase
|
|
68
69
|
assert_equal "MP3 player court order overturned", feed.entries.last.title
|
69
70
|
assert_equal "SanDisk puts its MP3 players back on display at a German electronics show after overturning a court injunction.", feed.entries.last.description
|
70
71
|
assert_equal "SanDisk puts its MP3 players back on display at a German electronics show after overturning a court injunction.", feed.entries.last.content
|
72
|
+
assert_instance_of Time, feed.entries.last.date_published
|
71
73
|
end
|
72
74
|
|
73
75
|
def test_simplerss
|
@@ -86,8 +88,7 @@ class FeedNormalizerTest < Test::Unit::TestCase
|
|
86
88
|
XML_FILES.keys.each do |xml_file|
|
87
89
|
feed = FeedNormalizer::FeedNormalizer.parse(XML_FILES[xml_file])
|
88
90
|
|
89
|
-
assert [feed.title, feed.url, feed.entries.first.url].collect{|e| e.is_a?(String)}.all?, "Not everything was a String in #{xml_file}"
|
90
|
-
assert [feed.parser, feed.class].collect{|e| e.is_a?(Class)}.all?
|
91
|
+
assert [feed.parser, feed.title, feed.url, feed.entries.first.url].collect{|e| e.is_a?(String)}.all?, "Not everything was a String in #{xml_file}"
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
@@ -121,6 +122,11 @@ class FeedNormalizerTest < Test::Unit::TestCase
|
|
121
122
|
assert_nothing_raised { Marshal.load(Marshal.dump(feed)) }
|
122
123
|
end
|
123
124
|
|
125
|
+
def test_yaml
|
126
|
+
feed = FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rss20])
|
127
|
+
assert_nothing_raised { YAML.load(YAML.dump(feed)) }
|
128
|
+
end
|
129
|
+
|
124
130
|
def test_method_missing
|
125
131
|
assert_raise(NoMethodError) { Feed.new(nil).nonexistant }
|
126
132
|
end
|
@@ -133,5 +139,33 @@ class FeedNormalizerTest < Test::Unit::TestCase
|
|
133
139
|
assert feed.entries.first.content =~ /\<p\>/
|
134
140
|
end
|
135
141
|
|
142
|
+
def test_malformed_feed
|
143
|
+
assert_nothing_raised { FeedNormalizer::FeedNormalizer.parse('<feed></feed>') }
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_dublin_core_date_ruby_rss
|
147
|
+
feed = FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rdf10], :force_parser => RubyRssParser)
|
148
|
+
assert_equal 'RSS::Parser', feed.parser
|
149
|
+
assert_instance_of Time, feed.entries.first.date_published
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_dublin_core_date_simple_rss
|
153
|
+
feed = FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rdf10], :force_parser => SimpleRssParser)
|
154
|
+
assert_equal 'SimpleRSS', feed.parser
|
155
|
+
assert_instance_of Time, feed.entries.first.date_published
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_dublin_core_creator_ruby_rss
|
159
|
+
feed = FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rdf10], :force_parser => RubyRssParser)
|
160
|
+
assert_equal 'RSS::Parser', feed.parser
|
161
|
+
assert_equal 'Jeff Hecht', feed.entries.last.author
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_dublin_core_creator_simple_rss
|
165
|
+
feed = FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rdf10], :force_parser => SimpleRssParser)
|
166
|
+
assert_equal 'SimpleRSS', feed.parser
|
167
|
+
assert_equal 'Jeff Hecht', feed.entries.last.author
|
168
|
+
end
|
169
|
+
|
136
170
|
end
|
137
171
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: feed-normalizer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.3.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.3.2
|
7
|
+
date: 2007-07-02 00:00:00 -07:00
|
8
8
|
summary: Extensible Ruby wrapper for Atom and RSS parsers
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -50,10 +50,14 @@ files:
|
|
50
50
|
- test/test_htmlcleaner.rb
|
51
51
|
test_files:
|
52
52
|
- test/test_all.rb
|
53
|
-
rdoc_options:
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
rdoc_options:
|
54
|
+
- --main
|
55
|
+
- README.txt
|
56
|
+
extra_rdoc_files:
|
57
|
+
- History.txt
|
58
|
+
- License.txt
|
59
|
+
- Manifest.txt
|
60
|
+
- Readme.txt
|
57
61
|
executables: []
|
58
62
|
|
59
63
|
extensions: []
|
@@ -86,5 +90,5 @@ dependencies:
|
|
86
90
|
requirements:
|
87
91
|
- - ">="
|
88
92
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.2.
|
93
|
+
version: 1.2.1
|
90
94
|
version:
|