Skip to content

Commit

Permalink
Finish 3.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed May 5, 2022
2 parents abe8779 + ec0b429 commit 6a04611
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -103,6 +103,10 @@ Then, use the function in a query:

See {SPARQL::Algebra::Expression.register_extension} for details.

### Variable Pre-binding

A call to execute a parsed query can include pre-bound variables, which cause queries to be executed with matching variables bound as defined. Variable pre-binding can be done using a Hash structure, or a Query Solution. See [Query with Binding example](#query-with-binding) and {SPARQL::Algebra::Query#execute}.

### SPARQLStar (SPARQL-star)

The gem supports [SPARQL-star][] where patterns may include sub-patterns recursively, for a kind of Reification.
Expand Down Expand Up @@ -287,6 +291,20 @@ a full set of RDF formats.
query = SPARQL::Algebra.parse(%{(bgp (triple ?s ?p ?o))})
sparql = query.to_sparql #=> "SELECT * WHERE { ?s ?p ?o }"

### Query with Binding

bindings = {page: RDF::URI("https://greggkellogg.net/")}
queryable = RDF::Repository.load("etc/doap.ttl")
query = SPARQL.parse(%(
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?person
WHERE {
?person foaf:homepage ?page .
}
))
solutions = query.execute(queryable, bindings: bindings)
solutions.to_sxp #=> (((person <https://greggkellogg.net/foaf#me>)))

### Command line processing

sparql execute --dataset etc/doap.ttl etc/from_default.rq
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.2.2
3.2.3
4 changes: 3 additions & 1 deletion lib/sparql/algebra/query.rb
Expand Up @@ -38,7 +38,9 @@ def variables
# the graph or repository to query
# @param [Hash{Symbol => Object}] options
# any additional keyword options
# @option options [Boolean] debug
# @option options [RDF::Query::Solution] :bindings
# a query solution containing zero or more variable bindings
# @option options [Boolean] :debug
# Query execution debugging
# @option options [RDF::Term, RDF::Query::Variable] :graph_name
# @yield [solution]
Expand Down
2 changes: 1 addition & 1 deletion spec/readme_spec.rb
Expand Up @@ -16,7 +16,7 @@ def self.read_examples
case title
when "Command line processing"
code.split("\n").reject {|c| c =~ /^\s*(?:#.*)?$/}.each do |command|
examples << {title: command, sh: command}
examples << {title: "#{title}: #{command.strip}", sh: command}
end
else
examples << {title: title, eval_true: code}
Expand Down

0 comments on commit 6a04611

Please sign in to comment.