aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/xml_mini.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-09 12:46:06 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-09 13:00:57 -0700
commit87d82ef76e88d7ce97cfc09151b677b552f2840a (patch)
tree5ce0f6147cb0da934e658b181546a72b473021b2 /activesupport/lib/active_support/xml_mini.rb
parent146511e0181a8c6703dcff7b5236d81b64841dd5 (diff)
downloadrails-87d82ef76e88d7ce97cfc09151b677b552f2840a.tar.gz
rails-87d82ef76e88d7ce97cfc09151b677b552f2840a.tar.bz2
rails-87d82ef76e88d7ce97cfc09151b677b552f2840a.zip
Require libxml-ruby 0.9.4 or 0.9.7 pending a segfault bugfix for 1.0.
Delegate parsing to a switchable backend.
Diffstat (limited to 'activesupport/lib/active_support/xml_mini.rb')
-rw-r--r--activesupport/lib/active_support/xml_mini.rb26
1 files changed, 12 insertions, 14 deletions
diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb
index 8ae8e7cefe..d2a882b685 100644
--- a/activesupport/lib/active_support/xml_mini.rb
+++ b/activesupport/lib/active_support/xml_mini.rb
@@ -1,21 +1,19 @@
-# = XmlMini
module ActiveSupport
+ # = XmlMini
module XmlMini
extend self
+ delegate :parse, :to => :@backend
- CONTENT_KEY = '__content__'.freeze
-
- # Hook the correct parser into XmlMini
- def hook_parser
- begin
- require 'xml/libxml' unless defined? LibXML
- require "active_support/xml_mini/libxml.rb"
- rescue MissingSourceFile => e
- require "active_support/xml_mini/rexml.rb"
- end
+ def backend=(name)
+ require "active_support/xml_mini/#{name.to_s.downcase}.rb"
+ @backend = ActiveSupport.const_get("XmlMini_#{name}")
end
+ end
- hook_parser
-
+ begin
+ gem 'libxml-ruby', '=0.9.4', '=0.9.7'
+ XmlMini.backend = 'LibXML'
+ rescue Gem::LoadError
+ XmlMini.backend = 'REXML'
end
-end \ No newline at end of file
+end