From 51d202e6f32d65f05da8c4905d4e53ee7eb9a574 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 14 Sep 2009 12:51:20 -0700 Subject: Remove premature active_support/mini --- activesupport/lib/active_support/mini.rb | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 activesupport/lib/active_support/mini.rb (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/mini.rb b/activesupport/lib/active_support/mini.rb deleted file mode 100644 index b787650655..0000000000 --- a/activesupport/lib/active_support/mini.rb +++ /dev/null @@ -1,9 +0,0 @@ -$LOAD_PATH.unshift File.dirname(__FILE__) - -# whole object.rb pulls up rarely used introspection extensions -require "core_ext/object/blank" -require "core_ext/object/metaclass" -require 'core_ext/array' -require 'core_ext/hash' -require 'core_ext/module/attribute_accessors' -require 'core_ext/string/inflections' -- cgit v1.2.3 From 0d762646c4285437c12ddec9d0938c4ff1c3ef42 Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 16 Sep 2009 14:12:13 -0400 Subject: Allow Nokogiri XmlMini backend to process cdata elements [#3219 state:committed] Signed-off-by: Jeremy Kemper --- activesupport/lib/active_support/xml_mini/nokogiri.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/xml_mini/nokogiri.rb b/activesupport/lib/active_support/xml_mini/nokogiri.rb index 847ab0152b..3b2c6a96d9 100644 --- a/activesupport/lib/active_support/xml_mini/nokogiri.rb +++ b/activesupport/lib/active_support/xml_mini/nokogiri.rb @@ -44,7 +44,7 @@ module ActiveSupport walker = lambda { |memo, parent, child, callback| next if child.blank? && 'file' != parent['type'] - if child.text? + if child.text? || child.cdata? (memo[CONTENT_ROOT] ||= '') << child.content next end -- cgit v1.2.3 From 636624fbf2952e1fd46b95c9199048b3d6647870 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 17 Sep 2009 11:39:14 -0700 Subject: making nokogiri to hash less clever, more fast O_o [#2243 state:committed] Signed-off-by: Jeremy Kemper --- .../lib/active_support/xml_mini/nokogiri.rb | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/xml_mini/nokogiri.rb b/activesupport/lib/active_support/xml_mini/nokogiri.rb index 3b2c6a96d9..17bacd8441 100644 --- a/activesupport/lib/active_support/xml_mini/nokogiri.rb +++ b/activesupport/lib/active_support/xml_mini/nokogiri.rb @@ -18,7 +18,7 @@ module ActiveSupport {} else data.ungetc(char) - doc = Nokogiri::XML(data) + doc = Nokogiri::XML(data) { |cfg| cfg.noblanks } raise doc.errors.first if doc.errors.length > 0 doc.to_hash end @@ -39,33 +39,25 @@ module ActiveSupport # hash:: # Hash to merge the converted element into. def to_hash(hash = {}) - hash[name] ||= attributes_as_hash + attributes = attributes_as_hash + if hash[name] + hash[name] = [hash[name]].flatten + hash[name] << attributes + else + hash[name] ||= attributes + end - walker = lambda { |memo, parent, child, callback| - next if child.blank? && 'file' != parent['type'] + children.each { |child| + next if child.blank? && 'file' != self['type'] if child.text? || child.cdata? - (memo[CONTENT_ROOT] ||= '') << child.content + (attributes[CONTENT_ROOT] ||= '') << child.content next end - name = child.name - - child_hash = child.attributes_as_hash - if memo[name] - memo[name] = [memo[name]].flatten - memo[name] << child_hash - else - memo[name] = child_hash - end - - # Recursively walk children - child.children.each { |c| - callback.call(child_hash, child, c, callback) - } + child.to_hash attributes } - children.each { |c| walker.call(hash[name], self, c, walker) } hash end -- cgit v1.2.3