rss 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +38 -0
- data/README.md +11 -11
- data/lib/rss/itunes.rb +10 -1
- data/lib/rss/maker/itunes.rb +2 -0
- data/lib/rss/rss.rb +43 -15
- data/lib/rss/utils.rb +0 -18
- data/lib/rss/version.rb +1 -1
- data/lib/rss/xml-stylesheet.rb +3 -4
- data/lib/rss/xml.rb +3 -2
- data/lib/rss.rb +11 -11
- metadata +7 -101
- data/Gemfile +0 -6
- data/Rakefile +0 -15
- data/rss.gemspec +0 -30
- data/test/dot.png +0 -0
- data/test/rss-assertions.rb +0 -2116
- data/test/rss-testcase.rb +0 -479
- data/test/run-test.rb +0 -15
- data/test/test_1.0.rb +0 -308
- data/test/test_2.0.rb +0 -412
- data/test/test_accessor.rb +0 -104
- data/test/test_atom.rb +0 -684
- data/test/test_content.rb +0 -105
- data/test/test_dublincore.rb +0 -270
- data/test/test_image.rb +0 -215
- data/test/test_inherit.rb +0 -41
- data/test/test_itunes.rb +0 -360
- data/test/test_maker_0.9.rb +0 -477
- data/test/test_maker_1.0.rb +0 -519
- data/test/test_maker_2.0.rb +0 -758
- data/test/test_maker_atom_entry.rb +0 -394
- data/test/test_maker_atom_feed.rb +0 -455
- data/test/test_maker_content.rb +0 -48
- data/test/test_maker_dc.rb +0 -150
- data/test/test_maker_image.rb +0 -63
- data/test/test_maker_itunes.rb +0 -488
- data/test/test_maker_slash.rb +0 -38
- data/test/test_maker_sy.rb +0 -45
- data/test/test_maker_taxo.rb +0 -82
- data/test/test_maker_trackback.rb +0 -42
- data/test/test_maker_xml-stylesheet.rb +0 -84
- data/test/test_parser.rb +0 -122
- data/test/test_parser_1.0.rb +0 -529
- data/test/test_parser_2.0.rb +0 -123
- data/test/test_parser_atom_entry.rb +0 -164
- data/test/test_parser_atom_feed.rb +0 -277
- data/test/test_setup_maker_0.9.rb +0 -247
- data/test/test_setup_maker_1.0.rb +0 -551
- data/test/test_setup_maker_2.0.rb +0 -309
- data/test/test_setup_maker_atom_entry.rb +0 -410
- data/test/test_setup_maker_atom_feed.rb +0 -446
- data/test/test_setup_maker_itunes.rb +0 -146
- data/test/test_setup_maker_slash.rb +0 -39
- data/test/test_slash.rb +0 -65
- data/test/test_syndication.rb +0 -126
- data/test/test_taxonomy.rb +0 -173
- data/test/test_to_s.rb +0 -701
- data/test/test_trackback.rb +0 -136
- data/test/test_xml-stylesheet.rb +0 -109
data/test/test_syndication.rb
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require "cgi"
|
3
|
-
require "rexml/document"
|
4
|
-
|
5
|
-
require_relative "rss-testcase"
|
6
|
-
|
7
|
-
require "rss/1.0"
|
8
|
-
require "rss/syndication"
|
9
|
-
|
10
|
-
module RSS
|
11
|
-
class TestSyndication < TestCase
|
12
|
-
|
13
|
-
def setup
|
14
|
-
@prefix = "sy"
|
15
|
-
@uri = "http://purl.org/rss/1.0/modules/syndication/"
|
16
|
-
|
17
|
-
@parents = %w(channel)
|
18
|
-
|
19
|
-
t = Time.iso8601("2000-01-01T12:00:05+00:00")
|
20
|
-
class << t
|
21
|
-
alias_method(:to_s, :iso8601)
|
22
|
-
end
|
23
|
-
|
24
|
-
@elems = {
|
25
|
-
:updatePeriod => "hourly",
|
26
|
-
:updateFrequency => "2",
|
27
|
-
:updateBase => t,
|
28
|
-
}
|
29
|
-
|
30
|
-
@sy_nodes = @elems.collect do |name, value|
|
31
|
-
"<#{@prefix}:#{name}>#{CGI.escapeHTML(value.to_s)}</#{@prefix}:#{name}>"
|
32
|
-
end.join("\n")
|
33
|
-
|
34
|
-
@rss_source = make_RDF(<<-EOR, {@prefix => @uri})
|
35
|
-
#{make_channel(@sy_nodes)}
|
36
|
-
#{make_image()}
|
37
|
-
#{make_item()}
|
38
|
-
#{make_textinput()}
|
39
|
-
EOR
|
40
|
-
|
41
|
-
@rss = Parser.parse(@rss_source)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_parser
|
45
|
-
|
46
|
-
assert_nothing_raised do
|
47
|
-
Parser.parse(@rss_source)
|
48
|
-
end
|
49
|
-
|
50
|
-
@elems.each do |tag, value|
|
51
|
-
assert_too_much_tag(tag.to_s, "channel") do
|
52
|
-
Parser.parse(make_RDF(<<-EOR, {@prefix => @uri}))
|
53
|
-
#{make_channel(("<" + @prefix + ":" + tag.to_s + ">" +
|
54
|
-
CGI.escapeHTML(value.to_s) +
|
55
|
-
"</" + @prefix + ":" + tag.to_s + ">") * 2)}
|
56
|
-
#{make_item}
|
57
|
-
EOR
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_accessor
|
64
|
-
|
65
|
-
t = Time.iso8601("2003-01-01T12:00:23+09:00")
|
66
|
-
class << t
|
67
|
-
alias_method(:to_s, :iso8601)
|
68
|
-
end
|
69
|
-
|
70
|
-
new_value = {
|
71
|
-
:updatePeriod => "daily",
|
72
|
-
:updateFrequency => "11",
|
73
|
-
:updateBase => t,
|
74
|
-
}
|
75
|
-
|
76
|
-
@elems.each do |name, value|
|
77
|
-
value = value.to_i if name == :updateFrequency
|
78
|
-
@parents.each do |parent|
|
79
|
-
assert_equal(value, @rss.__send__(parent).__send__("sy_#{name}"))
|
80
|
-
@rss.__send__(parent).__send__("sy_#{name}=", new_value[name])
|
81
|
-
new_val = new_value[name]
|
82
|
-
new_val = new_val.to_i if name == :updateFrequency
|
83
|
-
assert_equal(new_val, @rss.__send__(parent).__send__("sy_#{name}"))
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
%w(hourly daily weekly monthly yearly).each do |x|
|
88
|
-
@parents.each do |parent|
|
89
|
-
assert_nothing_raised do
|
90
|
-
@rss.__send__(parent).sy_updatePeriod = x
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
%w(-2 0.3 -0.4).each do |x|
|
96
|
-
@parents.each do |parent|
|
97
|
-
assert_not_available_value("sy:updateBase", x) do
|
98
|
-
@rss.__send__(parent).sy_updateBase = x
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_to_s
|
106
|
-
|
107
|
-
@elems.each do |name, value|
|
108
|
-
excepted = "<#{@prefix}:#{name}>#{value}</#{@prefix}:#{name}>"
|
109
|
-
@parents.each do |parent|
|
110
|
-
assert_equal(excepted,
|
111
|
-
@rss.__send__(parent).__send__("sy_#{name}_element"))
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
REXML::Document.new(@rss_source).root.each_element do |parent|
|
116
|
-
if @parents.include?(parent.name)
|
117
|
-
parent.each_element do |elem|
|
118
|
-
if elem.namespace == @uri
|
119
|
-
assert_equal(elem.text, @elems[elem.name.intern].to_s)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
data/test/test_taxonomy.rb
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require "cgi"
|
3
|
-
|
4
|
-
require_relative "rss-testcase"
|
5
|
-
|
6
|
-
require "rss/1.0"
|
7
|
-
require "rss/2.0"
|
8
|
-
require "rss/taxonomy"
|
9
|
-
|
10
|
-
module RSS
|
11
|
-
class TestTaxonomy < TestCase
|
12
|
-
|
13
|
-
def setup
|
14
|
-
@prefix = "taxo"
|
15
|
-
@uri = "http://purl.org/rss/1.0/modules/taxonomy/"
|
16
|
-
@dc_prefix = "dc"
|
17
|
-
@dc_uri = "http://purl.org/dc/elements/1.1/"
|
18
|
-
|
19
|
-
@ns = {
|
20
|
-
@prefix => @uri,
|
21
|
-
@dc_prefix => @dc_uri,
|
22
|
-
}
|
23
|
-
|
24
|
-
@topics_parents = %w(channel item)
|
25
|
-
|
26
|
-
@topics_lis = [
|
27
|
-
"http://meerkat.oreillynet.com/?c=cat23",
|
28
|
-
"http://meerkat.oreillynet.com/?c=47",
|
29
|
-
"http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
|
30
|
-
]
|
31
|
-
|
32
|
-
@topics_node = "<#{@prefix}:topics>\n"
|
33
|
-
@topics_node << " <rdf:Bag>\n"
|
34
|
-
@topics_lis.each do |value|
|
35
|
-
resource = CGI.escapeHTML(value)
|
36
|
-
@topics_node << " <rdf:li resource=\"#{resource}\"/>\n"
|
37
|
-
end
|
38
|
-
@topics_node << " </rdf:Bag>\n"
|
39
|
-
@topics_node << "</#{@prefix}:topics>"
|
40
|
-
|
41
|
-
@topic_topics_lis = \
|
42
|
-
[
|
43
|
-
"http://meerkat.oreillynet.com/?c=cat23",
|
44
|
-
"http://dmoz.org/Computers/Data_Formats/Markup_Languages/SGML/",
|
45
|
-
"http://dmoz.org/Computers/Programming/Internet/",
|
46
|
-
]
|
47
|
-
|
48
|
-
@topic_contents = \
|
49
|
-
[
|
50
|
-
{
|
51
|
-
:link => "http://meerkat.oreillynet.com/?c=cat23",
|
52
|
-
:title => "Data: XML",
|
53
|
-
:description => "A Meerkat channel",
|
54
|
-
},
|
55
|
-
{
|
56
|
-
:link => "http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
|
57
|
-
:title => "XML",
|
58
|
-
:subject => "XML",
|
59
|
-
:description => "DMOZ category",
|
60
|
-
:topics => @topic_topics_lis,
|
61
|
-
}
|
62
|
-
]
|
63
|
-
|
64
|
-
@topic_nodes = @topic_contents.collect do |info|
|
65
|
-
link = info[:link]
|
66
|
-
rv = "<#{@prefix}:topic rdf:about=\"#{link}\">\n"
|
67
|
-
info.each do |name, value|
|
68
|
-
case name
|
69
|
-
when :topics
|
70
|
-
rv << " <#{@prefix}:topics>\n"
|
71
|
-
rv << " <rdf:Bag>\n"
|
72
|
-
value.each do |li|
|
73
|
-
resource = CGI.escapeHTML(li)
|
74
|
-
rv << " <rdf:li resource=\"#{resource}\"/>\n"
|
75
|
-
end
|
76
|
-
rv << " </rdf:Bag>\n"
|
77
|
-
rv << " </#{@prefix}:topics>\n"
|
78
|
-
else
|
79
|
-
prefix = (name == :link ? @prefix : @dc_prefix)
|
80
|
-
rv << " <#{prefix}:#{name}>#{value}</#{prefix}:#{name}>\n"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
rv << "</#{@prefix}:topic>"
|
84
|
-
end
|
85
|
-
|
86
|
-
@rss_source = make_RDF(<<-EOR, @ns)
|
87
|
-
#{make_channel(@topics_node)}
|
88
|
-
#{make_image()}
|
89
|
-
#{make_item(@topics_node)}
|
90
|
-
#{make_textinput()}
|
91
|
-
#{@topic_nodes.join("\n")}
|
92
|
-
EOR
|
93
|
-
|
94
|
-
@rss = Parser.parse(@rss_source)
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_parser
|
98
|
-
assert_nothing_raised do
|
99
|
-
Parser.parse(@rss_source)
|
100
|
-
end
|
101
|
-
|
102
|
-
assert_too_much_tag("topics", "channel") do
|
103
|
-
Parser.parse(make_RDF(<<-EOR, @ns))
|
104
|
-
#{make_channel(@topics_node * 2)}
|
105
|
-
#{make_item()}
|
106
|
-
EOR
|
107
|
-
end
|
108
|
-
|
109
|
-
assert_too_much_tag("topics", "item") do
|
110
|
-
Parser.parse(make_RDF(<<-EOR, @ns))
|
111
|
-
#{make_channel()}
|
112
|
-
#{make_item(@topics_node * 2)}
|
113
|
-
EOR
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_accessor
|
118
|
-
topics = @rss.channel.taxo_topics
|
119
|
-
assert_equal(@topics_lis.sort,
|
120
|
-
topics.Bag.lis.collect {|li| li.resource}.sort)
|
121
|
-
assert_equal(@topics_lis.sort, topics.resources.sort)
|
122
|
-
|
123
|
-
assert_equal(@rss.taxo_topics.first, @rss.taxo_topic)
|
124
|
-
|
125
|
-
@topic_contents.each_with_index do |info, i|
|
126
|
-
topic = @rss.taxo_topics[i]
|
127
|
-
info.each do |name, value|
|
128
|
-
case name
|
129
|
-
when :link
|
130
|
-
assert_equal(value, topic.about)
|
131
|
-
assert_equal(value, topic.taxo_link)
|
132
|
-
when :topics
|
133
|
-
assert_equal(value.sort, topic.taxo_topics.resources.sort)
|
134
|
-
else
|
135
|
-
assert_equal(value, topic.__send__("dc_#{name}"))
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_to_s
|
142
|
-
@topics_parents.each do |parent|
|
143
|
-
meth = "taxo_topics_element"
|
144
|
-
assert_equal(@topics_node, @rss.__send__(parent).__send__(meth))
|
145
|
-
end
|
146
|
-
|
147
|
-
@topic_nodes.each_with_index do |node, i|
|
148
|
-
expected_xml = taxo_xmlns_container(node)
|
149
|
-
expected = REXML::Document.new(expected_xml).root.elements[1]
|
150
|
-
actual_xml = taxo_xmlns_container(@rss.taxo_topics[i].to_s(true, ""))
|
151
|
-
actual = REXML::Document.new(actual_xml).root.elements[1]
|
152
|
-
expected_elems = expected.reject {|x| x.is_a?(REXML::Text)}
|
153
|
-
actual_elems = actual.reject {|x| x.is_a?(REXML::Text)}
|
154
|
-
expected_elems.sort! {|x, y| x.name <=> y.name}
|
155
|
-
actual_elems.sort! {|x, y| x.name <=> y.name}
|
156
|
-
assert_equal(expected_elems.collect {|x| x.to_s},
|
157
|
-
actual_elems.collect {|x| x.to_s})
|
158
|
-
assert_equal(expected.attributes.sort, actual.attributes.sort)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
private
|
163
|
-
def taxo_xmlns_container(content)
|
164
|
-
xmlns_container({
|
165
|
-
@prefix => @uri,
|
166
|
-
"dc" => "http://purl.org/dc/elements/1.1/",
|
167
|
-
"rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
168
|
-
},
|
169
|
-
content)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|