Skip to content

Commit

Permalink
Merge pull request #6 from zazuko/next
Browse files Browse the repository at this point in the history
Prepare 1.0 release
  • Loading branch information
bergos authored Jul 5, 2021
2 parents fa90e3b + 5af4130 commit 7cd7dd0
Show file tree
Hide file tree
Showing 25 changed files with 171 additions and 161 deletions.
2 changes: 1 addition & 1 deletion packages/rdf/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ jobs:
strategy:
matrix:
node:
- '12'
- '14'
- '16'
steps:
Expand All @@ -16,3 +15,4 @@ jobs:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test
- run: npm run coverage
1 change: 0 additions & 1 deletion packages/rdf/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.nyc_output
coverage
node_modules
package-lock.json
3 changes: 3 additions & 0 deletions packages/rdf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# v1.0.0

- Moved to JavaScript modules
6 changes: 3 additions & 3 deletions packages/rdf/cube.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const buildCubeShape = require('./lib/cube/buildCubeShape')
const toObservation = require('./lib/cube/toObservation')
import buildCubeShape from './lib/cube/buildCubeShape/index.js'
import toObservation from './lib/cube/toObservation.js'

module.exports = {
export {
buildCubeShape,
toObservation
}
4 changes: 2 additions & 2 deletions packages/rdf/lib/PatternMatcher.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const TermSet = require('@rdfjs/term-set')
import TermSet from '@rdfjs/term-set'

class PatternMatcher {
constructor ({ subject, predicate, object, graph } = {}) {
Expand Down Expand Up @@ -27,4 +27,4 @@ class PatternMatcher {
}
}

module.exports = PatternMatcher
export default PatternMatcher
12 changes: 6 additions & 6 deletions packages/rdf/lib/cube/buildCubeShape/Cube.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const clownface = require('clownface')
const rdf = require('rdf-ext')
const TermMap = require('@rdfjs/term-map')
const Dimension = require('./Dimension')
const ns = require('./namespaces')
import TermMap from '@rdfjs/term-map'
import clownface from 'clownface'
import rdf from 'rdf-ext'
import Dimension from './Dimension.js'
import * as ns from './namespaces.js'

class Cube {
constructor ({ term, observationSet, shape }) {
Expand Down Expand Up @@ -51,4 +51,4 @@ class Cube {
}
}

module.exports = Cube
export default Cube
12 changes: 6 additions & 6 deletions packages/rdf/lib/cube/buildCubeShape/Dimension.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const clownface = require('clownface')
const rdf = require('rdf-ext')
const TermMap = require('@rdfjs/term-map')
const TermSet = require('@rdfjs/term-set')
const ns = require('./namespaces')
import TermMap from '@rdfjs/term-map'
import TermSet from '@rdfjs/term-set'
import clownface from 'clownface'
import rdf from 'rdf-ext'
import * as ns from './namespaces.js'

const datatypeParsers = new TermMap([
[ns.xsd.date, term => new Date(term.value)],
Expand Down Expand Up @@ -99,4 +99,4 @@ class Dimension {
}
}

module.exports = Dimension
export default Dimension
18 changes: 9 additions & 9 deletions packages/rdf/lib/cube/buildCubeShape/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const clownface = require('clownface')
const TermMap = require('@rdfjs/term-map')
const TermSet = require('@rdfjs/term-set')
const rdf = require('rdf-ext')
const { Transform } = require('readable-stream')
const Cube = require('./Cube')
const ns = require('./namespaces')
const urlJoin = require('../../urlJoin')
import TermMap from '@rdfjs/term-map'
import TermSet from '@rdfjs/term-set'
import clownface from 'clownface'
import rdf from 'rdf-ext'
import { Transform } from 'readable-stream'
import urlJoin from '../../urlJoin.js'
import Cube from './Cube.js'
import * as ns from './namespaces.js'

function defaultCube ({ observationSet }) {
const observationSetIri = observationSet && observationSet.value
Expand Down Expand Up @@ -84,4 +84,4 @@ function buildCubeShape ({ excludeValuesOf } = {}) {
return new CubeShapeBuilder({ excludeValuesOf })
}

module.exports = buildCubeShape
export default buildCubeShape
16 changes: 7 additions & 9 deletions packages/rdf/lib/cube/buildCubeShape/namespaces.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
const namespace = require('@rdfjs/namespace')
import namespace from '@rdfjs/namespace'

const ns = {
cube: namespace('https://cube.link/'),
rdf: namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),
rdfs: namespace('http://www.w3.org/2000/01/rdf-schema#'),
sh: namespace('http://www.w3.org/ns/shacl#'),
xsd: namespace('http://www.w3.org/2001/XMLSchema#')
}
const cube = namespace('https://cube.link/')
const rdf = namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
const rdfs = namespace('http://www.w3.org/2000/01/rdf-schema#')
const sh = namespace('http://www.w3.org/ns/shacl#')
const xsd = namespace('http://www.w3.org/2001/XMLSchema#')

module.exports = ns
export { cube, rdf, rdfs, sh, xsd }
20 changes: 10 additions & 10 deletions packages/rdf/lib/cube/toObservation.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { URL } = require('url')
const clownface = require('clownface')
const namespace = require('@rdfjs/namespace')
const TermMap = require('@rdfjs/term-map')
const TermSet = require('@rdfjs/term-set')
const rdf = require('rdf-ext')
const { Transform } = require('readable-stream')
const dateToId = require('../dateToId')
const urlJoin = require('../urlJoin')
import { URL } from 'url'
import namespace from '@rdfjs/namespace'
import TermMap from '@rdfjs/term-map'
import TermSet from '@rdfjs/term-set'
import clownface from 'clownface'
import rdf from 'rdf-ext'
import { Transform } from 'readable-stream'
import dateToId from '../dateToId.js'
import urlJoin from '../urlJoin.js'

const ns = {
cube: namespace('https://cube.link/'),
Expand Down Expand Up @@ -241,4 +241,4 @@ function toObservation ({
return new ToObservation({ blacklist, dimensions, observation, observations, observer, useDate, dateProperty, useIndex })
}

module.exports = toObservation
export default toObservation
2 changes: 1 addition & 1 deletion packages/rdf/lib/dateToId.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ function dateToId (date) {
// [^0-9Z]
}

module.exports = dateToId
export default dateToId
6 changes: 3 additions & 3 deletions packages/rdf/lib/urlJoin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { join } = require('path')
const { URL } = require('url')
import { join } from 'path'
import { URL } from 'url'

function urlJoin (base, part) {
const url = new URL(base)
Expand All @@ -9,4 +9,4 @@ function urlJoin (base, part) {
return url.toString()
}

module.exports = urlJoin
export default urlJoin
4 changes: 2 additions & 2 deletions packages/rdf/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
rdfs:label "Map (RDF/JS Quad)";
rdfs:comment "Calls a map function only for quads matching the given triple pattern.";
code:implementedBy [ a code:EcmaScript;
code:link <node:barnard59-rdf/mapMatch.js>
code:link <node:barnard59-rdf/mapMatch.js#default>
].

<cube.js#buildCubeShape> a p:Operation, p:WritableObjectMode, p:ReadableObjectMode;
Expand All @@ -28,5 +28,5 @@
rdfs:label "Set Graph";
rdfs:comment "Sets the graph of all quads to the given fixed value.";
code:implementedBy [ a code:EcmaScript;
code:link <node:barnard59-rdf/setGraph.js>
code:link <node:barnard59-rdf/setGraph.js#default>
].
8 changes: 4 additions & 4 deletions packages/rdf/mapMatch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const rdf = require('rdf-ext')
const { Transform } = require('readable-stream')
const PatternMatcher = require('./lib/PatternMatcher')
import rdf from 'rdf-ext'
import { Transform } from 'readable-stream'
import PatternMatcher from './lib/PatternMatcher.js'

function mapMatch ({ map, subject, predicate, object, graph }) {
const matcher = new PatternMatcher({ subject, predicate, object, graph })
Expand All @@ -22,4 +22,4 @@ function mapMatch ({ map, subject, predicate, object, graph }) {
})
}

module.exports = mapMatch
export default mapMatch
18 changes: 12 additions & 6 deletions packages/rdf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.2.4",
"description": "RDF support for Linked Data pipelines",
"main": "index.js",
"type": "module",
"scripts": {
"test": "standard && nyc --reporter=lcov mocha"
"coverage": "codecov",
"test": "stricter-standard && c8 --reporter=lcov --reporter=text mocha"
},
"repository": {
"type": "git",
Expand All @@ -21,17 +23,21 @@
"@rdfjs/namespace": "^1.1.0",
"@rdfjs/term-map": "^1.0.0",
"@rdfjs/term-set": "^1.0.1",
"clownface": "^1.0.0",
"rdf-ext": "^1.3.0",
"clownface": "^1.3.0",
"rdf-ext": "^1.3.2",
"rdf-transform-triple-to-quad": "^1.0.2",
"readable-stream": "^3.6.0"
},
"devDependencies": {
"@rdfjs/to-ntriples": "^1.0.2",
"c8": "^7.7.3",
"codecov": "^3.8.2",
"get-stream": "^6.0.1",
"isstream": "^0.1.2",
"mocha": "^8.4.0",
"nyc": "^15.0.1",
"standard": "^16.0.3"
"mocha": "^9.0.1",
"stricter-standard": "^0.2.0"
},
"engines": {
"node": ">= 14.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/rdf/setGraph.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const rdf = require('rdf-ext')
const TripleToQuadTransform = require('rdf-transform-triple-to-quad')
import rdf from 'rdf-ext'
import TripleToQuadTransform from 'rdf-transform-triple-to-quad'

function setGraph (graph) {
const iri = (graph && graph.value) || (graph && graph.toString()) || ''
Expand All @@ -11,4 +11,4 @@ function setGraph (graph) {
return new TripleToQuadTransform(rdf.namedNode(iri), { factory: rdf })
}

module.exports = setGraph
export default setGraph
76 changes: 38 additions & 38 deletions packages/rdf/test/PatternMatcher.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const { strictEqual } = require('assert')
const { describe, it } = require('mocha')
const rdf = require('rdf-ext')
const ns = require('./support/namespaces')
const PatternMatcher = require('../lib/PatternMatcher')
import { strictEqual } from 'assert'
import { describe, it } from 'mocha'
import rdf from 'rdf-ext'
import PatternMatcher from '../lib/PatternMatcher.js'
import { ex } from './support/namespaces.js'

describe('PatternMatcher', () => {
it('should be a constructor', () => {
strictEqual(typeof PatternMatcher, 'function')
})

it('should assign the given terms to the pattern object', () => {
const subject = ns.ex.subject
const predicate = ns.ex.predicate
const object = ns.ex.object
const graph = ns.ex.graph
const subject = ex.subject
const predicate = ex.predicate
const object = ex.object
const graph = ex.graph

const matcher = new PatternMatcher({ subject, predicate, object, graph })

Expand All @@ -24,14 +24,14 @@ describe('PatternMatcher', () => {
})

it('should assign the given iterable to the pattern object', () => {
const subject1 = ns.ex.subject1
const subject2 = ns.ex.subject2
const predicate1 = ns.ex.predicate1
const predicate2 = ns.ex.predicate2
const object1 = ns.ex.object1
const object2 = ns.ex.object2
const graph1 = ns.ex.graph1
const graph2 = ns.ex.graph2
const subject1 = ex.subject1
const subject2 = ex.subject2
const predicate1 = ex.predicate1
const predicate2 = ex.predicate2
const object1 = ex.object1
const object2 = ex.object2
const graph1 = ex.graph1
const graph2 = ex.graph2

const matcher = new PatternMatcher({
subject: [subject1, subject2],
Expand All @@ -58,23 +58,23 @@ describe('PatternMatcher', () => {
})

it('should return false if the quad doesn\'t match the pattern', () => {
const subject = ns.ex.subject
const predicate = ns.ex.predicate
const object = ns.ex.object
const graph = ns.ex.graph
const subject = ex.subject
const predicate = ex.predicate
const object = ex.object
const graph = ex.graph

const matcher = new PatternMatcher({ subject, predicate, object, graph })

const result = matcher.test(rdf.quad(subject, predicate, object, ns.ex.graph1))
const result = matcher.test(rdf.quad(subject, predicate, object, ex.graph1))

strictEqual(result, false)
})

it('should return true if the subject matches', () => {
const subject = ns.ex.subject
const predicate = ns.ex.predicate
const object = ns.ex.object
const graph = ns.ex.graph
const subject = ex.subject
const predicate = ex.predicate
const object = ex.object
const graph = ex.graph

const matcher = new PatternMatcher({ subject })

Expand All @@ -84,10 +84,10 @@ describe('PatternMatcher', () => {
})

it('should return true if the predicate matches', () => {
const subject = ns.ex.subject
const predicate = ns.ex.predicate
const object = ns.ex.object
const graph = ns.ex.graph
const subject = ex.subject
const predicate = ex.predicate
const object = ex.object
const graph = ex.graph

const matcher = new PatternMatcher({ predicate })

Expand All @@ -97,10 +97,10 @@ describe('PatternMatcher', () => {
})

it('should return true if the object matches', () => {
const subject = ns.ex.subject
const predicate = ns.ex.predicate
const object = ns.ex.object
const graph = ns.ex.graph
const subject = ex.subject
const predicate = ex.predicate
const object = ex.object
const graph = ex.graph

const matcher = new PatternMatcher({ object })

Expand All @@ -110,10 +110,10 @@ describe('PatternMatcher', () => {
})

it('should return true if the graph matches', () => {
const subject = ns.ex.subject
const predicate = ns.ex.predicate
const object = ns.ex.object
const graph = ns.ex.graph
const subject = ex.subject
const predicate = ex.predicate
const object = ex.object
const graph = ex.graph

const matcher = new PatternMatcher({ graph })

Expand Down
4 changes: 2 additions & 2 deletions packages/rdf/test/cube.test.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require('./cube/buildCubeShape.test')
require('./cube/toObservation.test')
import './cube/buildCubeShape.test.js'
import './cube/toObservation.test.js'
Loading

0 comments on commit 7cd7dd0

Please sign in to comment.