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

ruby-changes:3260

From: ko1@a...
Date: 28 Dec 2007 13:23:23 +0900
Subject: [ruby-changes:3260] kou - Ruby:r14753 (ruby_1_8): * lib/rss/rss.rb, test/rss/test_version.rb, NEWS: 0.2.2 -> 0.2.3.

kou	2007-12-28 13:23:09 +0900 (Fri, 28 Dec 2007)

  New Revision: 14753

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/NEWS
    branches/ruby_1_8/lib/rss/parser.rb
    branches/ruby_1_8/lib/rss/rss.rb
    branches/ruby_1_8/test/rss/test_parser.rb
    branches/ruby_1_8/test/rss/test_version.rb

  Log:
    * 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.


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

Index: ruby_1_8/NEWS
===================================================================
--- ruby_1_8/NEWS	(revision 14752)
+++ ruby_1_8/NEWS	(revision 14753)
@@ -85,7 +85,7 @@
 
 * rss
 
-  * 0.1.6 -> 0.2.2
+  * 0.1.6 -> 0.2.3
 
   * Fix image module URI
 
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 14752)
+++ ruby_1_8/ChangeLog	(revision 14753)
@@ -1,3 +1,10 @@
+Fri Dec 28 13:21:32 2007  Kouhei Sutou  <kou@c...>
+
+	* 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@r...>
 
 	* mkconfig.rb: should not use the libraries under the source directory
Index: ruby_1_8/lib/rss/parser.rb
===================================================================
--- ruby_1_8/lib/rss/parser.rb	(revision 14752)
+++ ruby_1_8/lib/rss/parser.rb	(revision 14753)
@@ -194,11 +194,7 @@
 
       # return the tag_names for setters associated with uri
       def available_tags(uri)
-        begin
-          @@accessor_bases[uri].keys
-        rescue NameError
-          []
-        end
+        (@@accessor_bases[uri] || {}).keys
       end
       
       # register uri against this name.
@@ -221,11 +217,13 @@
       # retrieve class_name for the supplied uri and tag_name
       # If it doesn't exist, capitalize the tag_name
       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)
@@ -448,12 +446,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
@@ -482,14 +482,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
@@ -510,9 +514,7 @@
         end
         @last_element = previous
       end
-      @proc_stack.push(pr)
     end
-
   end
 
   unless const_defined? :AVAILABLE_PARSER_LIBRARIES
Index: ruby_1_8/lib/rss/rss.rb
===================================================================
--- ruby_1_8/lib/rss/rss.rb	(revision 14752)
+++ ruby_1_8/lib/rss/rss.rb	(revision 14753)
@@ -52,7 +52,7 @@
 
 module RSS
 
-  VERSION = "0.2.2"
+  VERSION = "0.2.3"
 
   URI = "http://purl.org/rss/1.0/"
 
Index: ruby_1_8/test/rss/test_version.rb
===================================================================
--- ruby_1_8/test/rss/test_version.rb	(revision 14752)
+++ ruby_1_8/test/rss/test_version.rb	(revision 14753)
@@ -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: ruby_1_8/test/rss/test_parser.rb
===================================================================
--- ruby_1_8/test/rss/test_parser.rb	(revision 14752)
+++ ruby_1_8/test/rss/test_parser.rb	(revision 14753)
@@ -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

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