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_maker_taxo.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerTaxonomy < TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@uri = "http://purl.org/rss/1.0/modules/taxonomy/"
|
11
|
-
|
12
|
-
@resources = [
|
13
|
-
"http://meerkat.oreillynet.com/?c=cat23",
|
14
|
-
"http://meerkat.oreillynet.com/?c=47",
|
15
|
-
"http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
|
16
|
-
]
|
17
|
-
|
18
|
-
@topics = [
|
19
|
-
{
|
20
|
-
:link => "http://meerkat.oreillynet.com/?c=cat23",
|
21
|
-
:title => "Data: XML",
|
22
|
-
:description => "A Meerkat channel",
|
23
|
-
},
|
24
|
-
{
|
25
|
-
:link => "http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
|
26
|
-
:title => "XML",
|
27
|
-
:subject => "XML",
|
28
|
-
:description => "DMOZ category",
|
29
|
-
:topics => [
|
30
|
-
"http://meerkat.oreillynet.com/?c=cat23",
|
31
|
-
"http://dmoz.org/Computers/Data_Formats/Markup_Languages/SGML/",
|
32
|
-
"http://dmoz.org/Computers/Programming/Internet/",
|
33
|
-
]
|
34
|
-
},
|
35
|
-
]
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_rss10
|
39
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
40
|
-
setup_dummy_channel(maker)
|
41
|
-
set_topics(maker.channel)
|
42
|
-
|
43
|
-
setup_dummy_item(maker)
|
44
|
-
set_topics(maker.items.last)
|
45
|
-
|
46
|
-
setup_taxo_topic(maker, @topics)
|
47
|
-
end
|
48
|
-
assert_equal(@resources, rss.channel.taxo_topics.resources)
|
49
|
-
assert_equal(@resources, rss.items.last.taxo_topics.resources)
|
50
|
-
assert_taxo_topic(@topics, rss)
|
51
|
-
end
|
52
|
-
|
53
|
-
def _test_date
|
54
|
-
t1 = Time.iso8601("2000-01-01T12:00:05+00:00")
|
55
|
-
t2 = Time.iso8601("2005-01-01T12:00:05+00:00")
|
56
|
-
|
57
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
58
|
-
setup_dummy_channel(maker)
|
59
|
-
maker.channel.date = t1
|
60
|
-
maker.channel.dc_dates.new_date do |date|
|
61
|
-
date.value = t2
|
62
|
-
end
|
63
|
-
|
64
|
-
setup_dummy_item(maker)
|
65
|
-
item = maker.items.last
|
66
|
-
item.date = t2
|
67
|
-
item.dc_dates.new_date do |date|
|
68
|
-
date.value = t1
|
69
|
-
end
|
70
|
-
end
|
71
|
-
assert_equal([t1, t2], rss.channel.dc_dates.collect{|x| x.value})
|
72
|
-
assert_equal([t2, t1], rss.items.last.dc_dates.collect{|x| x.value})
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
def set_topics(target, resources=@resources)
|
77
|
-
resources.each do |value|
|
78
|
-
target.taxo_topics << value
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerTrackBack < TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@uri = "http://madskills.com/public/xml/rss/module/trackback/"
|
11
|
-
|
12
|
-
@elements = {
|
13
|
-
:ping => "http://bar.com/tb.cgi?tb_id=rssplustrackback",
|
14
|
-
:abouts => [
|
15
|
-
"http://foo.com/trackback/tb.cgi?tb_id=20020923",
|
16
|
-
"http://bar.com/trackback/tb.cgi?tb_id=20041114",
|
17
|
-
],
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_rss10
|
22
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
23
|
-
setup_dummy_channel(maker)
|
24
|
-
|
25
|
-
setup_dummy_item(maker)
|
26
|
-
item = maker.items.last
|
27
|
-
item.trackback_ping = @elements[:ping]
|
28
|
-
@elements[:abouts].each do |about|
|
29
|
-
item.trackback_abouts.new_about do |new_about|
|
30
|
-
new_about.value = about
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
assert_trackback(@elements, rss.items.last)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
def accessor_name(name)
|
39
|
-
"trackback_#{name}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerXMLStyleSheet < TestCase
|
8
|
-
|
9
|
-
def test_xml_stylesheet
|
10
|
-
href = 'a.xsl'
|
11
|
-
type = 'text/xsl'
|
12
|
-
title = 'sample'
|
13
|
-
media = 'printer'
|
14
|
-
charset = 'UTF-8'
|
15
|
-
alternate = 'yes'
|
16
|
-
|
17
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
18
|
-
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
19
|
-
xss.href = href
|
20
|
-
xss.type = type
|
21
|
-
xss.title = title
|
22
|
-
xss.media = media
|
23
|
-
xss.charset = charset
|
24
|
-
xss.alternate = alternate
|
25
|
-
end
|
26
|
-
|
27
|
-
setup_dummy_channel(maker)
|
28
|
-
setup_dummy_item(maker)
|
29
|
-
end
|
30
|
-
|
31
|
-
xss = rss.xml_stylesheets.first
|
32
|
-
assert_equal(href, xss.href)
|
33
|
-
assert_equal(type, xss.type)
|
34
|
-
assert_equal(title, xss.title)
|
35
|
-
assert_equal(media, xss.media)
|
36
|
-
assert_equal(charset, xss.charset)
|
37
|
-
assert_equal(alternate, xss.alternate)
|
38
|
-
|
39
|
-
|
40
|
-
href = 'http://example.com/index.xsl'
|
41
|
-
type = 'text/xsl'
|
42
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
43
|
-
maker.xml_stylesheets.new_xml_stylesheet do |_xss|
|
44
|
-
_xss.href = href
|
45
|
-
end
|
46
|
-
|
47
|
-
setup_dummy_channel(maker)
|
48
|
-
setup_dummy_item(maker)
|
49
|
-
end
|
50
|
-
|
51
|
-
xss = rss.xml_stylesheets.first
|
52
|
-
assert_equal(href, xss.href)
|
53
|
-
assert_equal(type, xss.type)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_not_valid_xml_stylesheet
|
57
|
-
href = 'xss.XXX'
|
58
|
-
type = "text/xsl"
|
59
|
-
|
60
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
61
|
-
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
62
|
-
# xss.href = href
|
63
|
-
xss.type = type
|
64
|
-
end
|
65
|
-
|
66
|
-
setup_dummy_channel(maker)
|
67
|
-
setup_dummy_item(maker)
|
68
|
-
end
|
69
|
-
assert(rss.xml_stylesheets.empty?)
|
70
|
-
|
71
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
72
|
-
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
73
|
-
xss.href = href
|
74
|
-
# xss.type = type
|
75
|
-
end
|
76
|
-
|
77
|
-
setup_dummy_channel(maker)
|
78
|
-
setup_dummy_item(maker)
|
79
|
-
end
|
80
|
-
assert(rss.xml_stylesheets.empty?)
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
data/test/test_parser.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require "tempfile"
|
3
|
-
|
4
|
-
require_relative "rss-testcase"
|
5
|
-
|
6
|
-
require "rss/1.0"
|
7
|
-
require "rss/dublincore"
|
8
|
-
|
9
|
-
module RSS
|
10
|
-
class TestParser < TestCase
|
11
|
-
def setup
|
12
|
-
@_default_parser = Parser.default_parser
|
13
|
-
@rss10 = make_RDF(<<-EOR)
|
14
|
-
#{make_channel}
|
15
|
-
#{make_item}
|
16
|
-
#{make_textinput}
|
17
|
-
#{make_image}
|
18
|
-
EOR
|
19
|
-
@rss_tmp = Tempfile.new(%w"rss10- .rdf")
|
20
|
-
@rss_tmp.print(@rss10)
|
21
|
-
@rss_tmp.close
|
22
|
-
@rss_file = @rss_tmp.path
|
23
|
-
@rss_file.untaint if RUBY_VERSION < '2.7'
|
24
|
-
end
|
25
|
-
|
26
|
-
def teardown
|
27
|
-
Parser.default_parser = @_default_parser
|
28
|
-
@rss_tmp.close(true)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_default_parser
|
32
|
-
assert_nothing_raised do
|
33
|
-
Parser.default_parser = RSS::AVAILABLE_PARSERS.first
|
34
|
-
end
|
35
|
-
|
36
|
-
assert_raise(RSS::NotValidXMLParser) do
|
37
|
-
Parser.default_parser = RSS::Parser
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_parse
|
42
|
-
assert_not_nil(RSS::Parser.parse(@rss_file))
|
43
|
-
|
44
|
-
garbage_rss_file = @rss_file + "-garbage"
|
45
|
-
if RSS::Parser.default_parser.name == "RSS::XMLParserParser"
|
46
|
-
assert_raise(RSS::NotWellFormedError) do
|
47
|
-
RSS::Parser.parse(garbage_rss_file)
|
48
|
-
end
|
49
|
-
else
|
50
|
-
assert_nil(RSS::Parser.parse(garbage_rss_file))
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_parse_tag_includes_hyphen
|
55
|
-
assert_nothing_raised do
|
56
|
-
RSS::Parser.parse(make_RDF(<<-EOR))
|
57
|
-
<xCal:x-calconnect-venue xmlns:xCal="urn:ietf:params:xml:ns:xcal" />
|
58
|
-
#{make_channel}
|
59
|
-
#{make_item}
|
60
|
-
#{make_textinput}
|
61
|
-
#{make_image}
|
62
|
-
EOR
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_parse_option_validate_nil
|
67
|
-
assert_raise(RSS::MissingTagError) do
|
68
|
-
RSS::Parser.parse(make_RDF(<<-RDF), :validate => nil)
|
69
|
-
RDF
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_parse_option_validate_true
|
74
|
-
assert_raise(RSS::MissingTagError) do
|
75
|
-
RSS::Parser.parse(make_RDF(<<-RDF), :validate => true)
|
76
|
-
RDF
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_parse_option_validate_false
|
81
|
-
rdf = RSS::Parser.parse(make_RDF(<<-RDF), :validate => false)
|
82
|
-
RDF
|
83
|
-
assert_nil(rdf.channel)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_parse_option_ignore_unknown_element_nil
|
87
|
-
assert_nothing_raised do
|
88
|
-
RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => nil)
|
89
|
-
<unknown/>
|
90
|
-
#{make_channel}
|
91
|
-
#{make_item}
|
92
|
-
#{make_textinput}
|
93
|
-
#{make_image}
|
94
|
-
RDF
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_parse_option_ignore_unknown_element_true
|
99
|
-
assert_nothing_raised do
|
100
|
-
RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => true)
|
101
|
-
<unknown/>
|
102
|
-
#{make_channel}
|
103
|
-
#{make_item}
|
104
|
-
#{make_textinput}
|
105
|
-
#{make_image}
|
106
|
-
RDF
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_parse_option_ignore_unknown_element_false
|
111
|
-
assert_raise(RSS::NotExpectedTagError) do
|
112
|
-
RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => false)
|
113
|
-
<unknown/>
|
114
|
-
#{make_channel}
|
115
|
-
#{make_item}
|
116
|
-
#{make_textinput}
|
117
|
-
#{make_image}
|
118
|
-
RDF
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|