Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
RUBYOPTS: "--disable-did-you-mean"
JAVA_OPTS: "-Djava.security.egd=file:/dev/urandom"

jobs:
rspec:
name: Ruby ${{ matrix.ruby }} Specs
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby: ["3.1", "3.2", "3.3", "3.4", "jruby"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run tests
run: bundle exec rake

rubocop:
name: RuboCop Linter
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.4
bundler-cache: true

- name: Run RuboCop
run: bundle exec rubocop --format github
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
.bundle
.yardoc
doc
Gemfile.lock
gem-private_key.pem
pkg
20 changes: 16 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
require:
plugins:
- rubocop-rspec
- rubocop-performance

AllCops:
DisabledByDefault: false
TargetRubyVersion: 2.5
TargetRubyVersion: 3.1
NewCops: enable
SuggestExtensions: false
Exclude:
- 'xpath.gemspec'
- 'vendor/**/*'

##### New Cops #####

Expand Down Expand Up @@ -123,6 +126,9 @@ Style/Documentation:
Style/EvenOdd:
Enabled: false

Style/QuotedSymbols:
Enabled: false

Lint/BooleanSymbol:
Enabled: false

Expand All @@ -147,5 +153,11 @@ RSpec/DescribedClass:
RSpec/DescribeClass:
Enabled: false

RSpec/FilePath:
RSpec/SpecFilePathFormat:
Enabled: false

RSpec/SpecFilePathSuffix:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

118 changes: 118 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
PATH
remote: .
specs:
xpath (3.2.0)
nokogiri (~> 1.8)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.3)
coderay (1.1.3)
diff-lcs (1.6.1)
ffi (1.17.1-java)
json (2.10.2)
json (2.10.2-java)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
method_source (1.1.0)
nokogiri (1.18.7-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.7-aarch64-linux-musl)
racc (~> 1.4)
nokogiri (1.18.7-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.7-arm-linux-musl)
racc (~> 1.4)
nokogiri (1.18.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.7-java)
racc (~> 1.4)
nokogiri (1.18.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.18.7-x86_64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.7-x86_64-linux-musl)
racc (~> 1.4)
parallel (1.26.3)
parser (3.3.7.4)
ast (~> 2.4.1)
racc
prism (1.4.0)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry (0.15.2-java)
coderay (~> 1.1)
method_source (~> 1.0)
spoon (~> 0.0)
racc (1.8.1)
racc (1.8.1-java)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.10.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.3)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
rubocop (1.75.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.43.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.43.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-performance (1.25.0)
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-rspec (3.5.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
ruby-progressbar (1.13.0)
spoon (0.0.6)
ffi
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
yard (0.9.37)

PLATFORMS
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
universal-java-17
x86_64-darwin
x86_64-linux-gnu
x86_64-linux-musl

DEPENDENCIES
pry
rake
rspec (~> 3.0)
rubocop
rubocop-performance
rubocop-rspec
xpath!
yard (>= 0.5.8)

BUNDLED WITH
2.6.4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ XPath is a Ruby DSL around a subset of XPath 1.0. Its primary purpose is to
facilitate writing complex XPath queries from Ruby code.

[![Gem Version](https://badge.fury.io/rb/xpath.png)](http://badge.fury.io/rb/xpath)
[![Build Status](https://secure.travis-ci.org/teamcapybara/xpath.png?branch=master)](http://travis-ci.org/teamcapybara/xpath)
[![Build Status](https://github.com/teamcapybara/xpath/actions/workflows/main.yml/badge.svg)](https://github.com/teamcapybara/xpath/actions)

## Generating expressions

Expand Down
2 changes: 1 addition & 1 deletion lib/xpath/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def with_element_conditions(expression, element_names)
end

def valid_xml_name?(name)
name =~ /^[a-zA-Z_:][a-zA-Z0-9_:.\-]*$/
name =~ /^[a-zA-Z_:][a-zA-Z0-9_:.-]*$/
end
end
end
6 changes: 3 additions & 3 deletions lib/xpath/union.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def expression
:union
end

def each(&block)
arguments.each(&block)
def each(&)
arguments.each(&)
end

def method_missing(*args) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
def method_missing(*args) # rubocop:disable Style/MissingRespondToMissing
XPath::Union.new(*arguments.map { |e| e.send(*args) })
end

Expand Down
4 changes: 0 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@

require 'xpath'
require 'pry'

RSpec.configure do |config|
config.expect_with(:rspec) { |c| c.syntax = :should }
end
19 changes: 9 additions & 10 deletions spec/union_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@expr1 = XPath.generate { |x| x.descendant(:p) }
@expr2 = XPath.generate { |x| x.descendant(:div) }
@collection = XPath::Union.new(@expr1, @expr2)
@collection.expressions.should eq [@expr1, @expr2]
expect(@collection.expressions).to eq [@expr1, @expr2]
end
end

Expand All @@ -20,9 +20,8 @@
@expr1 = XPath.generate { |x| x.descendant(:p) }
@expr2 = XPath.generate { |x| x.descendant(:div) }
@collection = XPath::Union.new(@expr1, @expr2)
exprs = []
@collection.each { |expr| exprs << expr }
exprs.should eq [@expr1, @expr2]
exprs = @collection.map { |expr| expr }
expect(exprs).to eq [@expr1, @expr2]
end
end

Expand All @@ -31,7 +30,7 @@
@expr1 = XPath.generate { |x| x.descendant(:p) }
@expr2 = XPath.generate { |x| x.descendant(:div) }
@collection = XPath::Union.new(@expr1, @expr2)
@collection.map(&:expression).should eq %i[descendant descendant]
expect(@collection.map(&:expression)).to eq %i[descendant descendant]
end
end

Expand All @@ -41,9 +40,9 @@
@expr2 = XPath.generate { |x| x.descendant(:div).where(x.attr(:id) == 'foo') }
@collection = XPath::Union.new(@expr1, @expr2)
@results = doc.xpath(@collection.to_xpath)
@results[0][:title].should eq 'fooDiv'
@results[1].text.should eq 'Blah'
@results[2].text.should eq 'Bax'
expect(@results[0][:title]).to eq 'fooDiv'
expect(@results[1].text).to eq 'Blah'
expect(@results[2].text).to eq 'Bax'
end
end

Expand All @@ -55,9 +54,9 @@
@xpath1 = @collection.where(XPath.attr(:id) == 'foo').to_xpath
@xpath2 = @collection.where(XPath.attr(:id) == 'fooDiv').to_xpath
@results = doc.xpath(@xpath1)
@results[0][:title].should eq 'fooDiv'
expect(@results[0][:title]).to eq 'fooDiv'
@results = doc.xpath(@xpath2)
@results[0][:id].should eq 'fooDiv'
expect(@results[0][:id]).to eq 'fooDiv'
end
end
end
Loading