Skip to content
Snippets Groups Projects
Commit 5fd168f7 authored by Mike Lynch's avatar Mike Lynch
Browse files

tests are passing, had to skip a couple which expected an inline context

parent 569e4c3b
Branches
Tags
No related merge requests found
// Quick tool for making a datacrate from a data pub // Quick tool for making a datacrate from a data pub
// FIXME - convert to ro-crate
const datacrate = require('./lib/catalog.js'); const datacrate = require('./lib/catalog.js');
const calcyte = require('calcyte'); const calcyte = require('calcyte');
......
...@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
const fs = require('fs-extra'); const fs = require('fs-extra');
const _ = require('lodash'); const _ = require('lodash');
const path = require('path'); const path = require('path');
const rocrate_defaults = require('ro-crate').Defaults;
const DEFAULTS = path.join(__dirname, "../defaults"); const DEFAULTS = path.join(__dirname, "../defaults");
const GEOCONTEXT = path.join(DEFAULTS, 'geojson-context.json'); const GEOCONTEXT = path.join(DEFAULTS, 'geojson-context.json');
...@@ -191,9 +191,6 @@ async function rb2rocrate(options) { ...@@ -191,9 +191,6 @@ async function rb2rocrate(options) {
} }
}); });
const context = calcyte.defaults.context;
// this isn't working with trim_context, which is clobbering the // this isn't working with trim_context, which is clobbering the
// geojson types for reasons I don't understand - see PT // geojson types for reasons I don't understand - see PT
...@@ -223,20 +220,13 @@ async function rb2rocrate(options) { ...@@ -223,20 +220,13 @@ async function rb2rocrate(options) {
"@type": "DataDownload", "@type": "DataDownload",
"encodingFormat": "zip" "encodingFormat": "zip"
}); });
context["DataDownload"] = "https://schema.org/DataDownload";
context["distribution"] = "https://schema.org/distribution";
} }
const catalog = { return {
'@context': context, '@context': rocrate_defaults.context,
'@graph': graph.filter((e) => e) '@graph': graph.filter((e) => e)
}; };
const jsonld = new calcyte.jsonld();
jsonld.init(catalog);
jsonld.trim_context();
return jsonld.json_ld;
} }
......
...@@ -95,6 +95,7 @@ async function make_jsonld(datapub) { ...@@ -95,6 +95,7 @@ async function make_jsonld(datapub) {
// get the root of the ro-crate // get the root of the ro-crate
// FIXME - use the native ro-crate root finder
function get_root(c) { function get_root(c) {
const roots = c['@graph'].filter((item) => {return item['path'] === './' }); const roots = c['@graph'].filter((item) => {return item['path'] === './' });
return roots[0]; return roots[0];
...@@ -196,7 +197,7 @@ describe("Try to load a janky default DataPub with empty fields", () => { ...@@ -196,7 +197,7 @@ describe("Try to load a janky default DataPub with empty fields", () => {
}) })
}); });
it("has no @types which don't appear in the @context", () => { it.skip("has no @types which don't appear in the @context", () => {
cj['@graph'].map((i) => { cj['@graph'].map((i) => {
expect(i).to.have.property('@type'); expect(i).to.have.property('@type');
const type = i['@type']; const type = i['@type'];
...@@ -268,7 +269,7 @@ describe("Convert a ReDBox 2.0 DataPub to json-ld", () => { ...@@ -268,7 +269,7 @@ describe("Convert a ReDBox 2.0 DataPub to json-ld", () => {
}) })
}); });
it("has no @types which don't appear in the @context", () => { it.skip("has no @types which don't appear in the @context", () => {
cj['@graph'].map((i) => { cj['@graph'].map((i) => {
expect(i).to.have.property('@type'); expect(i).to.have.property('@type');
const type = i['@type']; const type = i['@type'];
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment