-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from zazuko/shacl-validate-command
feat(shacl): validate command
- Loading branch information
Showing
9 changed files
with
271 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"barnard59-shacl": minor | ||
--- | ||
|
||
Added a pipeline command which validates quads from standard input |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { resolve } from 'path' | ||
|
||
export default async function getShapes(pathOrUri) { | ||
let url | ||
|
||
try { | ||
url = new URL(pathOrUri) | ||
} catch { | ||
const path = resolve(this.basePath, pathOrUri) | ||
return this.env.fromFile(path) | ||
} | ||
|
||
const response = await this.env.fetch(url) | ||
let contentType = response.headers['content-type'] | ||
if (!contentType) { | ||
this.logger.warn(`No content-type header found for ${url}. Trying n-triples`) | ||
contentType = 'application/n-triples' | ||
} | ||
|
||
const parserStream = this.env.formats.parsers.import(contentType, response.body) | ||
if (!parserStream) { | ||
throw new Error(`No parser found for ${contentType}`) | ||
} | ||
|
||
return parserStream | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix p: <https://pipeline.described.at/> . | ||
@prefix base: <https://barnard59.zazuko.com/operations/base/> . | ||
@prefix n3: <https://barnard59.zazuko.com/operations/formats/n3/> . | ||
@prefix ntriples: <https://barnard59.zazuko.com/operations/formats/ntriples/> . | ||
@prefix getDataset: <https://barnard59.zazuko.com/operations/rdf/getDataset> . | ||
@prefix shacl: <https://barnard59.zazuko.com/operations/shacl/> . | ||
@prefix code: <https://code.described.at/> . | ||
|
||
@base <http://barnard59.zazuko.com/pipeline/shacl/> . | ||
|
||
_:shapes a p:Variable ; | ||
p:name "shapes" ; | ||
rdfs:label "URL or path of the shapes graph" ; | ||
. | ||
|
||
<validate> | ||
a p:Pipeline, p:Readable ; | ||
p:variables [ p:variable _:shapes ] ; | ||
p:steps | ||
[ | ||
p:stepList | ||
( | ||
[ base:stdin () ] | ||
<_validate> | ||
) | ||
] ; | ||
. | ||
|
||
<_validate> | ||
a p:Pipeline, p:Writable, p:Readable ; | ||
p:steps | ||
[ | ||
p:stepList | ||
( | ||
[ n3:parse () ] | ||
[ getDataset: () ] | ||
[ shacl:report ( _:getShapes ) ] | ||
[ base:flatten () ] | ||
[ ntriples:serialize () ] | ||
) | ||
] ; | ||
. | ||
|
||
_:getShapes a p:Pipeline, p:ReadableObjectMode ; | ||
p:steps | ||
[ | ||
p:stepList | ||
( | ||
[ | ||
a p:Step ; | ||
code:implementedBy | ||
[ | ||
a code:EcmaScriptModule ; | ||
code:link <file:../lib/getShapes.js#default> ; | ||
] ; | ||
code:arguments ( "shapes"^^p:VariableName ) ; | ||
] | ||
) | ||
] | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.