ruby-changes:11795
From: kou <ko1@a...>
Date: Sat, 16 May 2009 18:23:14 +0900 (JST)
Subject: [ruby-changes:11795] Ruby:r23450 (trunk): * lib/rss/maker.rb, lib/rss/maker/0.9.rb,
kou 2009-05-16 18:22:55 +0900 (Sat, 16 May 2009) New Revision: 23450 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23450 Log: * lib/rss/maker.rb, lib/rss/maker/0.9.rb, test/test_maker_*.rb: add RSS::Maker.supported? Modified files: trunk/ChangeLog trunk/lib/rss/maker/0.9.rb trunk/lib/rss/maker.rb trunk/test/rss/test_maker_0.9.rb trunk/test/rss/test_maker_1.0.rb trunk/test/rss/test_maker_2.0.rb trunk/test/rss/test_maker_atom_entry.rb trunk/test/rss/test_maker_atom_feed.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 23449) +++ ChangeLog (revision 23450) @@ -1,3 +1,8 @@ +Sat May 16 18:14:19 2009 Kouhei Sutou <kou@c...> + + * 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 <kou@c...> * lib/rss/content/*, lib/rss/dublincore/*: fix circular require. Index: lib/rss/maker/0.9.rb =================================================================== --- lib/rss/maker/0.9.rb (revision 23449) +++ lib/rss/maker/0.9.rb (revision 23450) @@ -501,6 +501,7 @@ 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 Index: lib/rss/maker.rb =================================================================== --- lib/rss/maker.rb (revision 23449) +++ lib/rss/maker.rb (revision 23450) @@ -27,6 +27,10 @@ MAKERS.values.collect {|info| info[:maker]}.uniq end + def supported?(version) + versions.include?(version) + end + private # Can I remove this method? def maker(version) Index: test/rss/test_maker_2.0.rb =================================================================== --- test/rss/test_maker_2.0.rb (revision 23449) +++ test/rss/test_maker_2.0.rb (revision 23450) @@ -4,6 +4,13 @@ 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"]) Index: test/rss/test_maker_atom_entry.rb =================================================================== --- test/rss/test_maker_atom_entry.rb (revision 23449) +++ test/rss/test_maker_atom_entry.rb (revision 23450) @@ -4,6 +4,12 @@ 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"]) Index: test/rss/test_maker_atom_feed.rb =================================================================== --- test/rss/test_maker_atom_feed.rb (revision 23449) +++ test/rss/test_maker_atom_feed.rb (revision 23450) @@ -4,6 +4,15 @@ 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"]) Index: test/rss/test_maker_1.0.rb =================================================================== --- test/rss/test_maker_1.0.rb (revision 23449) +++ test/rss/test_maker_1.0.rb (revision 23450) @@ -4,6 +4,13 @@ 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"]) Index: test/rss/test_maker_0.9.rb =================================================================== --- test/rss/test_maker_0.9.rb (revision 23449) +++ test/rss/test_maker_0.9.rb (revision 23450) @@ -4,6 +4,17 @@ 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"]) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/