Sha256: 21b4d0dce6086928984d54731a1d90995a9f48e3aebe5f1f448fc5061818e5be

Contents?: true

Size: 1.67 KB

Versions: 25

Compression:

Stored size: 1.67 KB

Contents

require "webrat/core_extensions/meta_class"

module Webrat #:nodoc:
  module XML #:nodoc:

    def self.document(stringlike) #:nodoc:
      return stringlike.dom if stringlike.respond_to?(:dom)

      if Nokogiri::HTML::Document === stringlike
        stringlike
      elsif Nokogiri::XML::NodeSet === stringlike
        stringlike
      elsif stringlike.respond_to?(:body)
        Nokogiri::HTML(stringlike.body.to_s)
      else
        Nokogiri::HTML(stringlike.to_s)
      end
    end

    def self.html_document(stringlike) #:nodoc:
      return stringlike.dom if stringlike.respond_to?(:dom)

      if Nokogiri::HTML::Document === stringlike
        stringlike
      elsif Nokogiri::XML::NodeSet === stringlike
        stringlike
      elsif stringlike.respond_to?(:body)
        Nokogiri::HTML(stringlike.body.to_s)
      else
        Nokogiri::HTML(stringlike.to_s)
      end
    end

    def self.xml_document(stringlike) #:nodoc:
      return stringlike.dom if stringlike.respond_to?(:dom)

      if Nokogiri::HTML::Document === stringlike
        stringlike
      elsif Nokogiri::XML::NodeSet === stringlike
        stringlike
      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
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

25 entries across 25 versions & 13 rubygems

Version Path
diabolo-webrat-0.5.1 lib/webrat/core/xml.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/webrat-0.7.3/lib/webrat/core/xml.rb
webrat-0.7.3 lib/webrat/core/xml.rb
jbd-webrat-0.7.2.rails3 lib/webrat/core/xml.rb
webrat-0.7.2 lib/webrat/core/xml.rb
webrat-0.7.2.beta.2 lib/webrat/core/xml.rb
mutle-webrat-0.7.2.beta.1 lib/webrat/core/xml.rb
thoughtbot-webrat-0.7.2.pre lib/webrat/core/xml.rb
webrat-0.7.2.beta.1 lib/webrat/core/xml.rb
honkster-webrat-0.7.1.2 lib/webrat/core/xml.rb
honkster-webrat-0.7.1.1 lib/webrat/core/xml.rb
webrat-0.7.1 lib/webrat/core/xml.rb
davidtrogers-webrat-0.7.0 lib/webrat/core/xml.rb
webrat-0.7.0 lib/webrat/core/xml.rb
honkster-webrat-0.6.0.10 lib/webrat/core/xml.rb
honkster-webrat-0.6.0.9 lib/webrat/core/xml.rb
darkofabijan-webrat-0.6.1 lib/webrat/core/xml.rb
kbaum-webrat-0.5.1 lib/webrat/core/xml.rb
kbaum-webrat-0.6.1.pre lib/webrat/core/xml.rb
cynergy-webrat-0.6.0 lib/webrat/core/xml.rb