Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor & CI #1

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.DS_Store
36 changes: 36 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "5"
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -22,7 +23,7 @@ The input `statement` may either be JSON string of an xAPI statement or a Javasc
"actor": {
"mbox": "mailto:[email protected]"
},
"verb": {
"verb": {
"id": "http://adlnet.gov/expapi/verbs/created",
"display" :{"en-US": "created"}
},
Expand Down Expand Up @@ -59,7 +60,7 @@ The produced report object contains three key properties: a collection of any `e
"actor": {
"mbox": "mailto:[email protected]"
},
"verb": {
"verb": {
"id": "http://adlnet.gov/expapi/verbs/created",
"display" :{"en-US": "created"}
},
Expand Down Expand Up @@ -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
MIT License (C) 2013 Zachary Pierce, Measured Progress
91 changes: 91 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var xapiValidator = require('./xapiValidator');
module.exports = xapiValidator;
43 changes: 37 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
11 changes: 6 additions & 5 deletions spec/mocha_runner.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>xAPI Validator</title>
<link rel="stylesheet" href="lib/mocha.css" />
</head>
<body>
Expand All @@ -9,14 +10,14 @@
<script src="lib/chai.js"></script>
<script src="lib/underscore.js"></script>
<script>
mocha.setup('bdd');
mocha.setup('bdd');
expect = chai.expect;
</script>
<script src="../xapiValidator.js"></script>
<script src="xapiValidator_spec.js"></script>
<script src="../lib/xapiValidator.js"></script>
<script src="xapiValidator.test.js"></script>
<script>
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
else { mocha.run(); }
</script>
</body>
</html>
</html>
Loading