Extracting hpricot_document method
This commit is contained in:
parent
b1ef30c71d
commit
e7ddb4bdd1
|
@ -5,19 +5,23 @@ module Webrat #:nodoc:
|
||||||
if Webrat.configuration.parse_with_nokogiri?
|
if Webrat.configuration.parse_with_nokogiri?
|
||||||
Webrat.nokogiri_document(stringlike)
|
Webrat.nokogiri_document(stringlike)
|
||||||
else
|
else
|
||||||
return stringlike.dom if stringlike.respond_to?(:dom)
|
Webrat::XML.hpricot_document(stringlike)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if Hpricot::Doc === stringlike
|
def self.hpricot_document(stringlike)
|
||||||
stringlike
|
return stringlike.dom if stringlike.respond_to?(:dom)
|
||||||
elsif Hpricot::Elements === stringlike
|
|
||||||
stringlike
|
if Hpricot::Doc === stringlike
|
||||||
elsif StringIO === stringlike
|
stringlike
|
||||||
Hpricot(stringlike.string)
|
elsif Hpricot::Elements === stringlike
|
||||||
elsif stringlike.respond_to?(:body)
|
stringlike
|
||||||
Hpricot(stringlike.body.to_s)
|
elsif StringIO === stringlike
|
||||||
else
|
Hpricot(stringlike.string)
|
||||||
Hpricot(stringlike.to_s)
|
elsif stringlike.respond_to?(:body)
|
||||||
end
|
Hpricot(stringlike.body.to_s)
|
||||||
|
else
|
||||||
|
Hpricot(stringlike.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue