From dcec1c3d4940842a65d38d2191d5c4889e03cc8a Mon Sep 17 00:00:00 2001 From: kou Date: Sat, 17 Jun 2006 00:17:32 +0000 Subject: [PATCH] * lib/rss, test/rss: backported from trunk. (2005-11-16 - now) * lib/rss/1.0.rb: added convenience method 'resources'. * lib/rss/taxonomy.rb: ditto. * test/rss/rss-assertions.rb: added test for 'resources'. * test/rss/test_taxonomy.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/rss/1.0.rb | 13 ++++++++++--- lib/rss/taxonomy.rb | 10 ++++++++++ test/rss/rss-assertions.rb | 1 + test/rss/test_taxonomy.rb | 4 ++-- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85f4a14fab..9b43e12285 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,11 @@ Sat Jun 17 09:03:47 2006 Kouhei Sutou * lib/rss/taxonomy.rb: implemented taxonomy module. * test/rss/test_taxonomy.rb: added tests for taxonomy support. + * lib/rss/1.0.rb: added convenience method 'resources'. + * lib/rss/taxonomy.rb: ditto. + * test/rss/rss-assertions.rb: added test for 'resources'. + * test/rss/test_taxonomy.rb: ditto. + Sat Jun 17 02:01:00 2006 Tanaka Akira * lib/pp.rb (Kernel#pretty_inspect): defined for pretty printed diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb index be3ff7d411..5c7e3f5e62 100644 --- a/lib/rss/1.0.rb +++ b/lib/rss/1.0.rb @@ -438,12 +438,21 @@ module RSS end end + def resources + if @Seq + @Seq.lis.collect do |li| + li.resource + end + else + [] + end + end + private def children [@Seq] end - private def _tags rv = [] rv << [URI, 'Seq'] unless @Seq.nil? @@ -453,9 +462,7 @@ module RSS def rdf_validate(tags) _validate(tags, [["Seq", nil]]) end - end - end class Image < Element diff --git a/lib/rss/taxonomy.rb b/lib/rss/taxonomy.rb index d7a5b6d19e..c89de64d31 100644 --- a/lib/rss/taxonomy.rb +++ b/lib/rss/taxonomy.rb @@ -86,6 +86,16 @@ module RSS end end + def resources + if @Bag + @Bag.lis.collect do |li| + li.resource + end + else + [] + end + end + private def children [@Bag] diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb index 2636062519..f5e8c5ccaa 100644 --- a/test/rss/rss-assertions.rb +++ b/test/rss/rss-assertions.rb @@ -193,6 +193,7 @@ module RSS def assert_channel10_items(attrs, items) _wrap_assertion do + assert_equal(items.resources, items.Seq.lis.collect {|x| x.resource}) items.Seq.lis.each_with_index do |li, i| assert_attributes(attrs[i], %w(resource), li) end diff --git a/test/rss/test_taxonomy.rb b/test/rss/test_taxonomy.rb index 9d9665c476..c899f4720b 100644 --- a/test/rss/test_taxonomy.rb +++ b/test/rss/test_taxonomy.rb @@ -117,6 +117,7 @@ EOR topics = @rss.channel.taxo_topics assert_equal(@topics_lis.sort, topics.Bag.lis.collect {|li| li.resource}.sort) + assert_equal(@topics_lis.sort, topics.resources.sort) assert_equal(@rss.taxo_topics.first, @rss.taxo_topic) @@ -128,8 +129,7 @@ EOR assert_equal(value, topic.about) assert_equal(value, topic.taxo_link) when :topics - assert_equal(value.sort, - topic.taxo_topics.Bag.lis.collect {|li| li.resource}.sort) + assert_equal(value.sort, topic.taxo_topics.resources.sort) else assert_equal(value, topic.__send__("dc_#{name}")) end