feed-normalizer 1.0.0 → 1.0.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.
- data/Rakefile +1 -1
- data/lib/structures.rb +29 -2
- data/test/base_test.rb +7 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ task :package => [:test, :doc]
|
|
16
16
|
|
17
17
|
spec = Gem::Specification.new do |s|
|
18
18
|
s.name = "feed-normalizer"
|
19
|
-
s.version = "1.0.
|
19
|
+
s.version = "1.0.1"
|
20
20
|
s.author = "Andrew A. Smith"
|
21
21
|
s.email = "andy@tinnedfruit.org"
|
22
22
|
s.homepage = "http://code.google.com/p/feed-normalizer/"
|
data/lib/structures.rb
CHANGED
@@ -19,6 +19,21 @@ module FeedNormalizer
|
|
19
19
|
end
|
20
20
|
nil
|
21
21
|
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
module ElementEquality
|
26
|
+
|
27
|
+
def eql?(other)
|
28
|
+
self == (other)
|
29
|
+
end
|
30
|
+
|
31
|
+
def ==(other)
|
32
|
+
other.equal?(self) ||
|
33
|
+
(other.instance_of?(self.class) &&
|
34
|
+
self.class::ELEMENTS.collect{|el| instance_variable_get("@#{el}")==other.instance_variable_get("@#{el}")}.all?)
|
35
|
+
end
|
36
|
+
|
22
37
|
end
|
23
38
|
|
24
39
|
# Wraps content used in an Entry. type defaults to :text.
|
@@ -33,11 +48,22 @@ module FeedNormalizer
|
|
33
48
|
def to_s
|
34
49
|
body
|
35
50
|
end
|
51
|
+
|
52
|
+
def eql?(other)
|
53
|
+
self == (other)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Equal if the body is the same. Ignores type.
|
57
|
+
def ==(other)
|
58
|
+
other.equal?(self) ||
|
59
|
+
(other.instance_of?(self.class) &&
|
60
|
+
other.body == other.body)
|
61
|
+
end
|
36
62
|
end
|
37
63
|
|
38
64
|
# Represents a feed item entry.
|
39
65
|
class Entry
|
40
|
-
include Singular
|
66
|
+
include Singular, ElementEquality
|
41
67
|
|
42
68
|
ELEMENTS = [:content, :date_published, :urls, :description, :title, :id, :authors, :copyright]
|
43
69
|
attr_accessor *ELEMENTS
|
@@ -47,11 +73,12 @@ module FeedNormalizer
|
|
47
73
|
@authors = []
|
48
74
|
@content = Content.new
|
49
75
|
end
|
76
|
+
|
50
77
|
end
|
51
78
|
|
52
79
|
# Represents the root element of a feed.
|
53
80
|
class Feed
|
54
|
-
include Singular
|
81
|
+
include Singular, ElementEquality
|
55
82
|
|
56
83
|
ELEMENTS = [:title, :description, :id, :last_updated, :copyright, :authors, :urls, :image, :generator, :items]
|
57
84
|
attr_accessor *ELEMENTS
|
data/test/base_test.rb
CHANGED
@@ -65,4 +65,11 @@ class BaseTest < Test::Unit::TestCase
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
def test_feed_equality
|
69
|
+
assert_equal FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rss20]), FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rss20])
|
70
|
+
assert_equal FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom10]), FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom10])
|
71
|
+
assert_not_equal FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom03]), FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom10])
|
72
|
+
assert_not_equal FeedNormalizer::FeedNormalizer.parse(XML_FILES[:rss20]), FeedNormalizer::FeedNormalizer.parse(XML_FILES[:atom10])
|
73
|
+
end
|
74
|
+
|
68
75
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: feed-normalizer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2006-10-
|
6
|
+
version: 1.0.1
|
7
|
+
date: 2006-10-04 00:00:00 -07:00
|
8
8
|
summary: Extensible Ruby wrapper for Atom and RSS parsers
|
9
9
|
require_paths:
|
10
10
|
- lib
|