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

* lib/rss/rss.rb, test/rss/test_version.rb, NEWS: 0.2.2 -> 0.2.3.

* lib/rss/parser.rb, test/rss/test_parser.rb: supported "-" in tag name.
  Reported by Ray Chen. Thanks.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@14753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2007-12-28 04:23:09 +00:00
parent a303540310
commit 1f84e89cf4
6 changed files with 38 additions and 17 deletions

View file

@ -1,3 +1,10 @@
Fri Dec 28 13:21:32 2007 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/rss.rb, test/rss/test_version.rb, NEWS: 0.2.2 -> 0.2.3.
* lib/rss/parser.rb, test/rss/test_parser.rb: supported "-" in tag name.
Reported by Ray Chen. Thanks.
Thu Dec 27 23:56:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Dec 27 23:56:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* mkconfig.rb: should not use the libraries under the source directory * mkconfig.rb: should not use the libraries under the source directory

2
NEWS
View file

@ -85,7 +85,7 @@ with all sufficient information, see the ChangeLog file.
* rss * rss
* 0.1.6 -> 0.2.2 * 0.1.6 -> 0.2.3
* Fix image module URI * Fix image module URI

View file

@ -194,11 +194,7 @@ module RSS
# return the tag_names for setters associated with uri # return the tag_names for setters associated with uri
def available_tags(uri) def available_tags(uri)
begin (@@accessor_bases[uri] || {}).keys
@@accessor_bases[uri].keys
rescue NameError
[]
end
end end
# register uri against this name. # register uri against this name.
@ -221,11 +217,13 @@ module RSS
# retrieve class_name for the supplied uri and tag_name # retrieve class_name for the supplied uri and tag_name
# If it doesn't exist, capitalize the tag_name # If it doesn't exist, capitalize the tag_name
def class_name(uri, tag_name) def class_name(uri, tag_name)
begin name = (@@class_names[uri] || {})[tag_name]
@@class_names[uri][tag_name] return name if name
rescue NameError
tag_name[0,1].upcase + tag_name[1..-1] tag_name = tag_name.gsub(/[_\-]([a-z]?)/) do
$1.upcase
end end
tag_name[0, 1].upcase + tag_name[1..-1]
end end
def install_get_text_element(uri, name, accessor_base) def install_get_text_element(uri, name, accessor_base)
@ -448,12 +446,14 @@ module RSS
end end
def start_have_something_element(tag_name, prefix, attrs, ns, klass) def start_have_something_element(tag_name, prefix, attrs, ns, klass)
check_ns(tag_name, prefix, ns, klass.required_uri) check_ns(tag_name, prefix, ns, klass.required_uri)
attributes = collect_attributes(tag_name, prefix, attrs, ns, klass)
@proc_stack.push(setup_next_element(tag_name, klass, attributes))
end
def collect_attributes(tag_name, prefix, attrs, ns, klass)
attributes = {} attributes = {}
klass.get_attributes.each do |a_name, a_uri, required, element_name| klass.get_attributes.each do |a_name, a_uri, required, element_name|
if a_uri.is_a?(String) or !a_uri.respond_to?(:include?) if a_uri.is_a?(String) or !a_uri.respond_to?(:include?)
a_uri = [a_uri] a_uri = [a_uri]
end end
@ -482,14 +482,18 @@ module RSS
attributes[a_name] = val attributes[a_name] = val
end end
attributes
end
def setup_next_element(tag_name, klass, attributes)
previous = @last_element previous = @last_element
next_element = klass.new(@do_validate, attributes) next_element = klass.new(@do_validate, attributes)
previous.set_next_element(tag_name, next_element) previous.set_next_element(tag_name, next_element)
@last_element = next_element @last_element = next_element
@last_element.parent = previous if klass.need_parent? @last_element.parent = previous if klass.need_parent?
@xml_child_mode = @last_element.have_xml_content? @xml_child_mode = @last_element.have_xml_content?
pr = Proc.new do |text, tags|
Proc.new do |text, tags|
p(@last_element.class) if DEBUG p(@last_element.class) if DEBUG
if @xml_child_mode if @xml_child_mode
@last_element.content = @xml_element.to_s @last_element.content = @xml_element.to_s
@ -510,9 +514,7 @@ module RSS
end end
@last_element = previous @last_element = previous
end end
@proc_stack.push(pr)
end end
end end
unless const_defined? :AVAILABLE_PARSER_LIBRARIES unless const_defined? :AVAILABLE_PARSER_LIBRARIES

View file

@ -52,7 +52,7 @@ require "rss/xml-stylesheet"
module RSS module RSS
VERSION = "0.2.2" VERSION = "0.2.3"
URI = "http://purl.org/rss/1.0/" URI = "http://purl.org/rss/1.0/"

View file

@ -46,5 +46,17 @@ EOR
assert_nil(RSS::Parser.parse(garbage_rss_file)) assert_nil(RSS::Parser.parse(garbage_rss_file))
end end
end end
def test_parse_tag_includes_hyphen
assert_nothing_raised do
RSS::Parser.parse(make_RDF(<<-EOR))
<xCal:x-calconnect-venue xmlns:xCal="urn:ietf:params:xml:ns:xcal" />
#{make_channel}
#{make_item}
#{make_textinput}
#{make_image}
EOR
end
end
end end
end end

View file

@ -3,7 +3,7 @@ require "rss-testcase"
module RSS module RSS
class TestVersion < TestCase class TestVersion < TestCase
def test_version def test_version
assert_equal("0.2.2", ::RSS::VERSION) assert_equal("0.2.3", ::RSS::VERSION)
end end
end end
end end