Moving requiring of Nokogiri/Hpricot/REXML to a method
This commit is contained in:
parent
ec8bc82c24
commit
f1b4486594
|
@ -12,22 +12,28 @@ module Webrat
|
||||||
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.require_xml
|
||||||
|
if on_java?
|
||||||
|
# We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
|
||||||
|
require "nokogiri/css"
|
||||||
|
require "hpricot"
|
||||||
|
require "rexml/document"
|
||||||
|
else
|
||||||
|
require "nokogiri"
|
||||||
|
require "webrat/core/nokogiri"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.on_java?
|
||||||
|
RUBY_PLATFORM =~ /java/
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_PLATFORM =~ /java/
|
Webrat.require_xml
|
||||||
# We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
|
|
||||||
require "nokogiri/css"
|
|
||||||
require "hpricot"
|
|
||||||
require "rexml/document"
|
|
||||||
else
|
|
||||||
require "nokogiri"
|
|
||||||
require "webrat/core/nokogiri"
|
|
||||||
end
|
|
||||||
|
|
||||||
require "webrat/core"
|
require "webrat/core"
|
||||||
|
|
||||||
# TODO: This is probably not a good idea.
|
# TODO: This is probably not a good idea.
|
||||||
# Probably better for webrat users to require "webrat/rails" etc. directly
|
# Probably better for webrat users to require "webrat/rails" etc. directly
|
||||||
if defined?(RAILS_ENV)
|
require "webrat/rails" if defined?(RAILS_ENV)
|
||||||
require "webrat/rails"
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue