mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/rss.rb: fixed a indentation bug.
* lib/rss/taxonomy.rb: fixed <taxo:topic> #to_s bug. * test/rss/test_taxonomy.rb: added a #to_s test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7ff5d02f8b
commit
f988ceb53b
4 changed files with 37 additions and 12 deletions
|
@ -1,3 +1,11 @@
|
|||
Wed Nov 23 17:42:24 2005 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rss/rss.rb: fixed a indentation bug.
|
||||
|
||||
* lib/rss/taxonomy.rb: fixed <taxo:topic> #to_s bug.
|
||||
|
||||
* test/rss/test_taxonomy.rb: added a #to_s test.
|
||||
|
||||
Wed Nov 23 03:40:49 2005 Guy Decoux <ts@moulon.inra.fr>
|
||||
|
||||
* re.c (KR_REHASH): should cast to unsigned for 64bit CPU.
|
||||
|
|
|
@ -725,8 +725,8 @@ EOC
|
|||
private_methods.each do |meth|
|
||||
if /\A([^_]+)_[^_]+_elements?\z/ =~ meth and
|
||||
self.class::NSPOOL.has_key?($1)
|
||||
res = __send__(meth, need_convert)
|
||||
rv << "#{indent}#{res}" if /\A\s*\z/ !~ res
|
||||
res = __send__(meth, need_convert, indent)
|
||||
rv << res if /\A\s*\z/ !~ res
|
||||
end
|
||||
end
|
||||
rv.join("\n")
|
||||
|
|
|
@ -163,7 +163,6 @@ module RSS
|
|||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
link_element(need_convert, next_indent),
|
||||
other_element(need_convert, next_indent),
|
||||
]
|
||||
end
|
||||
|
@ -189,6 +188,12 @@ module RSS
|
|||
[@taxo_link, @taxo_topics]
|
||||
end
|
||||
|
||||
def _attrs
|
||||
[
|
||||
["#{RDF::PREFIX}:about", true, "about"]
|
||||
]
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = []
|
||||
rv << [TAXO_URI, "link"] unless @taxo_link.nil?
|
||||
|
|
|
@ -20,7 +20,7 @@ module RSS
|
|||
@dc_prefix => @dc_uri,
|
||||
}
|
||||
|
||||
@parents = %w(channel item)
|
||||
@topics_parents = %w(channel item)
|
||||
|
||||
@topics_lis = [
|
||||
"http://meerkat.oreillynet.com/?c=cat23",
|
||||
|
@ -66,28 +66,28 @@ module RSS
|
|||
info.each do |name, value|
|
||||
case name
|
||||
when :topics
|
||||
rv << "<#{@prefix}:topics>\n"
|
||||
rv << " <rdf:Bag>\n"
|
||||
rv << " <#{@prefix}:topics>\n"
|
||||
rv << " <rdf:Bag>\n"
|
||||
value.each do |li|
|
||||
resource = CGI.escapeHTML(li)
|
||||
rv << " <rdf:li resource=\"#{resource}\"/>\n"
|
||||
rv << " <rdf:li resource=\"#{resource}\"/>\n"
|
||||
end
|
||||
rv << " </rdf:Bag>\n"
|
||||
rv << "</#{@prefix}:topics>"
|
||||
rv << " </rdf:Bag>\n"
|
||||
rv << " </#{@prefix}:topics>\n"
|
||||
else
|
||||
prefix = (name == :link ? @prefix : @dc_prefix)
|
||||
rv << " <#{prefix}:#{name}>#{value}</#{prefix}:#{name}>\n"
|
||||
end
|
||||
end
|
||||
rv << "</#{@prefix}:topic>"
|
||||
end.join("\n")
|
||||
end
|
||||
|
||||
@rss_source = make_RDF(<<-EOR, @ns)
|
||||
#{make_channel(@topics_node)}
|
||||
#{make_image()}
|
||||
#{make_item(@topics_node)}
|
||||
#{make_textinput()}
|
||||
#{@topic_nodes}
|
||||
#{@topic_nodes.join("\n")}
|
||||
EOR
|
||||
|
||||
@rss = Parser.parse(@rss_source)
|
||||
|
@ -138,10 +138,22 @@ EOR
|
|||
end
|
||||
|
||||
def test_to_s
|
||||
@parents.each do |parent|
|
||||
@topics_parents.each do |parent|
|
||||
meth = "taxo_topics_element"
|
||||
assert_equal(@topics_node, @rss.__send__(parent).funcall(meth))
|
||||
end
|
||||
|
||||
@topic_nodes.each_with_index do |node, i|
|
||||
expected = REXML::Document.new(node).root
|
||||
actual = REXML::Document.new(@rss.taxo_topics[i].to_s(true, "")).root
|
||||
expected_elems = expected.children.reject {|x| x.is_a?(REXML::Text)}
|
||||
actual_elems = actual.children.reject {|x| x.is_a?(REXML::Text)}
|
||||
expected_elems.sort! {|x, y| x.name <=> y.name}
|
||||
actual_elems.sort! {|x, y| x.name <=> y.name}
|
||||
assert_equal(expected_elems.collect {|x| x.to_s},
|
||||
actual_elems.collect {|x| x.to_s})
|
||||
assert_equal(expected.attributes.sort, actual.attributes.sort)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue