diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | lib/rss/1.0.rb | 13 | ||||
-rw-r--r-- | lib/rss/taxonomy.rb | 10 | ||||
-rw-r--r-- | test/rss/rss-assertions.rb | 1 | ||||
-rw-r--r-- | test/rss/test_taxonomy.rb | 4 |
5 files changed, 33 insertions, 5 deletions
@@ -1,3 +1,13 @@ +Thu Nov 17 17:58:00 2005 Kouhei Sutou <[email protected]> + + * 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. + Thu Nov 17 17:53:30 2005 Kouhei Sutou <[email protected]> * lib/rss/taxonomy.rb: implemented taxonomy module. 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 0ece7b340e..fda4c9407b 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 |