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_trackback.rb
DELETED
@@ -1,136 +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/2.0"
|
9
|
-
require "rss/trackback"
|
10
|
-
|
11
|
-
module RSS
|
12
|
-
class TestTrackBack < TestCase
|
13
|
-
|
14
|
-
def setup
|
15
|
-
@prefix = "trackback"
|
16
|
-
@uri = "http://madskills.com/public/xml/rss/module/trackback/"
|
17
|
-
|
18
|
-
@parents = %w(item)
|
19
|
-
|
20
|
-
@elems = {
|
21
|
-
:ping => "http://bar.com/tb.cgi?tb_id=rssplustrackback",
|
22
|
-
:about => "http://foo.com/trackback/tb.cgi?tb_id=20020923",
|
23
|
-
}
|
24
|
-
|
25
|
-
@content_nodes = @elems.collect do |name, value|
|
26
|
-
"<#{@prefix}:#{name} rdf:resource=\"#{CGI.escapeHTML(value.to_s)}\"/>"
|
27
|
-
end.join("\n")
|
28
|
-
|
29
|
-
@content_nodes2 = @elems.collect do |name, value|
|
30
|
-
"<#{@prefix}:#{name}>#{CGI.escapeHTML(value.to_s)}</#{@prefix}:#{name}>"
|
31
|
-
end.join("\n")
|
32
|
-
|
33
|
-
@rss_source = make_RDF(<<-EOR, {@prefix => @uri})
|
34
|
-
#{make_channel()}
|
35
|
-
#{make_image()}
|
36
|
-
#{make_item(@content_nodes)}
|
37
|
-
#{make_textinput()}
|
38
|
-
EOR
|
39
|
-
|
40
|
-
@rss = Parser.parse(@rss_source)
|
41
|
-
|
42
|
-
@rss20_source = make_rss20(nil, {@prefix => @uri}) do
|
43
|
-
make_channel20(nil) do
|
44
|
-
make_item20(@content_nodes2)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
@rss20 = Parser.parse(@rss20_source, false)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_parser
|
52
|
-
|
53
|
-
assert_nothing_raised do
|
54
|
-
Parser.parse(@rss_source)
|
55
|
-
end
|
56
|
-
|
57
|
-
@elems.find_all{|k, v| k == :ping}.each do |tag, value|
|
58
|
-
assert_too_much_tag(tag.to_s, "item") do
|
59
|
-
Parser.parse(make_RDF(<<-EOR, {@prefix => @uri}))
|
60
|
-
#{make_channel()}
|
61
|
-
#{make_item(("<" + @prefix + ":" + tag.to_s + " rdf:resource=\"" +
|
62
|
-
CGI.escapeHTML(value.to_s) +
|
63
|
-
"\"/>") * 2)}
|
64
|
-
EOR
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
@elems.find_all{|k, v| k == :about}.each do |tag, value|
|
69
|
-
assert_missing_tag("trackback:ping", "item") do
|
70
|
-
Parser.parse(make_RDF(<<-EOR, {@prefix => @uri}))
|
71
|
-
#{make_channel()}
|
72
|
-
#{make_item(("<" + @prefix + ":" + tag.to_s + " rdf:resource=\"" +
|
73
|
-
CGI.escapeHTML(value.to_s) +
|
74
|
-
"\"/>") * 2)}
|
75
|
-
EOR
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_accessor
|
83
|
-
|
84
|
-
new_value = {
|
85
|
-
:ping => "http://baz.com/trackback/tb.cgi?tb_id=20030808",
|
86
|
-
:about => "http://hoge.com/trackback/tb.cgi?tb_id=90030808",
|
87
|
-
}
|
88
|
-
|
89
|
-
@elems.each do |name, value|
|
90
|
-
@parents.each do |parent|
|
91
|
-
accessor = "#{RSS::TRACKBACK_PREFIX}_#{name}"
|
92
|
-
target = @rss.__send__(parent)
|
93
|
-
target20 = @rss20.channel.__send__(parent, -1)
|
94
|
-
assert_equal(value, target.__send__(accessor))
|
95
|
-
assert_equal(value, target20.__send__(accessor))
|
96
|
-
if name == :about
|
97
|
-
# abount is zero or more
|
98
|
-
target.__send__("#{accessor}=", 0, new_value[name].to_s)
|
99
|
-
target20.__send__("#{accessor}=", 0, new_value[name].to_s)
|
100
|
-
else
|
101
|
-
target.__send__("#{accessor}=", new_value[name].to_s)
|
102
|
-
target20.__send__("#{accessor}=", new_value[name].to_s)
|
103
|
-
end
|
104
|
-
assert_equal(new_value[name], target.__send__(accessor))
|
105
|
-
assert_equal(new_value[name], target20.__send__(accessor))
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_to_s
|
112
|
-
|
113
|
-
@elems.each do |name, value|
|
114
|
-
excepted = %Q!<#{@prefix}:#{name} rdf:resource="#{CGI.escapeHTML(value)}"/>!
|
115
|
-
@parents.each do |parent|
|
116
|
-
meth = "#{RSS::TRACKBACK_PREFIX}_#{name}_element"
|
117
|
-
meth << "s" if name == :about
|
118
|
-
assert_equal(excepted, @rss.__send__(parent).__send__(meth))
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
REXML::Document.new(@rss_source).root.each_element do |parent|
|
123
|
-
if @parents.include?(parent.name)
|
124
|
-
parent.each_element do |elem|
|
125
|
-
if elem.namespace == @uri
|
126
|
-
assert_equal(elem.attributes["resource"], @elems[elem.name.intern])
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
data/test/test_xml-stylesheet.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require "rexml/document"
|
3
|
-
|
4
|
-
require_relative "rss-testcase"
|
5
|
-
|
6
|
-
require "rss/1.0"
|
7
|
-
require "rss/xml-stylesheet"
|
8
|
-
|
9
|
-
module RSS
|
10
|
-
class TestXMLStyleSheet < TestCase
|
11
|
-
|
12
|
-
def test_accessor
|
13
|
-
[
|
14
|
-
{:href => "a.xsl", :type => "text/xsl"},
|
15
|
-
{:media => "print", :title => "FOO"},
|
16
|
-
{:charset => "UTF-8", :alternate => "yes"},
|
17
|
-
].each do |attrs|
|
18
|
-
assert_xml_stylesheet_attrs(attrs, XMLStyleSheet.new(attrs))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_to_s
|
23
|
-
[
|
24
|
-
{:href => "a.xsl", :type => "text/xsl"},
|
25
|
-
{:type => "text/xsl"},
|
26
|
-
{:href => "a.xsl", :guess_type => "text/xsl"},
|
27
|
-
{:href => "a.css", :type => "text/css"},
|
28
|
-
{:href => "a.css", :type => "text/xsl",
|
29
|
-
:guess_type => "text/css"},
|
30
|
-
{:href => "a.xsl", :type => "text/xsl",
|
31
|
-
:title => "sample", :media => "printer",
|
32
|
-
:charset => "UTF-8", :alternate => "yes"},
|
33
|
-
{:href => "a.css", :guess_type => "text/css",
|
34
|
-
:alternate => "no"},
|
35
|
-
{:type => "text/xsl", :title => "sample",
|
36
|
-
:media => "printer", :charset => "UTF-8",
|
37
|
-
:alternate => "yes"},
|
38
|
-
].each do |attrs|
|
39
|
-
target, contents = parse_pi(XMLStyleSheet.new(attrs).to_s)
|
40
|
-
assert_xml_stylesheet(target, attrs, XMLStyleSheet.new(contents))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_bad_alternate
|
45
|
-
%w(a ___ ??? BAD_ALTERNATE).each do |value|
|
46
|
-
xss = XMLStyleSheet.new
|
47
|
-
assert_raise(NotAvailableValueError) do
|
48
|
-
xss.alternate = value
|
49
|
-
end
|
50
|
-
xss.do_validate = false
|
51
|
-
assert_nothing_raised do
|
52
|
-
xss.alternate = value
|
53
|
-
end
|
54
|
-
assert_nil(xss.alternate)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_parse
|
59
|
-
[
|
60
|
-
[{:href => "a.xsl", :type => "text/xsl"},],
|
61
|
-
[{:media => "print", :title => "FOO"},],
|
62
|
-
[{:charset => "UTF-8", :alternate => "yes"},],
|
63
|
-
[{:href => "a.xsl", :type => "text/xsl"},
|
64
|
-
{:type => "text/xsl"},
|
65
|
-
{:href => "a.xsl", :guess_type => "text/xsl"},
|
66
|
-
{:href => "a.css", :type => "text/css"},
|
67
|
-
{:href => "a.css", :type => "text/xsl",
|
68
|
-
:guess_type => "text/css"},
|
69
|
-
{:href => "a.xsl", :type => "text/xsl",
|
70
|
-
:title => "sample", :media => "printer",
|
71
|
-
:charset => "UTF-8", :alternate => "yes"},
|
72
|
-
{:href => "a.css", :guess_type => "text/css",
|
73
|
-
:alternate => "no"},
|
74
|
-
{:type => "text/xsl", :title => "sample",
|
75
|
-
:media => "printer", :charset => "UTF-8",
|
76
|
-
:alternate => "yes"},],
|
77
|
-
].each do |xsss|
|
78
|
-
doc = REXML::Document.new(make_sample_RDF)
|
79
|
-
root = doc.root
|
80
|
-
xsss.each do |xss|
|
81
|
-
content = xss.collect do |key, name|
|
82
|
-
%Q[#{key}="#{name}"]
|
83
|
-
end.join(" ")
|
84
|
-
pi = REXML::Instruction.new("xml-stylesheet", content)
|
85
|
-
root.previous_sibling = pi
|
86
|
-
end
|
87
|
-
rss = Parser.parse(doc.to_s)
|
88
|
-
have_href_xsss = xsss.find_all {|xss| xss.has_key?(:href)}
|
89
|
-
assert_equal(have_href_xsss.size, rss.xml_stylesheets.size)
|
90
|
-
rss.xml_stylesheets.each_with_index do |stylesheet, i|
|
91
|
-
target, = parse_pi(stylesheet.to_s)
|
92
|
-
assert_xml_stylesheet(target, have_href_xsss[i], stylesheet)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def parse_pi(pi)
|
98
|
-
/\A\s*<\?(\S+)([^?]*\?+(?:[^?>][^?]*\?+)*)>\s*\z/ =~ pi
|
99
|
-
target = $1
|
100
|
-
dummy = REXML::Document.new("<dummy #{$2.to_s.chop}/>").root
|
101
|
-
contents = {}
|
102
|
-
dummy.attributes.each do |name, value|
|
103
|
-
contents[name] = value
|
104
|
-
end
|
105
|
-
[target, contents]
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
end
|