diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1625e63a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{js,json,jsonld,yaml,yml}] +indent_style = space +indent_size = 2 + +[*.idl] +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore index aebca541..40233fb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,16 @@ -*.sw[op] +*.sw[nop] *~ +.bower.json +.cdtproject +.classpath .cproject .project *.sublime-project *.sublime-workspace .DS_Store .settings +TAGS coverage +dist node_modules v8.log diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a6af6bc..8d96333f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,33 +1,39 @@ # jsonld ChangeLog -## [Unreleased] +## Unreleased -## [0.4.11] - 2016-04-24 +### Changed +- Move `js/jsonld.js` to `lib/jsonld.js`. + +### Added +- Add .editorconfig support. + +## 0.4.11 - 2016-04-24 ### Changed - Add optimization for finding best CURIE matches. -## [0.4.10] - 2016-04-24 +## 0.4.10 - 2016-04-24 ### Changed - Add optimization for compacting keywords. -## [0.4.9] - 2016-04-23 +## 0.4.9 - 2016-04-23 ### Changed -- Add optimizations for _compactIri. +- Add optimizations for \_compactIri. -## [0.4.8] - 2016-04-14 +## 0.4.8 - 2016-04-14 ### Fixed - Revert es6-promise dependency to 2.x to avoid auto-polyfill behavior. -## [0.4.7] - 2016-04-14 +## 0.4.7 - 2016-04-14 ### Fixed - Testing document loader. -## [0.4.6] - 2016-03-02 +## 0.4.6 - 2016-03-02 ### Added - Add `headers` and `request` option for node doc loader. @@ -35,24 +41,24 @@ ### Changed - Include local tests. -## [0.4.5] - 2016-01-19 +## 0.4.5 - 2016-01-19 ### Fixed - N-Quads comments pattern. - Local tests. -## [0.4.4] - 2016-01-08 +## 0.4.4 - 2016-01-08 ### Fixed - Document cache in default node document loader is broken; disable until HTTP caching is implemented. -## [0.4.3] - 2016-01-05 +## 0.4.3 - 2016-01-05 ### Fixed - N-Quads may contain comments. -## [0.4.2] - 2015-10-12 +## 0.4.2 - 2015-10-12 ### Added - Add inputFormat and algorithm options to normalize. @@ -65,12 +71,12 @@ ### Fixed - Ignore null values in language maps. -## [0.4.1] - 2015-09-12 +## 0.4.1 - 2015-09-12 ### Changed - Ignore jsonld-request and pkginfo for browserify. -## [0.4.0] - 2015-09-12 +## 0.4.0 - 2015-09-12 ### Breaking Changes - "request" extension moved to [jsonld-request][]. This was done to simplify @@ -82,7 +88,7 @@ core JSON-LD processing library and because it uses the [jsonld-request][] module. -## [0.3.26] - 2015-09-01 +## 0.3.26 - 2015-09-01 ## Before 0.3.26 @@ -90,18 +96,3 @@ [jsonld-cli]: https://github.com/digitalbazaar/jsonld-cli [jsonld-request]: https://github.com/digitalbazaar/jsonld-request - -[Unreleased]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.11...HEAD -[0.4.11]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.10...0.4.11 -[0.4.10]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.9...0.4.10 -[0.4.9]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.8...0.4.9 -[0.4.8]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.7...0.4.8 -[0.4.7]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.6...0.4.7 -[0.4.6]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.5...0.4.6 -[0.4.5]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.4...0.4.5 -[0.4.4]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.3...0.4.4 -[0.4.3]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.2...0.4.3 -[0.4.2]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.1...0.4.2 -[0.4.1]: https://github.com/digitalbazaar/jsonld.js/compare/0.4.0...0.4.1 -[0.4.0]: https://github.com/digitalbazaar/jsonld.js/compare/0.3.26...0.4.0 -[0.3.26]: https://github.com/digitalbazaar/jsonld.js/compare/0.3.25...0.3.26 diff --git a/Makefile b/Makefile index 0c5cd9ae..ea39c9e5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ TESTS = tests/test.js +LOCAL_TESTS = test/*.js REPORTER = spec +JSONLD_TEST_SUITE=node_modules/json-ld-test-suite all: @@ -13,7 +15,7 @@ test-suite-node: exit 1; \ fi @if [ -d $(JSONLD_TEST_SUITE) ]; then \ - NODE_ENV=test ./node_modules/.bin/mocha -A -R $(REPORTER) $(TESTS); \ + NODE_ENV=test ./node_modules/.bin/mocha -t 30000 -A -R $(REPORTER) $(TESTS); \ else \ echo "Error: tests not found at $(JSONLD_TEST_SUITE)"; \ exit 1; \ @@ -51,10 +53,17 @@ test-normalization-browser: test-coverage: ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- \ - -u exports -R $(REPORTER) $(TESTS) + -t 30000 -u exports -R $(REPORTER) $(TESTS) + +test-coverage-lcov: + ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha \ + --report lcovonly -- -t 30000 -u exports -R $(REPORTER) $(TESTS) + +test-coverage-report: + ./node_modules/.bin/istanbul report test-local: - ./node_modules/.bin/mocha + ./node_modules/.bin/mocha -t 30000 -R $(REPORTER) $(LOCAL_TESTS) clean: rm -rf coverage diff --git a/README.md b/README.md index d006be32..1afa482d 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ bower install jsonld ```js require.config({ paths: { - jsonld: 'bower_components/jsonld/js/jsonld' + jsonld: 'bower_components/jsonld/lib/jsonld' } }); define(['jsonld'], function(jsonld) { ... }); diff --git a/bower.json b/bower.json index 8d5921db..cc5cff29 100644 --- a/bower.json +++ b/bower.json @@ -1,12 +1,24 @@ { "name": "jsonld", - "version": "0.4.12-dev", "description": "A JSON-LD Processor and API implementation in JavaScript.", + "keywords": [ + "JSON", + "Linked Data", + "JSON-LD", + "RDF", + "Semantic Web", + "jsonld" + ], "authors": [ - "Digital Bazaar, Inc." + "Digital Bazaar, Inc. (http://digitalbazaar.com/)" ], - "license": "BSD", - "main": ["js/jsonld.js"], + "license": "BSD-3-Clause", + "homepage": "http://github.com/digitalbazaar/jsonld.js", + "repository": { + "type": "git", + "url": "http://github.com/digitalbazaar/jsonld.js" + }, + "main": ["lib/jsonld.js"], "dependencies": { "es6-promise": "^2.0.0" }, diff --git a/js/jsonld.js b/lib/jsonld.js similarity index 99% rename from js/jsonld.js rename to lib/jsonld.js index 70758dbc..8f49e90e 100644 --- a/js/jsonld.js +++ b/lib/jsonld.js @@ -5731,6 +5731,15 @@ function _createTermDefinition(activeCtx, localCtx, term, defined) { {code: 'keyword redefinition', context: localCtx, term: term}); } + if(term === '@version') { + if(value !== 1.1) { + throw new JsonLdError( + 'Invalid JSON-LD syntax; version must be 1.1 if specified', + 'jsonld.SyntaxError', + {code: 'invalid @version value', context: localCtx}); + } + } + if(term === '') { throw new JsonLdError( 'Invalid JSON-LD syntax; a term cannot be an empty string.', diff --git a/package.json b/package.json index b351e4b7..1c1246e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsonld", - "version": "0.4.12-dev", + "version": "0.5.0-dev", "description": "A JSON-LD Processor and API implementation in JavaScript.", "homepage": "http://github.com/digitalbazaar/jsonld.js", "author": { @@ -9,10 +9,8 @@ "url": "http://digitalbazaar.com/" }, "contributors": [ - { - "name": "Dave Longley", - "email": "dlongley@digitalbazaar.com" - } + "Dave Longley ", + "David I. Lehn " ], "repository": { "type": "git", @@ -23,15 +21,15 @@ "email": "support@digitalbazaar.com" }, "license": "BSD-3-Clause", - "main": "js/jsonld.js", + "main": "lib/jsonld.js", "dependencies": { "es6-promise": "^2.0.0", + "json-ld-test-suite": "^1.0.1", "pkginfo": "~0.4.0", "request": "^2.61.0", "xmldom": "0.1.19" }, "devDependencies": { - "chai": "^3.4.1", "commander": "^2.8.0", "cors": "^2.7.1", "express": "^4.13.3", @@ -59,8 +57,9 @@ "test-browser": "make test-browser", "test": "make test", "coverage": "make test-coverage", - "jscs": "jscs js/jsonld.js tests/*.js", - "jshint": "jshint js/jsonld.js tests/*.js" + "coverage-report": "make test-coverage-report", + "jscs": "jscs lib/jsonld.js tests/*.js", + "jshint": "jshint lib/jsonld.js tests/*.js" }, "browser": { "crypto": "./browser/ignore.js", diff --git a/test/node-document-loader-tests.js b/test/node-document-loader-tests.js index 41ff114e..acb3ccf0 100644 --- a/test/node-document-loader-tests.js +++ b/test/node-document-loader-tests.js @@ -3,7 +3,7 @@ * * @author goofballLogic */ -var jsonld = require('../js/jsonld'); +var jsonld = require('..'); var assert = require('assert'); describe('For the node.js document loader', function() { @@ -16,9 +16,12 @@ describe('For the node.js document loader', function() { describe('When built with no options specified', function() { var options = {}; - it('loading should work', function(callback) { + it('loading should work', function(done) { jsonld.useDocumentLoader(documentLoaderType); - jsonld.expand('http://schema.org/', callback); + jsonld.expand('http://schema.org/', function(err, expanded) { + assert.ifError(err); + done(); + }); }); }); diff --git a/tests/test.js b/tests/test.js index 6dc999a8..50bd15d4 100644 --- a/tests/test.js +++ b/tests/test.js @@ -14,7 +14,7 @@ var _nodejs = (typeof process !== 'undefined' && process.versions && process.versions.node); if(_nodejs) { - var _jsdir = getEnv().JSDIR || 'js'; + var _jsdir = getEnv().JSDIR || 'lib'; var fs = require('fs'); var path = require('path'); var jsonld = require('../' + _jsdir + '/jsonld')(); @@ -60,11 +60,11 @@ if(_nodejs) { var fs = require('fs'); var system = require('system'); require('./setImmediate'); - var _jsdir = getEnv().JSDIR || 'js'; + var _jsdir = getEnv().JSDIR || 'lib'; require('../' + _jsdir + '/jsonld'); jsonld = jsonldjs; window.Promise = require('es6-promise').Promise; - var assert = require('chai').assert; + var assert = require('assert'); require('mocha/mocha'); require('mocha-phantomjs/lib/mocha-phantomjs/core_extensions'); var program = {};