diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-17 01:28:46 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-17 01:28:46 +0000 |
commit | 02cce7ed8273bab55081357c57f24a8265a6f32a (patch) | |
tree | 81fcc7a474ce90e19acf57390e5b5795849de6c0 /test | |
parent | 463c6a218fed7248531a002806e9b07be7f5a6ea (diff) |
* lib/rss/rss.rb (Kernel#funcall): removed.
* lib/rss/parser.rb (Kernel.URI): removed.
* lib/rss/maker/: supported
xxx.new_yyy do |yyy|
yyy.zzz = zzz
...
end
style and this style became the style of the recommendation.
Old style
yyy = xxx.new_yyy
yyy.zzz = zzz
...
is supported too but this style isn't recommended.
[ruby-talk:197284]
* test/rss/test_*maker*.rb: used new recommended style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/rss/test_maker_0.9.rb | 37 | ||||
-rw-r--r-- | test/rss/test_maker_1.0.rb | 68 | ||||
-rw-r--r-- | test/rss/test_maker_2.0.rb | 57 | ||||
-rw-r--r-- | test/rss/test_maker_dc.rb | 20 | ||||
-rw-r--r-- | test/rss/test_maker_taxo.rb | 10 | ||||
-rw-r--r-- | test/rss/test_maker_trackback.rb | 5 | ||||
-rw-r--r-- | test/rss/test_maker_xml-stylesheet.rb | 42 | ||||
-rw-r--r-- | test/rss/test_setup_maker_0.9.rb | 36 | ||||
-rw-r--r-- | test/rss/test_setup_maker_1.0.rb | 106 | ||||
-rw-r--r-- | test/rss/test_setup_maker_2.0.rb | 75 |
10 files changed, 251 insertions, 205 deletions
diff --git a/test/rss/test_maker_0.9.rb b/test/rss/test_maker_0.9.rb index d8556887e1..820d567289 100644 --- a/test/rss/test_maker_0.9.rb +++ b/test/rss/test_maker_0.9.rb @@ -82,12 +82,14 @@ module RSS maker.channel.lastBuildDate = lastBuildDate skipDays.each do |day| - new_day = maker.channel.skipDays.new_day - new_day.content = day + maker.channel.skipDays.new_day do |new_day| + new_day.content = day + end end skipHours.each do |hour| - new_hour = maker.channel.skipHours.new_hour - new_hour.content = hour + maker.channel.skipHours.new_hour do |new_hour| + new_hour.content = hour + end end end channel = rss.channel @@ -261,10 +263,11 @@ module RSS rss = RSS::Maker.make("0.91") do |maker| setup_dummy_channel(maker) - item = maker.items.new_item - item.title = title - item.link = link - # item.description = description + maker.items.new_item do |item| + item.title = title + item.link = link + # item.description = description + end end assert_equal(1, rss.channel.items.size) item = rss.channel.items.first @@ -278,10 +281,11 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + end end maker.items.do_sort = true end @@ -296,10 +300,11 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + end end maker.items.do_sort = Proc.new do |x, y| y.title[-1] <=> x.title[-1] diff --git a/test/rss/test_maker_1.0.rb b/test/rss/test_maker_1.0.rb index 9d90f3bedd..e15432146d 100644 --- a/test/rss/test_maker_1.0.rb +++ b/test/rss/test_maker_1.0.rb @@ -203,10 +203,11 @@ module RSS rss = RSS::Maker.make("1.0") do |maker| setup_dummy_channel(maker) - item = maker.items.new_item - item.title = title - item.link = link - # item.description = description + maker.items.new_item do |item| + item.title = title + item.link = link + # item.description = description + end end assert_equal(1, rss.items.size) item = rss.items.first @@ -221,10 +222,11 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + end end maker.items.do_sort = true end @@ -240,10 +242,11 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + end end maker.items.do_sort = Proc.new do |x, y| y.title[-1] <=> x.title[-1] @@ -262,10 +265,11 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + end end maker.items.max_size = max_size end @@ -282,10 +286,11 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + end end maker.items.max_size = max_size end @@ -296,10 +301,11 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + end end maker.items.max_size = max_size end @@ -319,18 +325,20 @@ module RSS rss = RSS::Maker.make("1.0") do |maker| setup_dummy_channel(maker) - item = maker.items.new_item - # item.title = title - item.link = link + maker.items.new_item do |item| + # item.title = title + item.link = link + end end assert(rss.items.empty?) rss = RSS::Maker.make("1.0") do |maker| setup_dummy_channel(maker) - item = maker.items.new_item - item.title = title - # item.link = link + maker.items.new_item do |item| + item.title = title + # item.link = link + end end assert(rss.items.empty?) end diff --git a/test/rss/test_maker_2.0.rb b/test/rss/test_maker_2.0.rb index 2c581f75ea..ec5f3abb8e 100644 --- a/test/rss/test_maker_2.0.rb +++ b/test/rss/test_maker_2.0.rb @@ -82,17 +82,20 @@ module RSS maker.channel.lastBuildDate = lastBuildDate skipDays.each do |day| - new_day = maker.channel.skipDays.new_day - new_day.content = day + maker.channel.skipDays.new_day do |new_day| + new_day.content = day + end end skipHours.each do |hour| - new_hour = maker.channel.skipHours.new_hour - new_hour.content = hour + maker.channel.skipHours.new_hour do |new_hour| + new_hour.content = hour + end end categories.each do |category| - new_category = maker.channel.categories.new_category - new_category.content = category + maker.channel.categories.new_category do |new_category| + new_category.content = category + end end maker.channel.generator = generator @@ -368,13 +371,14 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" - item.author = "#{author}#{i}" - item.comments = "#{comments}#{i}" - item.date = pubDate + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + item.author = "#{author}#{i}" + item.comments = "#{comments}#{i}" + item.date = pubDate + end end maker.items.do_sort = true end @@ -393,13 +397,14 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" - item.author = "#{author}#{i}" - item.comments = "#{comments}#{i}" - item.date = pubDate + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + item.author = "#{author}#{i}" + item.comments = "#{comments}#{i}" + item.date = pubDate + end end maker.items.do_sort = Proc.new do |x, y| y.title[-1] <=> x.title[-1] @@ -557,9 +562,10 @@ module RSS setup_dummy_channel(maker) setup_dummy_item(maker) - category = maker.items.last.categories.new_category - category.domain = domain - category.content = content + maker.items.last.categories.new_category do |category| + category.domain = domain + category.content = content + end end category = rss.channel.items.last.categories.last assert_equal(domain, category.domain) @@ -573,8 +579,9 @@ module RSS setup_dummy_channel(maker) setup_dummy_item(maker) - category = maker.items.last.categories.new_category - # category.content = content + maker.items.last.categories.new_category do |category| + # category.content = content + end end assert(rss.channel.items.last.categories.empty?) end diff --git a/test/rss/test_maker_dc.rb b/test/rss/test_maker_dc.rb index 9f568ed441..6266e953aa 100644 --- a/test/rss/test_maker_dc.rb +++ b/test/rss/test_maker_dc.rb @@ -81,8 +81,9 @@ module RSS elems.each do |name, values, plural| dc_elems = item.__send__("dc_#{plural}") values.each do |value| - elem = dc_elems.__send__("new_#{name}") - elem.value = value + dc_elems.__send__("new_#{name}") do |elem| + elem.value = value + end end end @@ -102,14 +103,16 @@ module RSS rss = RSS::Maker.make("1.0") do |maker| setup_dummy_channel(maker) maker.channel.date = t1 - date = maker.channel.dc_dates.new_date - date.value = t2 + maker.channel.dc_dates.new_date do |date| + date.value = t2 + end setup_dummy_item(maker) item = maker.items.last item.date = t2 - date = item.dc_dates.new_date - date.value = t1 + item.dc_dates.new_date do |date| + date.value = t1 + end end assert_equal([t1, t2], rss.channel.dc_dates.collect{|x| x.value}) assert_equal([t2, t1], rss.items.last.dc_dates.collect{|x| x.value}) @@ -131,8 +134,9 @@ module RSS plural ||= "#{name}s" dc_elems = target.__send__("dc_#{plural}") values.each do |value| - new_dc_elem = dc_elems.__send__("new_#{name}") - new_dc_elem.value = value + dc_elems.__send__("new_#{name}") do |new_dc_elem| + new_dc_elem.value = value + end end end end diff --git a/test/rss/test_maker_taxo.rb b/test/rss/test_maker_taxo.rb index 1c7d2844ce..8feb4e1d33 100644 --- a/test/rss/test_maker_taxo.rb +++ b/test/rss/test_maker_taxo.rb @@ -56,14 +56,16 @@ module RSS rss = RSS::Maker.make("1.0") do |maker| setup_dummy_channel(maker) maker.channel.date = t1 - date = maker.channel.dc_dates.new_date - date.value = t2 + maker.channel.dc_dates.new_date do |date| + date.value = t2 + end setup_dummy_item(maker) item = maker.items.last item.date = t2 - date = item.dc_dates.new_date - date.value = t1 + item.dc_dates.new_date do |date| + date.value = t1 + end end assert_equal([t1, t2], rss.channel.dc_dates.collect{|x| x.value}) assert_equal([t2, t1], rss.items.last.dc_dates.collect{|x| x.value}) diff --git a/test/rss/test_maker_trackback.rb b/test/rss/test_maker_trackback.rb index e90bb600a3..58705c6f80 100644 --- a/test/rss/test_maker_trackback.rb +++ b/test/rss/test_maker_trackback.rb @@ -25,8 +25,9 @@ module RSS item = maker.items.last item.trackback_ping = @elements[:ping] @elements[:abouts].each do |about| - new_about = item.trackback_abouts.new_about - new_about.value = about + item.trackback_abouts.new_about do |new_about| + new_about.value = about + end end end assert_trackback(@elements, rss.items.last) diff --git a/test/rss/test_maker_xml-stylesheet.rb b/test/rss/test_maker_xml-stylesheet.rb index bbdfdc682b..c380f21dc3 100644 --- a/test/rss/test_maker_xml-stylesheet.rb +++ b/test/rss/test_maker_xml-stylesheet.rb @@ -14,14 +14,15 @@ module RSS alternate = 'yes' rss = RSS::Maker.make("1.0") do |maker| - xss = maker.xml_stylesheets.new_xml_stylesheet - xss.href = href - xss.type = type - xss.title = title - xss.media = media - xss.charset = charset - xss.alternate = alternate - + maker.xml_stylesheets.new_xml_stylesheet do |xss| + xss.href = href + xss.type = type + xss.title = title + xss.media = media + xss.charset = charset + xss.alternate = alternate + end + setup_dummy_channel(maker) end @@ -37,9 +38,10 @@ module RSS href = 'http://example.com/index.xsl' type = 'text/xsl' rss = RSS::Maker.make("1.0") do |maker| - xss = maker.xml_stylesheets.new_xml_stylesheet - xss.href = href - + maker.xml_stylesheets.new_xml_stylesheet do |xss| + xss.href = href + end + setup_dummy_channel(maker) end @@ -53,19 +55,21 @@ module RSS type = "text/xsl" rss = RSS::Maker.make("1.0") do |maker| - xss = maker.xml_stylesheets.new_xml_stylesheet - # xss.href = href - xss.type = type - + maker.xml_stylesheets.new_xml_stylesheet do |xss| + # xss.href = href + xss.type = type + end + setup_dummy_channel(maker) end assert(rss.xml_stylesheets.empty?) rss = RSS::Maker.make("1.0") do |maker| - xss = maker.xml_stylesheets.new_xml_stylesheet - xss.href = href - # xss.type = type - + maker.xml_stylesheets.new_xml_stylesheet do |xss| + xss.href = href + # xss.type = type + end + setup_dummy_channel(maker) end assert(rss.xml_stylesheets.empty?) diff --git a/test/rss/test_setup_maker_0.9.rb b/test/rss/test_setup_maker_0.9.rb index 086065c2bc..9408728371 100644 --- a/test/rss/test_setup_maker_0.9.rb +++ b/test/rss/test_setup_maker_0.9.rb @@ -40,12 +40,14 @@ module RSS maker.channel.lastBuildDate = lastBuildDate skipDays.each do |day| - new_day = maker.channel.skipDays.new_day - new_day.content = day + maker.channel.skipDays.new_day do |new_day| + new_day.content = day + end end skipHours.each do |hour| - new_hour = maker.channel.skipHours.new_hour - new_hour.content = hour + maker.channel.skipHours.new_hour do |new_hour| + new_hour.content = hour + end end end @@ -149,10 +151,11 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + end end end @@ -196,14 +199,15 @@ module RSS maker.encoding = encoding maker.standalone = standalone - xss = maker.xml_stylesheets.new_xml_stylesheet - xss.href = href - xss.type = type - xss.title = title - xss.media = media - xss.charset = charset - xss.alternate = alternate - + maker.xml_stylesheets.new_xml_stylesheet do |xss| + xss.href = href + xss.type = type + xss.title = title + xss.media = media + xss.charset = charset + xss.alternate = alternate + end + setup_dummy_channel(maker) end diff --git a/test/rss/test_setup_maker_1.0.rb b/test/rss/test_setup_maker_1.0.rb index 95d8b310ba..51a4d146c7 100644 --- a/test/rss/test_setup_maker_1.0.rb +++ b/test/rss/test_setup_maker_1.0.rb @@ -195,23 +195,25 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" - - @dc_elems.each do |var, value| - item.__send__("dc_#{var}=", value) - end - - @content_elems.each do |var, value| - item.__send__("content_#{var}=", value) - end - - item.trackback_ping = @trackback_elems[:ping] - @trackback_elems[:about].each do |value| - new_about = item.trackback_abouts.new_about - new_about.value = value + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + + @dc_elems.each do |var, value| + item.__send__("dc_#{var}=", value) + end + + @content_elems.each do |var, value| + item.__send__("content_#{var}=", value) + end + + item.trackback_ping = @trackback_elems[:ping] + @trackback_elems[:about].each do |value| + item.trackback_abouts.new_about do |new_about| + new_about.value = value + end + end end end end @@ -321,14 +323,15 @@ module RSS maker.encoding = encoding maker.standalone = standalone - xss = maker.xml_stylesheets.new_xml_stylesheet - xss.href = href - xss.type = type - xss.title = title - xss.media = media - xss.charset = charset - xss.alternate = alternate - + maker.xml_stylesheets.new_xml_stylesheet do |xss| + xss.href = href + xss.type = type + xss.title = title + xss.media = media + xss.charset = charset + xss.alternate = alternate + end + setup_dummy_channel(maker) end @@ -384,14 +387,15 @@ module RSS maker.encoding = encoding maker.standalone = standalone - xss = maker.xml_stylesheets.new_xml_stylesheet - xss.href = href - xss.type = type - xss.title = title - xss.media = media - xss.charset = charset - xss.alternate = alternate - + maker.xml_stylesheets.new_xml_stylesheet do |xss| + xss.href = href + xss.type = type + xss.title = title + xss.media = media + xss.charset = charset + xss.alternate = alternate + end + maker.channel.about = channel_about maker.channel.title = channel_title maker.channel.link = channel_link @@ -418,23 +422,25 @@ module RSS end item_size.times do |i| - item = maker.items.new_item - item.title = "#{item_title}#{i}" - item.link = "#{item_link}#{i}" - item.description = "#{item_description}#{i}" - - @dc_elems.each do |var, value| - item.__send__("dc_#{var}=", value) - end - - @content_elems.each do |var, value| - item.__send__("content_#{var}=", value) - end - - item.trackback_ping = @trackback_elems[:ping] - @trackback_elems[:about].each do |value| - new_about = item.trackback_abouts.new_about - new_about.value = value + maker.items.new_item do |item| + item.title = "#{item_title}#{i}" + item.link = "#{item_link}#{i}" + item.description = "#{item_description}#{i}" + + @dc_elems.each do |var, value| + item.__send__("dc_#{var}=", value) + end + + @content_elems.each do |var, value| + item.__send__("content_#{var}=", value) + end + + item.trackback_ping = @trackback_elems[:ping] + @trackback_elems[:about].each do |value| + item.trackback_abouts.new_about do |new_about| + new_about.value = value + end + end end end diff --git a/test/rss/test_setup_maker_2.0.rb b/test/rss/test_setup_maker_2.0.rb index a35096cf16..8fb727de8d 100644 --- a/test/rss/test_setup_maker_2.0.rb +++ b/test/rss/test_setup_maker_2.0.rb @@ -46,18 +46,21 @@ module RSS maker.channel.lastBuildDate = lastBuildDate skipDays.each do |day| - new_day = maker.channel.skipDays.new_day - new_day.content = day + maker.channel.skipDays.new_day do |new_day| + new_day.content = day + end end skipHours.each do |hour| - new_hour = maker.channel.skipHours.new_hour - new_hour.content = hour + maker.channel.skipHours.new_hour do |new_hour| + new_hour.content = hour + end end categories.each do |category| - new_category = maker.channel.categories.new_category - new_category.content = category + maker.channel.categories.new_category do |new_category| + new_category.content = category + end end maker.channel.generator = generator @@ -189,27 +192,28 @@ module RSS setup_dummy_channel(maker) item_size.times do |i| - item = maker.items.new_item - item.title = "#{title}#{i}" - item.link = "#{link}#{i}" - item.description = "#{description}#{i}" - item.author = "#{author}#{i}" - item.comments = "#{comments}#{i}" - item.date = pubDate - - item.guid.isPermaLink = guid_isPermaLink - item.guid.content = guid_content - - item.enclosure.url = enclosure_url - item.enclosure.length = enclosure_length - item.enclosure.type = enclosure_type - - item.source.url = source_url - item.source.content = source_content - - category = item.categories.new_category - category.domain = category_domain - category.content = category_content + maker.items.new_item do |item| + item.title = "#{title}#{i}" + item.link = "#{link}#{i}" + item.description = "#{description}#{i}" + item.author = "#{author}#{i}" + item.comments = "#{comments}#{i}" + item.date = pubDate + + item.guid.isPermaLink = guid_isPermaLink + item.guid.content = guid_content + + item.enclosure.url = enclosure_url + item.enclosure.length = enclosure_length + item.enclosure.type = enclosure_type + + item.source.url = source_url + item.source.content = source_content + + category = item.categories.new_category + category.domain = category_domain + category.content = category_content + end end end @@ -270,14 +274,15 @@ module RSS maker.encoding = encoding maker.standalone = standalone - xss = maker.xml_stylesheets.new_xml_stylesheet - xss.href = href - xss.type = type - xss.title = title - xss.media = media - xss.charset = charset - xss.alternate = alternate - + maker.xml_stylesheets.new_xml_stylesheet do |xss| + xss.href = href + xss.type = type + xss.title = title + xss.media = media + xss.charset = charset + xss.alternate = alternate + end + setup_dummy_channel(maker) end |