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
@@ -1,164 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/atom"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestParserAtom < TestCase
|
8
|
-
def test_entry_validation
|
9
|
-
assert_ns("", Atom::URI) do
|
10
|
-
Parser.parse(<<-EOA)
|
11
|
-
<entry/>
|
12
|
-
EOA
|
13
|
-
end
|
14
|
-
|
15
|
-
assert_ns("", Atom::URI) do
|
16
|
-
Parser.parse(<<-EOA)
|
17
|
-
<entry xmlns="hoge"/>
|
18
|
-
EOA
|
19
|
-
end
|
20
|
-
|
21
|
-
assert_parse(<<-EOA, :missing_tag, "id", "entry") do
|
22
|
-
<entry xmlns="#{Atom::URI}"/>
|
23
|
-
EOA
|
24
|
-
end
|
25
|
-
|
26
|
-
assert_parse(<<-EOA, :missing_tag, "title", "entry") do
|
27
|
-
<entry xmlns="#{Atom::URI}">
|
28
|
-
<id>urn:uuid:506e336c-a26e-4457-917b-b89dca7ae746</id>
|
29
|
-
</entry>
|
30
|
-
EOA
|
31
|
-
end
|
32
|
-
|
33
|
-
assert_parse(<<-EOA, :missing_tag, "updated", "entry") do
|
34
|
-
<entry xmlns="#{Atom::URI}">
|
35
|
-
<id>urn:uuid:506e336c-a26e-4457-917b-b89dca7ae746</id>
|
36
|
-
<title>Example Entry</title>
|
37
|
-
</entry>
|
38
|
-
EOA
|
39
|
-
end
|
40
|
-
|
41
|
-
assert_parse(<<-EOA, :missing_tag, "author", "entry") do
|
42
|
-
<entry xmlns="#{Atom::URI}">
|
43
|
-
<id>urn:uuid:506e336c-a26e-4457-917b-b89dca7ae746</id>
|
44
|
-
<title>Example Entry</title>
|
45
|
-
<updated>2003-10-10T18:30:02Z</updated>
|
46
|
-
</entry>
|
47
|
-
EOA
|
48
|
-
end
|
49
|
-
|
50
|
-
assert_parse(<<-EOA, :nothing_raised) do
|
51
|
-
<entry xmlns="#{Atom::URI}">
|
52
|
-
<id>urn:uuid:506e336c-a26e-4457-917b-b89dca7ae746</id>
|
53
|
-
<title>Example Entry</title>
|
54
|
-
<updated>2003-10-10T18:30:02Z</updated>
|
55
|
-
<author>
|
56
|
-
<name>A person</name>
|
57
|
-
</author>
|
58
|
-
</entry>
|
59
|
-
EOA
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_entry
|
64
|
-
entry = RSS::Parser.parse(<<-EOA)
|
65
|
-
<?xml version="1.0" encoding="utf-8"?>
|
66
|
-
<entry xmlns="http://www.w3.org/2005/Atom">
|
67
|
-
<author>
|
68
|
-
<name>A person</name>
|
69
|
-
</author>
|
70
|
-
<title>Atom-Powered Robots Run Amok</title>
|
71
|
-
<link href="http://example.org/2003/12/13/atom03"/>
|
72
|
-
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
73
|
-
<updated>2003-12-13T18:30:02Z</updated>
|
74
|
-
<summary>Some text.</summary>
|
75
|
-
</entry>
|
76
|
-
EOA
|
77
|
-
assert_not_nil(entry)
|
78
|
-
assert_equal("Atom-Powered Robots Run Amok", entry.title.content)
|
79
|
-
assert_equal("http://example.org/2003/12/13/atom03", entry.link.href)
|
80
|
-
assert_equal("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a",
|
81
|
-
entry.id.content)
|
82
|
-
assert_equal(Time.parse("2003-12-13T18:30:02Z"), entry.updated.content)
|
83
|
-
assert_equal("Some text.", entry.summary.content)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_entry_author
|
87
|
-
assert_atom_person("author", method(:make_entry_document)) do |entry|
|
88
|
-
assert_equal(2, entry.authors.size)
|
89
|
-
entry.authors.last
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_entry_category
|
94
|
-
assert_atom_category(method(:make_entry_document)) do |entry|
|
95
|
-
assert_equal(1, entry.categories.size)
|
96
|
-
entry.category
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_entry_content_text
|
101
|
-
assert_atom_content(method(:make_entry_document)) do |entry|
|
102
|
-
entry.content
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_entry_contributor
|
107
|
-
assert_atom_person("contributor", method(:make_entry_document)) do |entry|
|
108
|
-
assert_equal(1, entry.contributors.size)
|
109
|
-
entry.contributor
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_entry_id
|
114
|
-
entry = RSS::Parser.parse(make_entry_document)
|
115
|
-
assert_equal(ENTRY_ID, entry.id.content)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_entry_link
|
119
|
-
assert_atom_link(method(:make_entry_document)) do |entry|
|
120
|
-
assert_equal(1, entry.links.size)
|
121
|
-
entry.link
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_published
|
126
|
-
generator = method(:make_entry_document)
|
127
|
-
assert_atom_date_construct("published", generator) do |entry|
|
128
|
-
entry.published
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_entry_rights
|
133
|
-
generator = method(:make_entry_document)
|
134
|
-
assert_atom_text_construct("rights", generator) do |entry|
|
135
|
-
entry.rights
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_entry_source
|
140
|
-
generator = method(:make_entry_document_with_open_source)
|
141
|
-
assert_atom_source(generator) do |entry|
|
142
|
-
assert_not_nil(entry.source)
|
143
|
-
entry.source
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_entry_summary
|
148
|
-
generator = method(:make_entry_document)
|
149
|
-
assert_atom_text_construct("summary", generator) do |entry|
|
150
|
-
entry.summary
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_entry_title
|
155
|
-
entry = RSS::Parser.parse(make_entry_document)
|
156
|
-
assert_equal(ENTRY_TITLE, entry.title.content)
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_entry_updated
|
160
|
-
entry = RSS::Parser.parse(make_entry_document)
|
161
|
-
assert_equal(Time.parse(ENTRY_UPDATED), entry.updated.content)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
@@ -1,277 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/atom"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestParserAtomFeed < TestCase
|
8
|
-
def test_feed_validation
|
9
|
-
assert_ns("", Atom::URI) do
|
10
|
-
Parser.parse(<<-EOA)
|
11
|
-
<feed/>
|
12
|
-
EOA
|
13
|
-
end
|
14
|
-
|
15
|
-
assert_ns("", Atom::URI) do
|
16
|
-
Parser.parse(<<-EOA)
|
17
|
-
<feed xmlns="hoge"/>
|
18
|
-
EOA
|
19
|
-
end
|
20
|
-
|
21
|
-
assert_parse(<<-EOA, :missing_tag, "id", "feed") do
|
22
|
-
<feed xmlns="#{Atom::URI}"/>
|
23
|
-
EOA
|
24
|
-
end
|
25
|
-
|
26
|
-
assert_parse(<<-EOA, :missing_tag, "title", "feed") do
|
27
|
-
<feed xmlns="#{Atom::URI}">
|
28
|
-
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
29
|
-
</feed>
|
30
|
-
EOA
|
31
|
-
end
|
32
|
-
|
33
|
-
assert_parse(<<-EOA, :missing_tag, "updated", "feed") do
|
34
|
-
<feed xmlns="#{Atom::URI}">
|
35
|
-
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
36
|
-
<title>Example Feed</title>
|
37
|
-
</feed>
|
38
|
-
EOA
|
39
|
-
end
|
40
|
-
|
41
|
-
assert_parse(<<-EOA, :missing_tag, "author", "feed") do
|
42
|
-
<feed xmlns="#{Atom::URI}">
|
43
|
-
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
44
|
-
<title>Example Feed</title>
|
45
|
-
<updated>2003-12-13T18:30:02Z</updated>
|
46
|
-
</feed>
|
47
|
-
EOA
|
48
|
-
end
|
49
|
-
|
50
|
-
assert_parse(<<-EOA, :nothing_raised) do
|
51
|
-
<feed xmlns="#{Atom::URI}">
|
52
|
-
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
53
|
-
<title>Example Feed</title>
|
54
|
-
<updated>2003-12-13T18:30:02Z</updated>
|
55
|
-
<author>
|
56
|
-
<name>A person</name>
|
57
|
-
</author>
|
58
|
-
</feed>
|
59
|
-
EOA
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_lang
|
64
|
-
feed = RSS::Parser.parse(<<-EOA)
|
65
|
-
<feed xmlns="#{Atom::URI}" xml:lang="ja">
|
66
|
-
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
67
|
-
<title xml:lang="en">Example Feed</title>
|
68
|
-
<updated>2003-12-13T18:30:02Z</updated>
|
69
|
-
<author xml:lang="en">
|
70
|
-
<name>A person</name>
|
71
|
-
</author>
|
72
|
-
</feed>
|
73
|
-
EOA
|
74
|
-
|
75
|
-
assert_equal("ja", feed.lang)
|
76
|
-
assert_equal("ja", feed.id.lang)
|
77
|
-
assert_equal("en", feed.title.lang)
|
78
|
-
assert_equal("ja", feed.updated.lang)
|
79
|
-
assert_equal("en", feed.author.lang)
|
80
|
-
assert_equal("en", feed.author.name.lang)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_base
|
84
|
-
feed = RSS::Parser.parse(<<-EOA)
|
85
|
-
<feed xmlns="#{Atom::URI}" xml:base="http://example.com/">
|
86
|
-
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
87
|
-
<title xml:lang="en">Example Feed</title>
|
88
|
-
<updated>2003-12-13T18:30:02Z</updated>
|
89
|
-
<generator uri="generator">Generator</generator>
|
90
|
-
<link hreflang="ja" href="http://example.org/link1"/>
|
91
|
-
<link hreflang="en" href="link2"/>
|
92
|
-
<link hreflang="fr" xml:base="http://example.net/" href="link3"/>
|
93
|
-
<author>
|
94
|
-
<name>A person</name>
|
95
|
-
<uri>person</uri>
|
96
|
-
</author>
|
97
|
-
</feed>
|
98
|
-
EOA
|
99
|
-
|
100
|
-
assert_equal("http://example.com/", feed.base)
|
101
|
-
assert_equal("http://example.com/", feed.id.base)
|
102
|
-
assert_equal("http://example.com/", feed.title.base)
|
103
|
-
assert_equal("http://example.com/", feed.updated.base)
|
104
|
-
assert_equal("http://example.com/", feed.generator.base)
|
105
|
-
assert_equal("http://example.com/generator", feed.generator.uri)
|
106
|
-
|
107
|
-
assert_equal("http://example.com/", feed.links[0].base)
|
108
|
-
assert_equal("http://example.org/link1", feed.links[0].href)
|
109
|
-
assert_equal("http://example.com/", feed.links[1].base)
|
110
|
-
assert_equal("http://example.com/link2", feed.links[1].href)
|
111
|
-
assert_equal("http://example.net/", feed.links[2].base)
|
112
|
-
assert_equal("http://example.net/link3", feed.links[2].href)
|
113
|
-
assert_equal("http://example.com/person", feed.author.uri.content)
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_feed_author
|
117
|
-
assert_atom_person("author", method(:make_feed)) do |feed|
|
118
|
-
assert_equal(2, feed.authors.size)
|
119
|
-
feed.authors[1]
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_entry_author
|
124
|
-
generator = method(:make_feed_with_open_entry)
|
125
|
-
assert_atom_person("author", generator) do |feed|
|
126
|
-
assert_equal(1, feed.entries.size)
|
127
|
-
assert_equal(1, feed.entry.authors.size)
|
128
|
-
feed.entry.author
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_feed_category
|
133
|
-
assert_atom_category(method(:make_feed)) do |feed|
|
134
|
-
assert_equal(1, feed.categories.size)
|
135
|
-
feed.category
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_entry_category
|
140
|
-
assert_atom_category(method(:make_feed_with_open_entry)) do |feed|
|
141
|
-
assert_equal(1, feed.entries.size)
|
142
|
-
assert_equal(1, feed.entry.categories.size)
|
143
|
-
feed.entry.category
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_entry_content
|
148
|
-
assert_atom_content(method(:make_feed_with_open_entry)) do |feed|
|
149
|
-
assert_equal(1, feed.entries.size)
|
150
|
-
feed.entry.content
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_feed_contributor
|
155
|
-
assert_atom_person("contributor", method(:make_feed)) do |feed|
|
156
|
-
assert_equal(1, feed.contributors.size)
|
157
|
-
feed.contributor
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_entry_contributor
|
162
|
-
generator = method(:make_feed_with_open_entry)
|
163
|
-
assert_atom_person("contributor", generator) do |feed|
|
164
|
-
assert_equal(1, feed.entries.size)
|
165
|
-
assert_equal(1, feed.entry.contributors.size)
|
166
|
-
feed.entry.contributor
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_feed_generator
|
171
|
-
assert_atom_generator(method(:make_feed)) do |feed|
|
172
|
-
feed.generator
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_feed_icon
|
177
|
-
assert_atom_icon(method(:make_feed)) do |feed|
|
178
|
-
feed.icon
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_feed_id
|
183
|
-
feed = RSS::Parser.parse(make_feed(''))
|
184
|
-
assert_equal(FEED_ID, feed.id.content)
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_entry_id
|
188
|
-
feed = RSS::Parser.parse(make_feed(''))
|
189
|
-
assert_equal(ENTRY_ID, feed.entry.id.content)
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_feed_link
|
193
|
-
assert_atom_link(method(:make_feed)) do |feed|
|
194
|
-
assert_equal(1, feed.links.size)
|
195
|
-
feed.link
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_entry_link
|
200
|
-
assert_atom_link(method(:make_feed_with_open_entry)) do |feed|
|
201
|
-
assert_equal(1, feed.entries.size)
|
202
|
-
assert_equal(1, feed.entry.links.size)
|
203
|
-
feed.entry.link
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_feed_logo
|
208
|
-
assert_atom_logo(method(:make_feed)) do |feed|
|
209
|
-
feed.logo
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_feed_rights
|
214
|
-
assert_atom_text_construct("rights", method(:make_feed)) do |feed|
|
215
|
-
feed.rights
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_entry_rights
|
220
|
-
generator = method(:make_feed_with_open_entry)
|
221
|
-
assert_atom_text_construct("rights", generator) do |feed|
|
222
|
-
assert_equal(1, feed.entries.size)
|
223
|
-
feed.entry.rights
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def test_entry_source
|
228
|
-
assert_atom_source(method(:make_feed_with_open_entry_source)) do |feed|
|
229
|
-
assert_equal(1, feed.entries.size)
|
230
|
-
assert_not_nil(feed.entry.source)
|
231
|
-
feed.entry.source
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_feed_subtitle
|
236
|
-
assert_atom_text_construct("subtitle", method(:make_feed)) do |feed|
|
237
|
-
feed.subtitle
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_feed_title
|
242
|
-
feed = RSS::Parser.parse(make_feed(''))
|
243
|
-
assert_equal(FEED_TITLE, feed.title.content)
|
244
|
-
end
|
245
|
-
|
246
|
-
def test_entry_title
|
247
|
-
feed = RSS::Parser.parse(make_feed(''))
|
248
|
-
assert_equal(ENTRY_TITLE, feed.entry.title.content)
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_feed_updated
|
252
|
-
feed = RSS::Parser.parse(make_feed(''))
|
253
|
-
assert_equal(Time.parse(FEED_UPDATED), feed.updated.content)
|
254
|
-
end
|
255
|
-
|
256
|
-
def test_entry_updated
|
257
|
-
feed = RSS::Parser.parse(make_feed(''))
|
258
|
-
assert_equal(Time.parse(ENTRY_UPDATED), feed.entry.updated.content)
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_entry_published
|
262
|
-
generator = method(:make_feed_with_open_entry)
|
263
|
-
assert_atom_date_construct("published", generator) do |feed|
|
264
|
-
assert_equal(1, feed.entries.size)
|
265
|
-
feed.entry.published
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
def test_entry_summary
|
270
|
-
generator = method(:make_feed_with_open_entry)
|
271
|
-
assert_atom_text_construct("summary", generator) do |feed|
|
272
|
-
assert_equal(1, feed.entries.size)
|
273
|
-
feed.entry.summary
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
@@ -1,247 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestSetupMaker09 < TestCase
|
8
|
-
|
9
|
-
def test_setup_maker_channel
|
10
|
-
title = "fugafuga"
|
11
|
-
link = "http://hoge.com"
|
12
|
-
description = "fugafugafugafuga"
|
13
|
-
language = "ja"
|
14
|
-
copyright = "foo"
|
15
|
-
managingEditor = "bar"
|
16
|
-
webMaster = "web master"
|
17
|
-
rating = '(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))'
|
18
|
-
docs = "http://foo.com/doc"
|
19
|
-
skipDays = [
|
20
|
-
"Sunday",
|
21
|
-
"Monday",
|
22
|
-
]
|
23
|
-
skipHours = [
|
24
|
-
"0",
|
25
|
-
"13",
|
26
|
-
]
|
27
|
-
pubDate = Time.now
|
28
|
-
lastBuildDate = Time.now
|
29
|
-
|
30
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
31
|
-
maker.channel.title = title
|
32
|
-
maker.channel.link = link
|
33
|
-
maker.channel.description = description
|
34
|
-
maker.channel.language = language
|
35
|
-
maker.channel.copyright = copyright
|
36
|
-
maker.channel.managingEditor = managingEditor
|
37
|
-
maker.channel.webMaster = webMaster
|
38
|
-
maker.channel.rating = rating
|
39
|
-
maker.channel.docs = docs
|
40
|
-
maker.channel.pubDate = pubDate
|
41
|
-
maker.channel.lastBuildDate = lastBuildDate
|
42
|
-
|
43
|
-
skipDays.each do |day|
|
44
|
-
maker.channel.skipDays.new_day do |new_day|
|
45
|
-
new_day.content = day
|
46
|
-
end
|
47
|
-
end
|
48
|
-
skipHours.each do |hour|
|
49
|
-
maker.channel.skipHours.new_hour do |new_hour|
|
50
|
-
new_hour.content = hour
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
setup_dummy_image(maker)
|
55
|
-
end
|
56
|
-
|
57
|
-
assert_not_set_error("maker.image", %w(title url)) do
|
58
|
-
RSS::Maker.make("0.91") do |maker|
|
59
|
-
rss.channel.setup_maker(maker)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
new_rss = RSS::Maker.make("0.91") do |maker|
|
64
|
-
rss.channel.setup_maker(maker)
|
65
|
-
setup_dummy_image(maker)
|
66
|
-
end
|
67
|
-
channel = new_rss.channel
|
68
|
-
|
69
|
-
assert_equal(title, channel.title)
|
70
|
-
assert_equal(link, channel.link)
|
71
|
-
assert_equal(description, channel.description)
|
72
|
-
assert_equal(language, channel.language)
|
73
|
-
assert_equal(copyright, channel.copyright)
|
74
|
-
assert_equal(managingEditor, channel.managingEditor)
|
75
|
-
assert_equal(webMaster, channel.webMaster)
|
76
|
-
assert_equal(rating, channel.rating)
|
77
|
-
assert_equal(docs, channel.docs)
|
78
|
-
assert_equal(pubDate, channel.pubDate)
|
79
|
-
assert_equal(lastBuildDate, channel.lastBuildDate)
|
80
|
-
|
81
|
-
skipDays.each_with_index do |day, i|
|
82
|
-
assert_equal(day, channel.skipDays.days[i].content)
|
83
|
-
end
|
84
|
-
skipHours.each_with_index do |hour, i|
|
85
|
-
assert_equal(hour.to_i, channel.skipHours.hours[i].content)
|
86
|
-
end
|
87
|
-
|
88
|
-
assert(channel.items.empty?)
|
89
|
-
assert_nil(channel.textInput)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_setup_maker_image
|
93
|
-
title = "fugafuga"
|
94
|
-
link = "http://hoge.com"
|
95
|
-
url = "http://hoge.com/hoge.png"
|
96
|
-
width = "144"
|
97
|
-
height = "400"
|
98
|
-
description = "an image"
|
99
|
-
|
100
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
101
|
-
setup_dummy_channel(maker)
|
102
|
-
maker.channel.link = link
|
103
|
-
|
104
|
-
maker.image.title = title
|
105
|
-
maker.image.url = url
|
106
|
-
maker.image.width = width
|
107
|
-
maker.image.height = height
|
108
|
-
maker.image.description = description
|
109
|
-
end
|
110
|
-
|
111
|
-
new_rss = RSS::Maker.make("0.91") do |maker|
|
112
|
-
rss.channel.setup_maker(maker)
|
113
|
-
rss.image.setup_maker(maker)
|
114
|
-
end
|
115
|
-
|
116
|
-
image = new_rss.image
|
117
|
-
assert_equal(title, image.title)
|
118
|
-
assert_equal(link, image.link)
|
119
|
-
assert_equal(url, image.url)
|
120
|
-
assert_equal(width.to_i, image.width)
|
121
|
-
assert_equal(height.to_i, image.height)
|
122
|
-
assert_equal(description, image.description)
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_setup_maker_textinput
|
126
|
-
title = "fugafuga"
|
127
|
-
description = "text hoge fuga"
|
128
|
-
name = "hoge"
|
129
|
-
link = "http://hoge.com"
|
130
|
-
|
131
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
132
|
-
setup_dummy_channel(maker)
|
133
|
-
setup_dummy_image(maker)
|
134
|
-
|
135
|
-
maker.textinput.title = title
|
136
|
-
maker.textinput.description = description
|
137
|
-
maker.textinput.name = name
|
138
|
-
maker.textinput.link = link
|
139
|
-
end
|
140
|
-
|
141
|
-
new_rss = RSS::Maker.make("0.91") do |maker|
|
142
|
-
rss.channel.setup_maker(maker)
|
143
|
-
rss.image.setup_maker(maker)
|
144
|
-
rss.textinput.setup_maker(maker)
|
145
|
-
end
|
146
|
-
|
147
|
-
textInput = new_rss.channel.textInput
|
148
|
-
assert_equal(title, textInput.title)
|
149
|
-
assert_equal(description, textInput.description)
|
150
|
-
assert_equal(name, textInput.name)
|
151
|
-
assert_equal(link, textInput.link)
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_setup_maker_items(for_backward_compatibility=false)
|
155
|
-
title = "TITLE"
|
156
|
-
link = "http://hoge.com/"
|
157
|
-
description = "text hoge fuga"
|
158
|
-
|
159
|
-
item_size = 5
|
160
|
-
|
161
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
162
|
-
setup_dummy_channel(maker)
|
163
|
-
|
164
|
-
item_size.times do |i|
|
165
|
-
maker.items.new_item do |item|
|
166
|
-
item.title = "#{title}#{i}"
|
167
|
-
item.link = "#{link}#{i}"
|
168
|
-
item.description = "#{description}#{i}"
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
setup_dummy_image(maker)
|
173
|
-
end
|
174
|
-
|
175
|
-
new_rss = RSS::Maker.make("0.91") do |maker|
|
176
|
-
rss.channel.setup_maker(maker)
|
177
|
-
|
178
|
-
rss.items.each do |item|
|
179
|
-
if for_backward_compatibility
|
180
|
-
item.setup_maker(maker)
|
181
|
-
else
|
182
|
-
item.setup_maker(maker.items)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
rss.image.setup_maker(maker)
|
187
|
-
end
|
188
|
-
|
189
|
-
assert_equal(item_size, new_rss.items.size)
|
190
|
-
new_rss.items.each_with_index do |item, i|
|
191
|
-
assert_equal("#{title}#{i}", item.title)
|
192
|
-
assert_equal("#{link}#{i}", item.link)
|
193
|
-
assert_equal("#{description}#{i}", item.description)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_setup_maker_items_backward_compatibility
|
198
|
-
test_setup_maker_items(true)
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_setup_maker
|
202
|
-
encoding = "EUC-JP"
|
203
|
-
standalone = true
|
204
|
-
|
205
|
-
href = 'a.xsl'
|
206
|
-
type = 'text/xsl'
|
207
|
-
title = 'sample'
|
208
|
-
media = 'printer'
|
209
|
-
charset = 'UTF-8'
|
210
|
-
alternate = 'yes'
|
211
|
-
|
212
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
213
|
-
maker.encoding = encoding
|
214
|
-
maker.standalone = standalone
|
215
|
-
|
216
|
-
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
217
|
-
xss.href = href
|
218
|
-
xss.type = type
|
219
|
-
xss.title = title
|
220
|
-
xss.media = media
|
221
|
-
xss.charset = charset
|
222
|
-
xss.alternate = alternate
|
223
|
-
end
|
224
|
-
|
225
|
-
setup_dummy_channel(maker)
|
226
|
-
setup_dummy_image(maker)
|
227
|
-
end
|
228
|
-
|
229
|
-
new_rss = RSS::Maker.make("0.91") do |maker|
|
230
|
-
rss.setup_maker(maker)
|
231
|
-
end
|
232
|
-
|
233
|
-
assert_equal("0.91", new_rss.rss_version)
|
234
|
-
assert_equal(encoding, new_rss.encoding)
|
235
|
-
assert_equal(standalone, new_rss.standalone)
|
236
|
-
|
237
|
-
xss = rss.xml_stylesheets.first
|
238
|
-
assert_equal(1, rss.xml_stylesheets.size)
|
239
|
-
assert_equal(href, xss.href)
|
240
|
-
assert_equal(type, xss.type)
|
241
|
-
assert_equal(title, xss.title)
|
242
|
-
assert_equal(media, xss.media)
|
243
|
-
assert_equal(charset, xss.charset)
|
244
|
-
assert_equal(alternate, xss.alternate)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|