aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-09-21 14:57:24 -0300
committerEmilio Tagua <miloops@gmail.com>2009-09-21 14:57:24 -0300
commita294d8362bfb62b7133ad0799ae1327cd5ddd1e4 (patch)
tree477930041d5c42f2453178ab110c8455c6d702fe /activesupport/lib/active_support
parent378b02d3aa890cedabf1ef81c34a371dbbc52c25 (diff)
parente2d0b0ee61c5a8c2626abb5ac1029b48ec1965eb (diff)
downloadrails-a294d8362bfb62b7133ad0799ae1327cd5ddd1e4.tar.gz
rails-a294d8362bfb62b7133ad0799ae1327cd5ddd1e4.tar.bz2
rails-a294d8362bfb62b7133ad0799ae1327cd5ddd1e4.zip
Merge commit 'rails/master'
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/mini.rb9
-rw-r--r--activesupport/lib/active_support/xml_mini/nokogiri.rb34
2 files changed, 13 insertions, 30 deletions
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'
diff --git a/activesupport/lib/active_support/xml_mini/nokogiri.rb b/activesupport/lib/active_support/xml_mini/nokogiri.rb
index 847ab0152b..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?
- (memo[CONTENT_ROOT] ||= '') << child.content
+ if child.text? || child.cdata?
+ (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