-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added submodule dependency, missing schema's, package.json, README an…
…d test fixed context.json
- Loading branch information
Showing
8 changed files
with
119 additions
and
13 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,3 @@ | ||
[submodule "curriculum-basis"] | ||
path = curriculum-basis | ||
url = https://github.com/slonl/curriculum-basis |
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,2 @@ | ||
# curriculum-samenhang | ||
SLO Samenhang curriculum (relaties en begrippen) |
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
Submodule curriculum-basis
added at
ce330e
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,17 @@ | ||
{ | ||
"name": "curriculum-samenhang", | ||
"description": "Curriculum Context: Samenhang (relaties en begrippen)", | ||
"main": "context.json", | ||
"scripts": { | ||
"test": "node test/test.mjs", | ||
"repl": "NODE_REPL_HISTORY=.repl_history && node test/repl.mjs" | ||
}, | ||
"author": "SLO", | ||
"license": "MIT", | ||
"dependencies": { | ||
"ajv": "^6.5.5", | ||
"curriculum-js": "^0.3.7", | ||
"jsondiffpatch": "^0.3.11", | ||
"uuid": "^3.3.2" | ||
} | ||
} |
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,22 @@ | ||
{ | ||
"@context": { | ||
"sh": "http://opendata.slo.nl/curriculum/schemas/samenhang.jsonld", | ||
"id": { | ||
"@id": "@id" | ||
}, | ||
"title": { | ||
"@id": "http://purl.org/dc/terms/title", | ||
"@type": "@id" | ||
}, | ||
"description": { | ||
"@id": "http://purl.org/dc/terms/description", | ||
"@type": "@id" | ||
}, | ||
"sh_tag": { | ||
"@id": "sh:#sh_tag" | ||
}, | ||
"sh_relatie": { | ||
"@id": "sh:#sh_relatie" | ||
} | ||
} | ||
} |
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,46 @@ | ||
// load the curriculum-js library | ||
import Curriculum from 'curriculum-js' | ||
// load node filesystem support | ||
import fs from 'fs' | ||
import repl from 'repl'; | ||
|
||
// create an async function, so we can use await inside it | ||
async function main() { | ||
|
||
// create new curriculum instance | ||
const curriculum = new Curriculum() | ||
|
||
// read the list of all contexts from the file /curriculum-contexts.txt | ||
const schemas = fs.readFileSync('curriculum-contexts.txt','utf8') | ||
.split(/\n/g) // split the file on newlines | ||
.map(line => line.trim()) // remove leading and trailing whitespace | ||
.filter(Boolean) // filter empty lines | ||
|
||
// load all contexts from the editor/ and master/ folders | ||
let loadedSchemas = schemas.map( | ||
schema => curriculum.loadContextFromFile(schema, schema+'/context.json') | ||
).concat( | ||
curriculum.loadContextFromFile('curriculum-samenhang', 'context.json') | ||
) | ||
|
||
// wait untill all contexts have been loaded, and return the promise values as schemas | ||
Promise.allSettled(loadedSchemas).then((settledSchemas) => { | ||
loadedSchemas = settledSchemas.map(promise => promise.value) | ||
}) | ||
.then(() => { | ||
|
||
var server = repl.start({ | ||
ignoreUndefined: true | ||
}); | ||
|
||
server.context.curriculum = curriculum; | ||
if (process.env.NODE_REPL_HISTORY) { | ||
server.setupHistory(process.env.NODE_REPL_HISTORY, (e) => { if (e) console.log(e); } ); | ||
} else { | ||
console.log('Set environment variable NODE_REPL_HISTORY=.repl_history to enable persistent REPL history'); | ||
} | ||
|
||
}) | ||
} | ||
|
||
main() |
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,23 @@ | ||
import Curriculum from "curriculum-js"; | ||
|
||
async function validate() { | ||
var curriculum = new Curriculum(); | ||
var schema = await curriculum.loadContextFromFile( | ||
"curriculum-samenhang", | ||
"context.json" | ||
); | ||
await curriculum.loadContextFromFile( | ||
"curriculum-samenhang", | ||
"curriculum-basis/context.json" | ||
); | ||
try { | ||
await curriculum.validate(schema); | ||
console.log("Data is valid!"); | ||
} catch (error) { | ||
error.validationErrors.forEach((error) => { | ||
console.log(error.instancePath + ": " + error.message); | ||
}); | ||
} | ||
} | ||
|
||
validate(); |