summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/rss/1.0.rb13
-rw-r--r--lib/rss/taxonomy.rb10
-rw-r--r--test/rss/rss-assertions.rb1
-rw-r--r--test/rss/test_taxonomy.rb4
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 <kou@cozmixng.org>
* 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 <akr@m17n.org>
* 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