Skip to content

Commit 5d09cbe

Browse files
committed
Finish 0.6.4
2 parents 9badefd + 1c20c5a commit 5d09cbe

33 files changed

+534
-557
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
with:
3535
ruby-version: ${{ matrix.ruby }}
3636
- name: Install dependencies
37-
run: bundle install --jobs 4 --retry 3
37+
run: ruby --version; bundle install --jobs 4 --retry 3
3838
- name: Run tests
3939
run: bundle exec rspec spec
4040

README.md

Lines changed: 98 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -25,120 +25,131 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine version 2.0.
2525
## Examples
2626
### Validating a node using ShExC
2727

28-
require 'rubygems'
2928
require 'rdf/turtle'
3029
require 'shex'
3130

32-
shexc: %(
31+
shexc = %(
3332
PREFIX doap: <http://usefulinc.com/ns/doap#>
3433
PREFIX dc: <http://purl.org/dc/terms/>
35-
<TestShape> EXTRA a {
36-
a doap:Project;
37-
(doap:name;doap:description|dc:title;dc:description)+;
38-
doap:category*;
39-
doap:developer IRI;
40-
doap:implements [<http://shex.io/shex-semantics/>]
34+
PREFIX ex: <http://example.com/>
35+
36+
ex:TestShape EXTRA a {
37+
a [doap:Project];
38+
( doap:name Literal;
39+
doap:description Literal
40+
| dc:title Literal;
41+
dc:description Literal)+;
42+
doap:category IRI*;
43+
doap:developer IRI+;
44+
doap:implements [<http://shex.io/shex-semantics/>]
4145
}
4246
)
4347
graph = RDF::Graph.load("etc/doap.ttl")
4448
schema = ShEx.parse(shexc)
4549
map = {
46-
"https://rubygems.org/gems/shex" => "TestShape"
50+
RDF::URI("https://rubygems.org/gems/shex") => RDF::URI("http://example.com/TestShape")
4751
}
48-
schema.satisfies?("https://rubygems.org/gems/shex", graph, map)
52+
schema.satisfies?(graph, map)
4953
# => true
5054
### Validating a node using ShExJ
5155

5256
require 'rubygems'
5357
require 'rdf/turtle'
5458
require 'shex'
5559

56-
shexj: %({
60+
shexj = %({
61+
"@context": "http://www.w3.org/ns/shex.jsonld",
5762
"type": "Schema",
58-
"prefixes": {
59-
"doap": "http://usefulinc.com/ns/doap#",
60-
"dc": "http://purl.org/dc/terms/"
61-
},
62-
"shapes": {
63-
"TestShape": {
64-
"type": "Shape",
65-
"extra": ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"],
66-
"expression": {
67-
"type": "EachOf",
68-
"expressions": [
69-
{
70-
"type": "TripleConstraint",
71-
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
72-
"valueExpr": {
73-
"type": "NodeConstraint",
74-
"values": ["http://usefulinc.com/ns/doap#Project"]
75-
}
76-
},
77-
{
78-
"type": "OneOf",
79-
"expressions": [
80-
{
81-
"type": "EachOf",
82-
"expressions": [
83-
{
84-
"type": "TripleConstraint",
85-
"predicate": "http://usefulinc.com/ns/doap#name",
86-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
87-
},
88-
{
89-
"type": "TripleConstraint",
90-
"predicate": "http://usefulinc.com/ns/doap#description",
91-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
92-
}
93-
]
94-
},
95-
{
96-
"type": "EachOf",
97-
"expressions": [
98-
{
99-
"type": "TripleConstraint",
100-
"predicate": "http://purl.org/dc/terms/title",
101-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
102-
},
103-
{
104-
"type": "TripleConstraint",
105-
"predicate": "http://purl.org/dc/terms/description",
106-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
107-
}
108-
]
63+
"shapes": [{
64+
"id": "http://example.com/TestShape",
65+
"type": "Shape",
66+
"extra": ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"],
67+
"expression": {
68+
"type": "EachOf",
69+
"expressions": [{
70+
"type": "TripleConstraint",
71+
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
72+
"valueExpr": {
73+
"type": "NodeConstraint",
74+
"values": ["http://usefulinc.com/ns/doap#Project"]
75+
}
76+
}, {
77+
"type": "OneOf",
78+
"expressions": [{
79+
"type": "EachOf",
80+
"expressions": [{
81+
"type": "TripleConstraint",
82+
"predicate": "http://usefulinc.com/ns/doap#name",
83+
"valueExpr": {
84+
"type": "NodeConstraint",
85+
"nodeKind": "literal"
10986
}
110-
],
111-
"min": 1, "max": -1
112-
},
113-
{
114-
"type": "TripleConstraint",
115-
"predicate": "http://usefulinc.com/ns/doap#category",
116-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "iri"},
117-
"min": 0, "max": -1
87+
}, {
88+
"type": "TripleConstraint",
89+
"predicate": "http://usefulinc.com/ns/doap#description",
90+
"valueExpr": {
91+
"type": "NodeConstraint",
92+
"nodeKind": "literal"
93+
}
94+
}]
95+
}, {
96+
"type": "EachOf",
97+
"expressions": [{
98+
"type": "TripleConstraint",
99+
"predicate": "http://purl.org/dc/terms/title",
100+
"valueExpr": {
101+
"type": "NodeConstraint",
102+
"nodeKind": "literal"
103+
}
104+
}, {
105+
"type": "TripleConstraint",
106+
"predicate": "http://purl.org/dc/terms/description",
107+
"valueExpr": {
108+
"type": "NodeConstraint",
109+
"nodeKind": "literal"
110+
}
111+
}]
112+
}],
113+
"min": 1,
114+
"max": -1
115+
}, {
116+
"type": "TripleConstraint",
117+
"predicate": "http://usefulinc.com/ns/doap#category",
118+
"valueExpr": {
119+
"type": "NodeConstraint",
120+
"nodeKind": "iri"
118121
},
119-
{
120-
"type": "TripleConstraint",
121-
"predicate": "http://usefulinc.com/ns/doap#developer",
122-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "iri"},
123-
"min": 1, "max": -1
122+
"min": 0,
123+
"max": -1
124+
}, {
125+
"type": "TripleConstraint",
126+
"predicate": "http://usefulinc.com/ns/doap#developer",
127+
"valueExpr": {
128+
"type": "NodeConstraint",
129+
"nodeKind": "iri"
124130
},
125-
{
126-
"type": "TripleConstraint",
127-
"predicate": "http://usefulinc.com/ns/doap#implements",
128-
"valueExpr": {
129-
"type": "NodeConstraint",
130-
"values": ["http://shex.io/shex-semantics/"]
131-
}
131+
"min": 1,
132+
"max": -1
133+
}, {
134+
"type": "TripleConstraint",
135+
"predicate": "http://usefulinc.com/ns/doap#implements",
136+
"valueExpr": {
137+
"type": "NodeConstraint",
138+
"values": [
139+
"http://shex.io/shex-semantics/"
140+
]
132141
}
133-
]
134-
}
142+
}
143+
]
135144
}
136145
}
137-
})
146+
]})
138147
graph = RDF::Graph.load("etc/doap.ttl")
139148
schema = ShEx.parse(shexj, format: :shexj)
140-
map = {"https://rubygems.org/gems/shex" => "TestShape"}
141-
schema.satisfies?("https://rubygems.org/gems/shex", graph, map)
149+
map = {
150+
RDF::URI("https://rubygems.org/gems/shex") => RDF::URI("http://example.com/TestShape")
151+
}
152+
schema.satisfies?(graph, map)
142153
# => true
143154

144155
## Extensions

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.3
1+
0.6.4

etc/shex.ebnf

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44
55
# leading CODE is captured in startActions
66
[1] shexDoc ::= directive* ((notStartAction | startActions) statement*)?
7-
[2] directive ::= baseDecl | prefixDecl
7+
[2] directive ::= baseDecl | prefixDecl | importDecl
88
[3] baseDecl ::= "BASE" IRIREF
99
[4] prefixDecl ::= "PREFIX" PNAME_NS IRIREF
10+
[4.5] importDecl ::= "IMPORT" IRIREF
1011

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

1617
[8] statement ::= directive | notStartAction
1718

1819
[9] shapeExprDecl ::= shapeExprLabel (shapeExpression | "EXTERNAL")
19-
[10] shapeExpression ::= "NOT"? shapeAtomNoRef shapeOr?
20-
| "NOT" shapeRef shapeOr?
21-
| shapeRef shapeOr
20+
[10] shapeExpression ::= shapeOr
2221
[11] inlineShapeExpression ::= inlineShapeOr
23-
[12] shapeOr ::= ("OR" shapeAnd)+
24-
| ("AND" shapeNot)+ ("OR" shapeAnd)*
22+
[12] shapeOr ::= shapeAnd ("OR" shapeAnd)*
2523
[13] inlineShapeOr ::= inlineShapeAnd ("OR" inlineShapeAnd)*
2624
[14] shapeAnd ::= shapeNot ("AND" shapeNot)*
2725
[15] inlineShapeAnd ::= inlineShapeNot ("AND" inlineShapeNot)*
@@ -48,7 +46,6 @@
4846
[23] shapeRef ::= ATPNAME_LN | ATPNAME_NS | '@' shapeExprLabel
4947

5048
[24] litNodeConstraint ::= "LITERAL" xsFacet*
51-
| nonLiteralKind stringFacet*
5249
| datatype xsFacet*
5350
| valueSet xsFacet*
5451
| numericFacet+
@@ -82,12 +79,10 @@
8279
#[42] multiElementGroup ::= unaryTripleExpr (';' unaryTripleExpr)+ ';'?
8380
[40] groupTripleExpr ::= unaryTripleExpr (';' unaryTripleExpr?)*
8481

85-
[43] unaryTripleExpr ::= productionLabel? (tripleConstraint | bracketedTripleExpr) | include
86-
[43a] productionLabel ::= '$' (iri | blankNode)
82+
[43] unaryTripleExpr ::= ('$' tripleExprLabel)? (tripleConstraint | bracketedTripleExpr) | include
8783

8884
# Use oneOfTripleExpr instead of innerTripleExpr
89-
#[44] bracketedTripleExpr ::= '(' innerTripleExpr ')' cardinality? annotation* semanticActions
90-
[44] bracketedTripleExpr ::= '(' oneOfTripleExpr ')' cardinality? annotation* semanticActions
85+
[44] bracketedTripleExpr ::= '(' tripleExpression ')' cardinality? annotation* semanticActions
9186

9287
[45] tripleConstraint ::= senseFlags? predicate inlineShapeExpression cardinality? annotation* semanticActions
9388
[46] cardinality ::= '*' | '+' | '?' | REPEAT_RANGE
@@ -103,6 +98,7 @@
10398
[53] literalRange ::= literal ('~' literalExclusion*)?
10499
[54] literalExclusion ::= '-' literal '~'?
105100
[55] languageRange ::= LANGTAG ('~' languageExclusion*)?
101+
| '@' '~' languageExclusion*
106102
[56] languageExclusion ::= '-' LANGTAG '~'?
107103

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

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

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

0 commit comments

Comments
 (0)