Sha256: a7fbd952e46c7fa4b5d2014515c6ee0a5313a60cfca59101be1e542020656a67

Contents?: true

Size: 1.94 KB

Versions: 14

Compression:

Stored size: 1.94 KB

Contents

= XPath

XPath is a Ruby DSL around a subset of XPath 1.0. It's primary purpose is to
facilitate writing complex XPath queries from Ruby code.

== Generating expressions

To create quick, one of expressions, XPath.generate can be used:

    XPath.generate { |x| x.descendant(:ul)[x.attr(:id) == 'foo'] }

However for more complex expressions, it is probably ore convenient to include
the XPath module into your own class or module:

    module MyXPaths
      include XPath

      def foo_ul
        descendant(:ul)[attr(:id) == 'foo']
      end

      def password_field(id)
        descendant(:input)[attr(:type) == 'password'][attr(:id) == id]
      end
    end

Both ways return an XPath::Expression instance, which can be further modified.
To convert the expression to a string, just call #to_s on it.

== HTML

XPath comes with a set of premade XPaths for use with HTML documents.

== License

(The MIT License)

Copyright © 2010 Jonas Nicklas

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the ‘Software’), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/README.rdoc
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/README.rdoc
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/README.rdoc
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/README.rdoc
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/README.rdoc
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/README.rdoc
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/README.rdoc
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/README.rdoc
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/README.rdoc
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/README.rdoc
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/README.rdoc
xpath-0.1.4 README.rdoc
wgibbs-xpath-0.1.4 README.rdoc
xpath-0.1.3 README.rdoc