1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rss/maker/base.rb (RSS::Maker::RSSBase#to_feed): raise

exception not return nil if RSS::Maker.make can't get required information.
* test/rss/rss-assertions.rb: follow the above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2008-06-29 08:42:46 +00:00
parent 7556f66e9c
commit 94031b9628
3 changed files with 40 additions and 20 deletions

View file

@ -1,3 +1,10 @@
Sun Jun 29 17:41:42 2008 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/maker/base.rb (RSS::Maker::RSSBase#to_feed): raise
exception not return nil if RSS::Maker.make can't get required
information.
* test/rss/rss-assertions.rb: follow the above change.
Sun Jun 29 17:37:23 2008 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/maker/base.rb (RSS::Maker::RSSBase#make): require block.

View file

@ -420,11 +420,8 @@ module RSS
setup_xml_stylesheets(feed)
setup_elements(feed)
setup_other_elements(feed)
if feed.valid?
feed
else
nil
end
feed.validate
feed
end
private

View file

@ -1272,22 +1272,32 @@ EOA
invalid_feed_checker=nil)
_wrap_assertion do
elements = []
invalid_feed = false
feed = RSS::Maker.make("atom:#{feed_type}") do |maker|
yield maker
targets = chain_reader(maker, maker_readers)
targets.each do |target|
element = maker_extractor.call(target)
elements << element if element
invalid_feed_exception = nil
feed = nil
begin
feed = RSS::Maker.make("atom:#{feed_type}") do |maker|
yield maker
targets = chain_reader(maker, maker_readers)
targets.each do |target|
element = maker_extractor.call(target)
elements << element if element
end
if invalid_feed_checker
invalid_feed_exception = invalid_feed_checker.call(targets)
end
end
if invalid_feed_checker
invalid_feed = invalid_feed_checker.call(targets)
rescue RSS::Error
if invalid_feed_exception.is_a?(RSS::TooMuchTagError)
assert_too_much_tag(invalid_feed_exception.tag,
invalid_feed_exception.parent) do
raise
end
else
raise
end
end
if invalid_feed
assert_nil(feed)
else
if invalid_feed_exception.nil?
actual_elements = chain_reader(feed, feed_readers) || []
actual_elements = actual_elements.collect do |target|
feed_extractor.call(target)
@ -1542,18 +1552,24 @@ EOA
:length => target.length,
}
end
if feed_readers.first == "entries"
parent = "entry"
else
parent = feed_type
end
invalid_feed_checker = Proc.new do |targets|
infos = {}
invalid = false
invalid_exception = nil
targets.each do |target|
key = [target.hreflang, target.type]
if infos.has_key?(key)
invalid = true
invalid_exception = RSS::TooMuchTagError.new("link", parent)
break
end
infos[key] = true if target.rel.nil? or target.rel == "alternate"
end
invalid
invalid_exception
end
invalid_feed_checker = nil if allow_duplication
_assert_maker_atom_elements(feed_type, maker_readers, feed_readers,