[前][次][番号順一覧][スレッド一覧]

ruby-changes:3259

From: ko1@a...
Date: 28 Dec 2007 13:21:29 +0900
Subject: [ruby-changes:3259] kou - Ruby:r14752 (trunk): * lib/rss/rss.rb, test/rss/test_version.rb: 0.2.2 -> 0.2.3.

kou	2007-12-28 13:20:47 +0900 (Fri, 28 Dec 2007)

  New Revision: 14752

  Modified files:
    trunk/ChangeLog
    trunk/lib/rss/parser.rb
    trunk/lib/rss/rss.rb
    trunk/test/rss/test_parser.rb
    trunk/test/rss/test_version.rb

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


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_version.rb?r1=14752&r2=14751
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rss/rss.rb?r1=14752&r2=14751
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14752&r2=14751
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_parser.rb?r1=14752&r2=14751
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rss/parser.rb?r1=14752&r2=14751

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14751)
+++ ChangeLog	(revision 14752)
@@ -1,3 +1,10 @@
+Fri Dec 28 13:18:47 2007  Kouhei Sutou  <kou@c...>
+
+	* lib/rss/rss.rb, test/rss/test_version.rb: 0.2.2 -> 0.2.3.
+
+	* lib/rss/parser.rb, test/rss/test_parser.rb: supported "-" in tag name.
+	Reported by Ray Chen. Thanks.
+
 Fri Dec 28 13:07:31 2007  Nobuyoshi Nakada  <nobu@r...>
 
 	* gc.c (os_obj_of): returns an enumerator if no block given.  based on
Index: lib/rss/parser.rb
===================================================================
--- lib/rss/parser.rb	(revision 14751)
+++ lib/rss/parser.rb	(revision 14752)
@@ -178,11 +178,7 @@
       end
 
       def available_tags(uri)
-        begin
-          @@accessor_bases[uri].keys
-        rescue NameError
-          []
-        end
+        (@@accessor_bases[uri] || {}).keys
       end
       
       def register_uri(uri, name)
@@ -200,11 +196,13 @@
       end
 
       def class_name(uri, tag_name)
-        begin
-          @@class_names[uri][tag_name]
-        rescue NameError
-          tag_name[0,1].upcase + tag_name[1..-1]
+        name = (@@class_names[uri] || {})[tag_name]
+        return name if name
+
+        tag_name = tag_name.gsub(/[_\-]([a-z]?)/) do
+          $1.upcase
         end
+        tag_name[0, 1].upcase + tag_name[1..-1]
       end
 
       def install_get_text_element(uri, name, accessor_base)
@@ -422,12 +420,14 @@
     end
 
     def start_have_something_element(tag_name, prefix, attrs, ns, klass)
-
       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 = {}
       klass.get_attributes.each do |a_name, a_uri, required, element_name|
-
         if a_uri.is_a?(String) or !a_uri.respond_to?(:include?)
           a_uri = [a_uri]
         end
@@ -456,14 +456,18 @@
 
         attributes[a_name] = val
       end
+      attributes
+    end
 
+    def setup_next_element(tag_name, klass, attributes)
       previous = @last_element
       next_element = klass.new(@do_validate, attributes)
       previous.set_next_element(tag_name, next_element)
       @last_element = next_element
       @last_element.parent = previous if klass.need_parent?
       @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
         if @xml_child_mode
           @last_element.content = @xml_element.to_s
@@ -484,9 +488,7 @@
         end
         @last_element = previous
       end
-      @proc_stack.push(pr)
     end
-
   end
 
   unless const_defined? :AVAILABLE_PARSER_LIBRARIES
Index: lib/rss/rss.rb
===================================================================
--- lib/rss/rss.rb	(revision 14751)
+++ lib/rss/rss.rb	(revision 14752)
@@ -53,7 +53,7 @@
 
 module RSS
 
-  VERSION = "0.2.2"
+  VERSION = "0.2.3"
 
   URI = "http://purl.org/rss/1.0/"
 
Index: test/rss/test_version.rb
===================================================================
--- test/rss/test_version.rb	(revision 14751)
+++ test/rss/test_version.rb	(revision 14752)
@@ -3,7 +3,7 @@
 module RSS
   class TestVersion < TestCase
     def test_version
-      assert_equal("0.2.2", ::RSS::VERSION)
+      assert_equal("0.2.3", ::RSS::VERSION)
     end
   end
 end
Index: test/rss/test_parser.rb
===================================================================
--- test/rss/test_parser.rb	(revision 14751)
+++ test/rss/test_parser.rb	(revision 14752)
@@ -46,5 +46,17 @@
         assert_nil(RSS::Parser.parse(garbage_rss_file))
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]