-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,023 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,26 @@ | ||
{ | ||
"node": true, | ||
"browser": true, | ||
"esnext": true, | ||
"bitwise": true, | ||
"camelcase": false, | ||
"browser": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"eqnull": true, | ||
"expr": true, | ||
"esnext": true, | ||
"exported": ["attempt"], | ||
"globals": { | ||
"Backbone": true, | ||
"Minionette": true, | ||
"_": true, | ||
"attempt": true | ||
}, | ||
"immed": true, | ||
"indent": 4, | ||
"jquery": true, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"regexp": true, | ||
"undef": true, | ||
"unused": true, | ||
"node": true, | ||
"strict": false, | ||
"trailing": true, | ||
"smarttabs": true, | ||
"jquery": true, | ||
"white": false, | ||
"globals": { | ||
"jQuery": true, | ||
"Backbone": true, | ||
"_": true, | ||
"Minionette": true, | ||
"attempt": true, | ||
"slice": true, | ||
"define": true, | ||
"sinon": true, | ||
"chai": true, | ||
"sinonChai": true, | ||
"jqueryChai": true, | ||
"describe": true, | ||
"before": true, | ||
"beforeEach": true, | ||
"after": true, | ||
"afterEach": true, | ||
"expect": true, | ||
"it": true | ||
}, | ||
"exported": ["attempt"] | ||
"undef": true, | ||
"unused": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var gulp = require('gulp'); | ||
var karma = require('karma').server; | ||
var jshint = require('gulp-jshint'); | ||
var uglify = require('gulp-uglify'); | ||
var rename = require('gulp-rename'); | ||
var preprocess = require('gulp-preprocess'); | ||
var esformatter = require('gulp-esformatter'); | ||
var minimist = require('minimist'); | ||
|
||
var opts = minimist(process.argv.slice(2)); | ||
|
||
gulp.task('test', function (done) { | ||
karma.start({ | ||
configFile: __dirname + '/karma.conf.js', | ||
singleRun: !opts.continuous | ||
}, done); | ||
}); | ||
|
||
gulp.task('jshint', function() { | ||
return gulp.src('src/*.js') | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter('default', {verbose: true})) | ||
.pipe(jshint.reporter('fail')); | ||
}); | ||
|
||
gulp.task('build', ['default'], function() { | ||
return gulp.src(['./src/build/*.js']) | ||
.pipe(preprocess()) | ||
.pipe(esformatter({ indent: { value: ' ' } })) | ||
.pipe(gulp.dest('lib')) | ||
.pipe(uglify()) | ||
.pipe(rename({ suffix: '-min' })) | ||
.pipe(gulp.dest('lib')); | ||
}); | ||
|
||
gulp.task('default', ['jshint', 'test']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,15 @@ | ||
// A helper function, similar to _.result | ||
// that will return the property on obj, unless obj | ||
// is undefined or null. Passes the 3rd params | ||
// as arguments to the property, if it is a method | ||
function attempt(obj, property, args) { | ||
// that will call the prop on obj, unless obj | ||
// is undefined or null. Passes the 3rd param | ||
// as arguments to the method. | ||
function attempt(obj, prop, args) { | ||
// Return undefined unless obj | ||
// is not null or undefined | ||
if (obj == null) { return void 0; } | ||
var prop = obj[property]; | ||
var fn = obj[prop]; | ||
|
||
if (_.isFunction(prop)) { | ||
var length; | ||
if (_.isArray(args)) { | ||
length = args.length; | ||
} else { | ||
length = (args == null) ? 0 : -1; | ||
} | ||
switch (length) { | ||
case -1: | ||
return obj[property](args); | ||
case 0: | ||
return obj[property](); | ||
case 1: | ||
return obj[property](args[0]); | ||
case 2: | ||
return obj[property](args[0], args[1]); | ||
case 3: | ||
return obj[property](args[0], args[1], args[2]); | ||
} | ||
return prop.apply(obj, args); | ||
if (_.isFunction(fn)) { | ||
var apply = _.isArray(args); | ||
return apply ? fn.apply(obj, args) : obj[prop](args); | ||
} | ||
return prop; | ||
} |
Oops, something went wrong.