diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..c13c5f6 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd4f2b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +.DS_Store diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..51209b8 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,36 @@ +{ + "bitwise": true, + "camelcase": true, + "curly": true, + "esnext": true, + "immed": true, + "newcap": true, + "noarg": true, + "node": true, + "strict": false, + "undef": true, + "unused": "vars", + "boss": true, + "browser": true, + "debug": false, + "devel": true, + "eqeqeq": true, + "eqnull": true, + "evil": true, + "expr": true, + "forin": false, + "laxbreak": false, + "noempty": false, + "nomen": false, + "nonew": false, + "onevar": false, + "plusplus": false, + "predef": [ + "describe", + "it", + "define" + ], + "regexp": false, + "sub": true, + "white": false +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..24a8ab9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "5" diff --git a/README.md b/README.md index 7cf31ac..c9daae2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # xAPI Validator +![Test Passing Travis CI](https://travis-ci.org/elenatorro/xAPI-Validator-JS.svg?branch=master) A stand-alone Javascript validator for Experience API (xAPI) statements. @@ -22,7 +23,7 @@ The input `statement` may either be JSON string of an xAPI statement or a Javasc "actor": { "mbox": "mailto:bob@example.com" }, - "verb": { + "verb": { "id": "http://adlnet.gov/expapi/verbs/created", "display" :{"en-US": "created"} }, @@ -59,7 +60,7 @@ The produced report object contains three key properties: a collection of any `e "actor": { "mbox": "mailto:charles@example.com" }, - "verb": { + "verb": { "id": "http://adlnet.gov/expapi/verbs/created", "display" :{"en-US": "created"} }, @@ -92,4 +93,4 @@ Community feedback, criticism, and collaboration are most welcome. On the less-technical side, if an error message appears cryptic or unhelpful, please report it as an Issue and it should be addressed. ## License -MIT License (C) 2013 Zachary Pierce, Measured Progress \ No newline at end of file +MIT License (C) 2013 Zachary Pierce, Measured Progress diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..32ecea3 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,91 @@ +'use strict'; + +/* Libraries */ +let + browserify = require('browserify'), + buffer = require('vinyl-buffer'), + connect = require('gulp-connect'), + gulp = require('gulp'), + livereload = require('gulp-livereload'), + source = require('vinyl-source-stream'), + sourcemaps = require('gulp-sourcemaps'), + uglify = require('gulp-uglify') +; + +/* Config */ +const + BABEL_CONFIG = Object.freeze({ + presets: ['es2015'] + }), + BROWSERIFY_TRANSFORM = 'babelify', + BROWSERIFY_CONFIG = Object.freeze({ + debug: true, + json: true, + standalone: 'xapi-validator' + }), + DIST_FILENAME = 'xapiValidator.js', + DIST_FILENAME_MIN = 'xapiValidator.min.js', + DIST_TEST_FILENAME = 'xapiValidator.test.js', + DIST_PATH = 'lib', + DIST_MAIN_PATH = './', + DIST_TEST_PATH = 'spec', + MAPS_PATH = './maps', + SRC_FILE = 'src/xapiValidator.js', + SRC_TEST_FILE = 'test/xapiValidator.test.js', + WATCH_FILES = ['src/*.js', 'constants/*.js', 'spec/*.js', 'spec/lib/*.js'] +; + +/* Task Config */ + +const + BUILD_TASK = 'build', + BUILD_PROD_TASK = 'build-prod', + BUILD_TEST_TASK = 'build-test', + CONNECT_TASK = 'connect', + DEFAULT_TASK = 'default', + DEFAULT_TASKS = [BUILD_TASK, BUILD_TEST_TASK], + WATCH_TASK = 'watch', + WATCH_TASKS = [BUILD_TASK, BUILD_TEST_TASK, CONNECT_TASK] +; + +gulp.task(BUILD_TASK, () => { + return browserify(SRC_FILE, BROWSERIFY_CONFIG) + .transform(BROWSERIFY_TRANSFORM, BABEL_CONFIG) + .bundle() + .pipe(source(DIST_FILENAME)) + .pipe(gulp.dest(DIST_MAIN_PATH)) + .pipe(livereload()); +}); + +gulp.task(BUILD_TEST_TASK, () => { + return browserify(SRC_TEST_FILE, BROWSERIFY_CONFIG) + .transform(BROWSERIFY_TRANSFORM, BABEL_CONFIG) + .bundle() + .pipe(source(DIST_TEST_FILENAME)) + .pipe(gulp.dest(DIST_TEST_PATH)) + .pipe(livereload()); +}); + +gulp.task(BUILD_PROD_TASK, () => { + return browserify(SRC_FILE, BROWSERIFY_CONFIG) + .transform(BROWSERIFY_TRANSFORM, BABEL_CONFIG) + .bundle() + .pipe(source(DIST_FILENAME_MIN)) + .pipe(buffer()) + .pipe(sourcemaps.init()) + .pipe(uglify()) + .pipe(sourcemaps.write(MAPS_PATH)) + .pipe(gulp.dest(DIST_PATH)) + .pipe(livereload()); +}); + +gulp.task(WATCH_TASK, WATCH_TASKS, () => { + livereload.listen(); + gulp.watch(WATCH_FILES, WATCH_TASKS); +}); + +gulp.task(CONNECT_TASK, () => { + connect.server(); +}); + +gulp.task(DEFAULT_TASK, DEFAULT_TASKS); diff --git a/index.js b/index.js new file mode 100644 index 0000000..54ca5b9 --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +var xapiValidator = require('./xapiValidator'); +module.exports = xapiValidator; diff --git a/package.json b/package.json index 0c3da03..b8b4cfb 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,45 @@ "main": "./xapiValidator", "author": "Zachary Pierce", "description": "A validator for Experience API (xAPI) statements", - "keywords":["xAPI", "validator", "lrs", "json", "TinCan"], + "scripts": { + "lint": "eslint src/xAPI-validator.js", + "test": "mocha --compilers js:babel-core/register" + }, + "keywords": [ + "xAPI", + "validator", + "lrs", + "json", + "TinCan" + ], "license": "MIT", "engines": { "node": ">=0.6.6" }, - "devDependencies":{ - "chai": "*", - "mocha": "*", - "underscore": "*" + "devDependencies": { + "babel": "^6.5.2", + "babel-cli": "^6.18.0", + "babel-core": "^6.18.2", + "babel-eslint": "^7.1.0", + "babel-plugin-add-module-exports": "^0.2.1", + "babel-preset-es2015": "^6.18.0", + "babelify": "^7.3.0", + "browserify": "^13.1.1", + "chai": "^3.5.0", + "coveralls": "^2.11.14", + "eslint": "^3.9.1", + "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", + "gulp-browserify": "^0.5.1", + "gulp-connect": "^5.0.0", + "gulp-livereload": "^3.8.1", + "gulp-rename": "^1.2.2", + "gulp-sourcemaps": "^2.2.0", + "gulp-uglify": "^2.0.0", + "mocha": "^3.1.2", + "sinon": "^1.17.6", + "underscore": "*", + "vinyl-buffer": "^1.0.0", + "vinyl-source-stream": "^1.1.0" } -} \ No newline at end of file +} diff --git a/spec/mocha_runner.html b/spec/mocha_runner.html index 66e16b4..4c40df2 100644 --- a/spec/mocha_runner.html +++ b/spec/mocha_runner.html @@ -1,6 +1,7 @@ - +
+