From 01c35c817528cc54c8c28f56786e92ff292e3c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Mon, 9 Apr 2007 15:33:38 +0000 Subject: Removed ill faded xml_node class from codebase. Use XmlSimple instead git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6511 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_controller/cgi_ext/cgi_methods.rb | 6 +- .../lib/action_controller/vendor/xml_node.rb | 97 ---------------------- 2 files changed, 1 insertion(+), 102 deletions(-) delete mode 100644 actionpack/lib/action_controller/vendor/xml_node.rb (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb index b06966729a..abf70cc76a 100755 --- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb +++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb @@ -1,5 +1,4 @@ require 'cgi' -require 'action_controller/vendor/xml_node' require 'strscan' # Static methods for parsing the query and request parameters that can be used in @@ -49,13 +48,10 @@ class CGIMethods #:nodoc: case strategy = ActionController::Base.param_parsers[mime_type] when Proc strategy.call(raw_post_data) - when :xml_simple + when :xml_simple, :xml_node raw_post_data.blank? ? {} : Hash.from_xml(raw_post_data) when :yaml YAML.load(raw_post_data) - when :xml_node - node = XmlNode.from_xml(raw_post_data) - { node.node_name => node } end rescue Exception => e # YAML, XML or Ruby code block errors { "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace, diff --git a/actionpack/lib/action_controller/vendor/xml_node.rb b/actionpack/lib/action_controller/vendor/xml_node.rb deleted file mode 100644 index d07bef142a..0000000000 --- a/actionpack/lib/action_controller/vendor/xml_node.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'rexml/document' - -# SimpleXML like xml parser. Written by leon breet from the ruby on rails Mailing list -class XmlNode #:nodoc: - attr :node - - def initialize(node, options = {}) - @node = node - @children = {} - @raise_errors = options[:raise_errors] - end - - def self.from_xml(xml_or_io) - document = REXML::Document.new(xml_or_io) - if document.root - XmlNode.new(document.root) - else - XmlNode.new(document) - end - end - - def node_encoding - @node.encoding - end - - def node_name - @node.name - end - - def node_value - @node.text - end - - def node_value=(value) - @node.text = value - end - - def xpath(expr) - matches = nil - REXML::XPath.each(@node, expr) do |element| - matches ||= XmlNodeList.new - matches << (@children[element] ||= XmlNode.new(element)) - end - matches - end - - def method_missing(name, *args) - name = name.to_s - nodes = nil - @node.each_element(name) do |element| - nodes ||= XmlNodeList.new - nodes << (@children[element] ||= XmlNode.new(element)) - end - nodes - end - - def <<(node) - if node.is_a? REXML::Node - child = node - elsif node.respond_to? :node - child = node.node - end - @node.add_element child - @children[child] ||= XmlNode.new(child) - end - - def [](name) - @node.attributes[name.to_s] - end - - def []=(name, value) - @node.attributes[name.to_s] = value - end - - def to_s - @node.to_s - end - - def to_i - to_s.to_i - end -end - -class XmlNodeList < Array #:nodoc: - def [](i) - i.is_a?(String) ? super(0)[i] : super(i) - end - - def []=(i, value) - i.is_a?(String) ? self[0][i] = value : super(i, value) - end - - def method_missing(name, *args) - name = name.to_s - self[0].__send__(name, *args) - end -end \ No newline at end of file -- cgit v1.2.3