Skip to content

Commit

Permalink
Finish 3.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 26, 2020
2 parents c5e7b57 + b59e7aa commit 4f9e705
Show file tree
Hide file tree
Showing 1,943 changed files with 6,921 additions and 66,165 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow runs continuous CI across different versions of ruby on all branches and pull requests to develop.

name: CI
on:
push:
branches: [ '**' ]
pull_request:
branches: [ develop ]
workflow_dispatch:

jobs:
tests:
name: Ruby ${{ matrix.ruby }}
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
runs-on: ubuntu-latest
env:
CI: true
strategy:
fail-fast: false
matrix:
ruby:
- 2.4
- 2.5
- 2.6
- 2.7
#- ruby-head # net-http-persistent
- jruby
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Run tests
run: bundle exec rspec spec

8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage devel
enough, be assured we will eventually add you in there.
* Do note that in order for us to merge any non-trivial changes (as a rule
of thumb, additions larger than about 15 lines of code), we need an
explicit [public domain dedication][PDD] on record from you.
explicit [public domain dedication][PDD] on record from you,
which you will be asked to agree to on the first commit to a repo within the organization.
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.

[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[pr]: https://github.com/ruby-rdf/sparql/compare/
[PDD]: https://unlicense.org/#unlicensing-contributions
[pr]: https://github.com/ruby-rdf/rdf/compare/
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ group :development do
gem 'rdf-vocab', github: "ruby-rdf/rdf-vocab", branch: "develop"
gem 'ld-patch', github: "ruby-rdf/ld-patch", branch: "develop"
gem 'shex', github: "ruby-rdf/shex", branch: "develop"
gem 'awesome_print', github: 'MatthiasWinkelmann/awesome_print'
gem "equivalent-xml", '>= 0.6.0'
gem 'psych', platforms: [:mri, :rbx]
gem 'simplecov', platforms: :mri
Expand All @@ -42,6 +41,7 @@ group :debug do
gem 'pry-byebug', platforms: :mri
gem 'redcarpet', platforms: :ruby
gem 'ruby-prof', platforms: :mri
gem 'awesome_print', github: 'akshaymohite/awesome_print'
end

group :test do
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
This is a [Ruby][] implementation of [SPARQL][] for [RDF.rb][].

[![Gem Version](https://badge.fury.io/rb/sparql.png)](https://badge.fury.io/rb/sparql)

[![Build Status](https://travis-ci.org/ruby-rdf/sparql.png?branch=master)](https://travis-ci.org/ruby-rdf/sparql)

[![Build Status](https://github.com/ruby-rdf/sparql/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/sparql/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/sparql/badge.svg)](https://coveralls.io/r/ruby-rdf/sparql)
[![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)

## Features

Expand Down Expand Up @@ -419,7 +418,9 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
list in the the `README`. Alphabetical order applies.
* Do note that in order for us to merge any non-trivial changes (as a rule
of thumb, additions larger than about 15 lines of code), we need an
explicit [public domain dedication][PDD] on record from you.
explicit [public domain dedication][PDD] on record from you,
which you will be asked to agree to on the first commit to a repo within the organization.
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.

## License

Expand All @@ -437,7 +438,7 @@ A copy of the [SPARQL 1.0 tests][] and [SPARQL 1.1 tests][] are also included in
[Rack::LinkedData]: https://rubygems.org/gems/rack-linkeddata
[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[PDD]: https://unlicense.org/#unlicensing-contributions
[SPARQL]: https://en.wikipedia.org/wiki/SPARQL
[SPARQL 1.0]: https://www.w3.org/TR/sparql11-query/
[SPARQL 1.0 tests]:https://www.w3.org/2001/sw/DataAccess/tests/
Expand All @@ -447,8 +448,8 @@ A copy of the [SPARQL 1.0 tests][] and [SPARQL 1.1 tests][] are also included in
[grammar]: https://www.w3.org/TR/sparql11-query/#grammar
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts
[RDF.rb]: https://rubydoc.info/github/ruby-rdf/rdf
[RDF*]: https://lists.w3.org/Archives/Public/public-rdf-star/
[SPARQL*]: https://arxiv.org/pdf/1406.3399.pdf
[RDF*]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html
[SPARQL*]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html#sparql-query-language
[Backports]: https://rubygems.org/gems/backports
[Linked Data]: https://rubygems.org/gems/linkeddata
[SPARQL doc]: https://rubydoc.info/github/ruby-rdf/sparql/frames
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.1.4
31 changes: 20 additions & 11 deletions bin/sparql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run(input, **options)
end

query = if options[:sse]
SPARQL::Algebra.parse(input, debug: options[:debug], update: options[:update])
SPARQL::Algebra.parse(input, logger: options[:logger], update: options[:update])
else
# Only do grammar debugging if we're generating SSE
SPARQL::Grammar.parse(input, **options)
Expand All @@ -47,7 +47,7 @@ def run(input, **options)
puts ("\nSSE:\n" + query.to_sse) if options[:debug] || options[:to_sse]

unless options[:to_sse]
res = query.execute(options[:dataset], debug: options[:debug])
res = query.execute(options[:dataset], logger: options[:logger])
display_results(res, **options)
end
end
Expand All @@ -60,6 +60,11 @@ def server(options)
register Sinatra::SPARQL
set :repository, repository

before do
options[:logger].info "#{request.request_method} [#{request.path_info}], " +
params.merge(Accept: request.accept.map(&:to_s)).map {|k,v| "#{k}=#{v}" unless k.to_s == "content"}.join(" ")
end

get '/' do
if params["query"]
query = params["query"].to_s.match(/^http:/) ? RDF::Util::File.open_file(params["query"]) : ::CGI.unescape(params["query"].to_s)
Expand All @@ -78,20 +83,19 @@ def server(options)
SPARQL.execute(params['query'], settings.repository)
end
end
Rack::Server.start(app: app)
Rack::Server.start(app: app, Port: options.fetch(:port, 9292))
rescue LoadError
$stderr.puts "Running SPARQL server requires Rack to be in environment: #{$!.message}"
end

def usage
puts "Usage: #{$0} execute [options] query-file Execute a query against the specified dataset"
puts " #{$0} parse [options] query-file Parse a query into SPARQL S-Expressions (SSE)"
puts " #{$0} query [options] end-point query-file Run the query against a remote end-point"
puts " #{$0} server [options] dataset-file Start a server initialized from the specified dataset"
puts "Usage: #{File.basename($0)} execute [options] query-file Execute a query against the specified dataset"
puts " #{File.basename($0)} parse [options] query-file Parse a query into SPARQL S-Expressions (SSE)"
puts " #{File.basename($0)} query [options] end-point query-file Run the query against a remote end-point"
puts " #{File.basename($0)} server [options] dataset-file Start a server initialized from the specified dataset"
puts "Options:"
puts " --dataset: File containing RDF graph or dataset"
puts " --debug: Display detailed debug output"
puts " --debug: Display detailed debug output"
puts " --execute,-e: Use option argument as the SPARQL input if no query-file given"
puts " --format: Output format for results"
puts " --port,-p Port on which to run server; defaults to 9292"
Expand All @@ -116,20 +120,25 @@ opts = GetoptLong.new(
["--help", "-?", GetoptLong::NO_ARGUMENT]
)

logger = Logger.new(STDERR)
logger.level = Logger::WARN
logger.formatter = lambda {|severity, datetime, progname, msg| "%5s %s\n" % [severity, msg]}

options = {
dataset: RDF::Repository.new,
logger: logger,
}

opts.each do |opt, arg|
case opt
when '--dataset' then options[:dataset].load(arg, rdfstar: :PG)
when '--debug' then options[:debug] = true
when '--dataset' then options[:dataset].load(arg, rdfstar: true)
when '--debug' then options[:debug] = true ; logger.level = Logger::DEBUG
when '--execute' then input = arg
when '--format' then options[:format] = arg.to_sym
when '--port' then options[:port] = arg.to_i
when '--sse' then options[:sse] = true
when '--update' then options[:update] = true
when '--verbose' then options[:verbose] = true
when '--verbose' then options[:verbose] = true ; logger.level = Logger::INFO
when "--help" then usage
end
end
Expand Down
29 changes: 16 additions & 13 deletions etc/sparql11.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@
[76] PropertyList ::= PropertyListNotEmpty?
[77] PropertyListNotEmpty ::= Verb ObjectList ( ';' ( Verb ObjectList )? )*
[78] Verb ::= VarOrIri | 'a'
[79] ObjectList ::= Object ( ',' Object )*
[80] Object ::= GraphNode
[79] ObjectList ::= Object AnnotationPattern? ( ',' Object AnnotationPattern? )*
[80] Object ::= GraphNode | EmbTP
[81] TriplesSameSubjectPath ::= VarOrTermOrEmbTP PropertyListPathNotEmpty
| TriplesNodePath PropertyListPath
[82] PropertyListPath ::= PropertyListPathNotEmpty?
[83] PropertyListPathNotEmpty::= ( VerbPath | VerbSimple ) ObjectListPath
( ';' ( ( VerbPath | VerbSimple ) ObjectList )? )*
[84] VerbPath ::= Path
[85] VerbSimple ::= Var
[86] ObjectListPath ::= ObjectPath ( ',' ObjectPath )*
[86] ObjectListPath ::= ObjectPath AnnotationPattern? ( ',' ObjectPath AnnotationPattern? )*
[87] ObjectPath ::= GraphNodePath
[88] Path ::= PathAlternative
[89] PathAlternative ::= PathSequence ( '|' PathSequence )*
Expand All @@ -120,18 +120,17 @@
[99] BlankNodePropertyList ::= '[' PropertyListNotEmpty ']'
[100] TriplesNodePath ::= CollectionPath | BlankNodePropertyListPath
[101] BlankNodePropertyListPath::= '[' PropertyListPathNotEmpty ']'
[102] Collection ::= '(' GraphNode+ ')'
[103] CollectionPath ::= '(' GraphNodePath+ ')'
[104] GraphNode ::= VarOrTerm | TriplesNode
[105] GraphNodePath ::= VarOrTermOrEmbTP | TriplesNodePath
[106] VarOrTerm ::= Var | GraphTerm
[106s] VarOrTermOrEmbTP ::= Var | GraphTerm | EmbTP
[107] VarOrIri ::= Var | iri
[102] Collection ::= '(' GraphNode+ ')'
[103] CollectionPath ::= '(' GraphNodePath+ ')'
[104] GraphNode ::= VarOrTerm | TriplesNode
[105] GraphNodePath ::= VarOrTermOrEmbTP | TriplesNodePath
[106] VarOrTerm ::= Var | GraphTerm
[107] VarOrIri ::= Var | iri
[107s] VarOrBlankNodeOrIriOrEmbTP ::= Var | BlankNode| iri | EmbTP
[108] Var ::= VAR1 | VAR2
[109] GraphTerm ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral
[108] Var ::= VAR1 | VAR2
[109] GraphTerm ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral
| BlankNode | NIL
[1xxs] EmbTP ::= '<<' VarOrBlankNodeOrIriOrEmbTP Verb VarOrTermOrEmbTP '>>'
[174] EmbTP ::= '<<' EmbSubjectOrObject Verb EmbSubjectOrObject '>>'
[110] Expression ::= ConditionalOrExpression
[111] ConditionalOrExpression ::= ConditionalAndExpression
( '||' ConditionalAndExpression )*
Expand Down Expand Up @@ -242,6 +241,10 @@
[136] iri ::= IRIREF | PrefixedName
[137] PrefixedName ::= PNAME_LN | PNAME_NS
[138] BlankNode ::= BLANK_NODE_LABEL | ANON
[175] EmbSubjectOrObject ::= Var | BlankNode | iri | RDFLiteral
| NumericLiteral | BooleanLiteral | EmbTP
[176] VarOrTermOrEmbTP ::= Var | GraphTerm | EmbTP
[177] AnnotationPattern ::= '{|' PropertyListNotEmpty '|}'

@terminals

Expand Down

0 comments on commit 4f9e705

Please sign in to comment.