Skip to content

Commit

Permalink
Finish 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 29, 2021
2 parents 9badefd + 684dfd4 commit 3209fe5
Show file tree
Hide file tree
Showing 35 changed files with 551 additions and 573 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
fail-fast: false
matrix:
ruby:
- 2.5
- 2.6
- 2.7
- 3.0
- 3.1
- ruby-head
- jruby
steps:
Expand All @@ -34,7 +34,7 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
run: ruby --version; bundle install --jobs 4 --retry 3
- name: Run tests
run: bundle exec rspec spec

3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ group :development, :test do
gem 'rdf-rdfa', git: "https://github.com/ruby-rdf/rdf-rdfa", branch: "develop"
gem 'rdf-isomorphic', git: "https://github.com/ruby-rdf/rdf-isomorphic", branch: "develop"
gem 'rdf-turtle', git: "https://github.com/ruby-rdf/rdf-turtle", branch: "develop"
gem 'rdf-vocab', git: "https://github.com/ruby-rdf/rdf-vocab", branch: "develop"
gem 'rdf-xsd', git: "https://github.com/ruby-rdf/rdf-xsd", branch: "develop"
gem 'rdf-spec', git: "https://github.com/ruby-rdf/rdf-spec", branch: "develop"
gem 'sparql', git: "https://github.com/ruby-rdf/sparql", branch: "develop"
gem 'sparql-client', git: "https://github.com/ruby-rdf/sparql-client", branch: "develop"
gem 'sxp', git: "https://github.com/dryruby/sxp.rb", branch: "develop"
gem 'earl-report'
gem 'simplecov', '~> 0.21', platforms: :mri
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
end
Expand Down
189 changes: 100 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,120 +25,131 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine version 2.0.
## Examples
### Validating a node using ShExC

require 'rubygems'
require 'rdf/turtle'
require 'shex'

shexc: %(
shexc = %(
PREFIX doap: <http://usefulinc.com/ns/doap#>
PREFIX dc: <http://purl.org/dc/terms/>
<TestShape> EXTRA a {
a doap:Project;
(doap:name;doap:description|dc:title;dc:description)+;
doap:category*;
doap:developer IRI;
doap:implements [<http://shex.io/shex-semantics/>]
PREFIX ex: <http://example.com/>

ex:TestShape EXTRA a {
a [doap:Project];
( doap:name Literal;
doap:description Literal
| dc:title Literal;
dc:description Literal)+;
doap:category IRI*;
doap:developer IRI+;
doap:implements [<http://shex.io/shex-semantics/>]
}
)
graph = RDF::Graph.load("etc/doap.ttl")
schema = ShEx.parse(shexc)
map = {
"https://rubygems.org/gems/shex" => "TestShape"
RDF::URI("https://rubygems.org/gems/shex") => RDF::URI("http://example.com/TestShape")
}
schema.satisfies?("https://rubygems.org/gems/shex", graph, map)
schema.satisfies?(graph, map)
# => true
### Validating a node using ShExJ

require 'rubygems'
require 'rdf/turtle'
require 'shex'

shexj: %({
shexj = %({
"@context": "http://www.w3.org/ns/shex.jsonld",
"type": "Schema",
"prefixes": {
"doap": "http://usefulinc.com/ns/doap#",
"dc": "http://purl.org/dc/terms/"
},
"shapes": {
"TestShape": {
"type": "Shape",
"extra": ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"],
"expression": {
"type": "EachOf",
"expressions": [
{
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": ["http://usefulinc.com/ns/doap#Project"]
}
},
{
"type": "OneOf",
"expressions": [
{
"type": "EachOf",
"expressions": [
{
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#name",
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
},
{
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#description",
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
}
]
},
{
"type": "EachOf",
"expressions": [
{
"type": "TripleConstraint",
"predicate": "http://purl.org/dc/terms/title",
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
},
{
"type": "TripleConstraint",
"predicate": "http://purl.org/dc/terms/description",
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
}
]
"shapes": [{
"id": "http://example.com/TestShape",
"type": "Shape",
"extra": ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"],
"expression": {
"type": "EachOf",
"expressions": [{
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": ["http://usefulinc.com/ns/doap#Project"]
}
}, {
"type": "OneOf",
"expressions": [{
"type": "EachOf",
"expressions": [{
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#name",
"valueExpr": {
"type": "NodeConstraint",
"nodeKind": "literal"
}
],
"min": 1, "max": -1
},
{
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#category",
"valueExpr": {"type": "NodeConstraint", "nodeKind": "iri"},
"min": 0, "max": -1
}, {
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#description",
"valueExpr": {
"type": "NodeConstraint",
"nodeKind": "literal"
}
}]
}, {
"type": "EachOf",
"expressions": [{
"type": "TripleConstraint",
"predicate": "http://purl.org/dc/terms/title",
"valueExpr": {
"type": "NodeConstraint",
"nodeKind": "literal"
}
}, {
"type": "TripleConstraint",
"predicate": "http://purl.org/dc/terms/description",
"valueExpr": {
"type": "NodeConstraint",
"nodeKind": "literal"
}
}]
}],
"min": 1,
"max": -1
}, {
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#category",
"valueExpr": {
"type": "NodeConstraint",
"nodeKind": "iri"
},
{
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#developer",
"valueExpr": {"type": "NodeConstraint", "nodeKind": "iri"},
"min": 1, "max": -1
"min": 0,
"max": -1
}, {
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#developer",
"valueExpr": {
"type": "NodeConstraint",
"nodeKind": "iri"
},
{
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#implements",
"valueExpr": {
"type": "NodeConstraint",
"values": ["http://shex.io/shex-semantics/"]
}
"min": 1,
"max": -1
}, {
"type": "TripleConstraint",
"predicate": "http://usefulinc.com/ns/doap#implements",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://shex.io/shex-semantics/"
]
}
]
}
}
]
}
}
})
]})
graph = RDF::Graph.load("etc/doap.ttl")
schema = ShEx.parse(shexj, format: :shexj)
map = {"https://rubygems.org/gems/shex" => "TestShape"}
schema.satisfies?("https://rubygems.org/gems/shex", graph, map)
map = {
RDF::URI("https://rubygems.org/gems/shex") => RDF::URI("http://example.com/TestShape")
}
schema.satisfies?(graph, map)
# => true

## Extensions
Expand Down Expand Up @@ -189,8 +200,8 @@ The parser uses the executable [S-Expressions][] generated from the EBNF ShExC g

## Dependencies

* [Ruby](https://ruby-lang.org/) (>= 2.4)
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
* [Ruby](https://ruby-lang.org/) (>= 2.6)
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2)
* [SPARQL gem](https://rubygems.org/gems/sparql) (~> 3.1)

## Installation
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.3
0.7.0
24 changes: 10 additions & 14 deletions etc/shex.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@
# leading CODE is captured in startActions
[1] shexDoc ::= directive* ((notStartAction | startActions) statement*)?
[2] directive ::= baseDecl | prefixDecl
[2] directive ::= baseDecl | prefixDecl | importDecl
[3] baseDecl ::= "BASE" IRIREF
[4] prefixDecl ::= "PREFIX" PNAME_NS IRIREF
[4.5] importDecl ::= "IMPORT" IRIREF

[5] notStartAction ::= start | shapeExprDecl
# "START" easier for parser than "start"
[6] start ::= "START" '=' "NOT"? (shapeAtomNoRef | shapeRef) shapeOr?
[6] start ::= "START" '=' inlineShapeExpression
[7] startActions ::= codeDecl+

[8] statement ::= directive | notStartAction

[9] shapeExprDecl ::= shapeExprLabel (shapeExpression | "EXTERNAL")
[10] shapeExpression ::= "NOT"? shapeAtomNoRef shapeOr?
| "NOT" shapeRef shapeOr?
| shapeRef shapeOr
[10] shapeExpression ::= shapeOr
[11] inlineShapeExpression ::= inlineShapeOr
[12] shapeOr ::= ("OR" shapeAnd)+
| ("AND" shapeNot)+ ("OR" shapeAnd)*
[12] shapeOr ::= shapeAnd ("OR" shapeAnd)*
[13] inlineShapeOr ::= inlineShapeAnd ("OR" inlineShapeAnd)*
[14] shapeAnd ::= shapeNot ("AND" shapeNot)*
[15] inlineShapeAnd ::= inlineShapeNot ("AND" inlineShapeNot)*
Expand All @@ -48,7 +46,6 @@
[23] shapeRef ::= ATPNAME_LN | ATPNAME_NS | '@' shapeExprLabel

[24] litNodeConstraint ::= "LITERAL" xsFacet*
| nonLiteralKind stringFacet*
| datatype xsFacet*
| valueSet xsFacet*
| numericFacet+
Expand Down Expand Up @@ -82,12 +79,10 @@
#[42] multiElementGroup ::= unaryTripleExpr (';' unaryTripleExpr)+ ';'?
[40] groupTripleExpr ::= unaryTripleExpr (';' unaryTripleExpr?)*

[43] unaryTripleExpr ::= productionLabel? (tripleConstraint | bracketedTripleExpr) | include
[43a] productionLabel ::= '$' (iri | blankNode)
[43] unaryTripleExpr ::= ('$' tripleExprLabel)? (tripleConstraint | bracketedTripleExpr) | include

# Use oneOfTripleExpr instead of innerTripleExpr
#[44] bracketedTripleExpr ::= '(' innerTripleExpr ')' cardinality? annotation* semanticActions
[44] bracketedTripleExpr ::= '(' oneOfTripleExpr ')' cardinality? annotation* semanticActions
[44] bracketedTripleExpr ::= '(' tripleExpression ')' cardinality? annotation* semanticActions

[45] tripleConstraint ::= senseFlags? predicate inlineShapeExpression cardinality? annotation* semanticActions
[46] cardinality ::= '*' | '+' | '?' | REPEAT_RANGE
Expand All @@ -103,6 +98,7 @@
[53] literalRange ::= literal ('~' literalExclusion*)?
[54] literalExclusion ::= '-' literal '~'?
[55] languageRange ::= LANGTAG ('~' languageExclusion*)?
| '@' '~' languageExclusion*
[56] languageExclusion ::= '-' LANGTAG '~'?

[57] include ::= '&' tripleExprLabel
Expand All @@ -119,7 +115,7 @@

[16t] numericLiteral ::= DOUBLE | DECIMAL | INTEGER
[65] rdfLiteral ::= langString | string ('^^' datatype)?
[134s] booleanLiteral ::= 'true' | 'false'
[134s] booleanLiteral ::= "true" | "false"
[135s] string ::= STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
| STRING_LITERAL1 | STRING_LITERAL2
[66] langString ::= LANG_STRING_LITERAL1 | LANG_STRING_LITERAL_LONG1
Expand Down Expand Up @@ -173,4 +169,4 @@
[172s] HEX ::= [0-9] | [A-F] | [a-f]
[173s] PN_LOCAL_ESC ::= '\\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%')

@pass [ \t\r\n]+ | "#" [^\r\n]*
@pass [ \t\r\n]+ | "#" [^\r\n]* | "/*" ([^*] | '*' ([^/] | '\\/'))* "*/"
Loading

0 comments on commit 3209fe5

Please sign in to comment.