Sha256: 214d6bf1268538f03423c7cc305d18925ef37448e444e0bbce1b6ceb8835a52c

Contents?: true

Size: 1.83 KB

Versions: 35

Compression:

Stored size: 1.83 KB

Contents

require "webrat/core_extensions/meta_class"

module Webrat
  
  def self.nokogiri_document(stringlike) #:nodoc:
    return stringlike.dom if stringlike.respond_to?(:dom)
    
    if Nokogiri::HTML::Document === stringlike
      stringlike
    elsif Nokogiri::XML::NodeSet === stringlike
      stringlike
    elsif StringIO === stringlike
      Nokogiri::HTML(stringlike.string)
    elsif stringlike.respond_to?(:body)
      Nokogiri::HTML(stringlike.body.to_s)
    else
      Nokogiri::HTML(stringlike.to_s)
    end
  end
  
  def self.html_nokogiri_document(stringlike) #:nodoc:
    return stringlike.dom if stringlike.respond_to?(:dom)
    
    if Nokogiri::HTML::Document === stringlike
      stringlike
    elsif Nokogiri::XML::NodeSet === stringlike
      stringlike
    elsif StringIO === stringlike
      Nokogiri::HTML(stringlike.string)
    elsif stringlike.respond_to?(:body)
      Nokogiri::HTML(stringlike.body.to_s)
    else
      Nokogiri::HTML(stringlike.to_s)
    end
  end
  
  def self.xml_nokogiri_document(stringlike) #:nodoc:
    return stringlike.dom if stringlike.respond_to?(:dom)
    
    if Nokogiri::HTML::Document === stringlike
      stringlike
    elsif Nokogiri::XML::NodeSet === stringlike
      stringlike
    elsif StringIO === stringlike
      Nokogiri::XML(stringlike.string)
    elsif stringlike.respond_to?(:body)
      Nokogiri::XML(stringlike.body.to_s)
    else
      Nokogiri::XML(stringlike.to_s)
    end
  end
  
  def self.define_dom_method(object, dom) #:nodoc:
    object.meta_class.send(:define_method, :dom) do
      dom
    end
  end
  
end


module Nokogiri #:nodoc:
  module CSS #:nodoc:
    class XPathVisitor #:nodoc:
      
      def visit_pseudo_class_text(node) #:nodoc:
        "@type='text'"
      end

      def visit_pseudo_class_password(node) #:nodoc:
        "@type='password'"
      end
      
    end
  end
end

Version data entries

35 entries across 35 versions & 11 rubygems

Version Path
adva-0.2.4 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.2.3 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.2.2 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.2.1 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.2.0 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.1.4 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.1.3 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.1.2 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.1.1 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.1.0 test/webrat/lib/webrat/core/xml/nokogiri.rb
adva-0.0.1 test/webrat/lib/webrat/core/xml/nokogiri.rb
auxesis-webrat-0.4.1 lib/webrat/core/xml/nokogiri.rb
brynary-webrat-0.4.0 lib/webrat/core/xml/nokogiri.rb
diabolo-webrat-0.4.2 lib/webrat/core/xml/nokogiri.rb
hectoregm-webrat-0.4.2 lib/webrat/core/xml/nokogiri.rb
jferris-webrat-0.4.3.0.1238640835 lib/webrat/core/xml/nokogiri.rb
jferris-webrat-0.4.3 lib/webrat/core/xml/nokogiri.rb
jwilger-webrat-0.4.2.1 lib/webrat/core/xml/nokogiri.rb
jwilger-webrat-0.4.2.2 lib/webrat/core/xml/nokogiri.rb
jwilger-webrat-0.4.2.3 lib/webrat/core/xml/nokogiri.rb