From a687b15ff8df120be282d939bc1ff21b1a4861fd Mon Sep 17 00:00:00 2001 From: kou Date: Sat, 16 May 2009 09:22:55 +0000 Subject: [PATCH] * lib/rss/maker.rb, lib/rss/maker/0.9.rb, test/test_maker_*.rb: add RSS::Maker.supported? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/rss/maker.rb | 4 ++++ lib/rss/maker/0.9.rb | 1 + test/rss/test_maker_0.9.rb | 11 +++++++++++ test/rss/test_maker_1.0.rb | 7 +++++++ test/rss/test_maker_2.0.rb | 7 +++++++ test/rss/test_maker_atom_entry.rb | 6 ++++++ test/rss/test_maker_atom_feed.rb | 9 +++++++++ 8 files changed, 50 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8012b7f1a7..c2c4184430 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat May 16 18:14:19 2009 Kouhei Sutou + + * lib/rss/maker.rb, lib/rss/maker/0.9.rb, + test/test_maker_*.rb: add RSS::Maker.supported? + Sat May 16 18:12:39 2009 Kouhei Sutou * lib/rss/content/*, lib/rss/dublincore/*: fix circular require. diff --git a/lib/rss/maker.rb b/lib/rss/maker.rb index ed3fff47d8..a7ee200b32 100644 --- a/lib/rss/maker.rb +++ b/lib/rss/maker.rb @@ -27,6 +27,10 @@ module RSS MAKERS.values.collect {|info| info[:maker]}.uniq end + def supported?(version) + versions.include?(version) + end + private # Can I remove this method? def maker(version) diff --git a/lib/rss/maker/0.9.rb b/lib/rss/maker/0.9.rb index ed992028cf..aede4d7c20 100644 --- a/lib/rss/maker/0.9.rb +++ b/lib/rss/maker/0.9.rb @@ -501,6 +501,7 @@ module RSS add_maker("0.9", "0.92", RSS092) add_maker("0.91", "0.91", RSS091) add_maker("0.92", "0.92", RSS092) + add_maker("rss0.9", "0.92", RSS092) add_maker("rss0.91", "0.91", RSS091) add_maker("rss0.92", "0.92", RSS092) end diff --git a/test/rss/test_maker_0.9.rb b/test/rss/test_maker_0.9.rb index 61b272d130..32aa183756 100644 --- a/test/rss/test_maker_0.9.rb +++ b/test/rss/test_maker_0.9.rb @@ -4,6 +4,17 @@ require "rss/maker" module RSS class TestMaker09 < TestCase + def test_supported? + assert(RSS::Maker.supported?("0.9")) + assert(RSS::Maker.supported?("rss0.9")) + assert(RSS::Maker.supported?("0.91")) + assert(RSS::Maker.supported?("rss0.91")) + assert(RSS::Maker.supported?("0.92")) + assert(RSS::Maker.supported?("rss0.92")) + assert(!RSS::Maker.supported?("0.93")) + assert(!RSS::Maker.supported?("rss0.93")) + end + def test_find_class assert_equal(RSS::Maker::RSS091, RSS::Maker["0.91"]) assert_equal(RSS::Maker::RSS091, RSS::Maker["rss0.91"]) diff --git a/test/rss/test_maker_1.0.rb b/test/rss/test_maker_1.0.rb index 47bfe99ba2..b465556979 100644 --- a/test/rss/test_maker_1.0.rb +++ b/test/rss/test_maker_1.0.rb @@ -4,6 +4,13 @@ require "rss/maker" module RSS class TestMaker10 < TestCase + def test_supported? + assert(RSS::Maker.supported?("1.0")) + assert(RSS::Maker.supported?("rss1.0")) + assert(!RSS::Maker.supported?("1.1")) + assert(!RSS::Maker.supported?("rss1.1")) + end + def test_find_class assert_equal(RSS::Maker::RSS10, RSS::Maker["1.0"]) assert_equal(RSS::Maker::RSS10, RSS::Maker["rss1.0"]) diff --git a/test/rss/test_maker_2.0.rb b/test/rss/test_maker_2.0.rb index 7285f11a72..6321ea5dce 100644 --- a/test/rss/test_maker_2.0.rb +++ b/test/rss/test_maker_2.0.rb @@ -4,6 +4,13 @@ require "rss/maker" module RSS class TestMaker20 < TestCase + def test_supported? + assert(RSS::Maker.supported?("2.0")) + assert(RSS::Maker.supported?("rss2.0")) + assert(!RSS::Maker.supported?("2.2")) + assert(!RSS::Maker.supported?("rss2.2")) + end + def test_find_class assert_equal(RSS::Maker::RSS20, RSS::Maker["2.0"]) assert_equal(RSS::Maker::RSS20, RSS::Maker["rss2.0"]) diff --git a/test/rss/test_maker_atom_entry.rb b/test/rss/test_maker_atom_entry.rb index 94e4255e9e..4275bdc685 100644 --- a/test/rss/test_maker_atom_entry.rb +++ b/test/rss/test_maker_atom_entry.rb @@ -4,6 +4,12 @@ require "rss/maker" module RSS class TestMakerAtomEntry < TestCase + def test_supported? + assert(RSS::Maker.supported?("atom:entry")) + assert(RSS::Maker.supported?("atom1.0:entry")) + assert(!RSS::Maker.supported?("atom2.0:entry")) + end + def test_find_class assert_equal(RSS::Maker::Atom::Entry, RSS::Maker["atom:entry"]) assert_equal(RSS::Maker::Atom::Entry, RSS::Maker["atom1.0:entry"]) diff --git a/test/rss/test_maker_atom_feed.rb b/test/rss/test_maker_atom_feed.rb index 2ca67e719a..724763b881 100644 --- a/test/rss/test_maker_atom_feed.rb +++ b/test/rss/test_maker_atom_feed.rb @@ -4,6 +4,15 @@ require "rss/maker" module RSS class TestMakerAtomFeed < TestCase + def test_supported? + assert(RSS::Maker.supported?("atom")) + assert(RSS::Maker.supported?("atom:feed")) + assert(RSS::Maker.supported?("atom1.0")) + assert(RSS::Maker.supported?("atom1.0:feed")) + assert(!RSS::Maker.supported?("atom2.0")) + assert(!RSS::Maker.supported?("atom2.0:feed")) + end + def test_find_class assert_equal(RSS::Maker::Atom::Feed, RSS::Maker["atom"]) assert_equal(RSS::Maker::Atom::Feed, RSS::Maker["atom:feed"])