Skip to content

Commit f5a6d5d

Browse files
author
Evan Sharp
committed
Chore(build): Created build and tests.
1 parent 0d9eaa8 commit f5a6d5d

13 files changed

+455
-39
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
bower_components
2+
node_modules

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The "data-match" attribute should be set equal to the ng-model value of the fiel
1010
Installation
1111
------------
1212

13-
`bower install angular-input-match`
13+
`bower install angular-validation-match`
1414

1515
Then add `validation.match` to your angular dependencies
1616

bower.json

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
{
2-
"name": "angular-input-match",
3-
"version": "1.0.0",
4-
"homepage": "https://github.com/TheSharpieOne/angular-input-match",
5-
"authors": [
6-
"TheSharpieOne"
7-
],
8-
"description": "Checks if one input matches another",
9-
"main": "match.js",
10-
"keywords": [
11-
"Angular",
12-
"input",
13-
"form",
14-
"confirmation",
15-
"match",
16-
"validation"
17-
],
18-
"repository": {
19-
"type": "git",
20-
"url": "git://github.com/TheSharpieOne/angular-input-match"
2+
"name": "angular-input-match",
3+
"version": "1.1.0",
4+
"homepage": "https://github.com/TheSharpieOne/angular-input-match",
5+
"authors": [
6+
"TheSharpieOne <[email protected]>"
7+
],
8+
"description": "Checks if one input matches another",
9+
"main": "dist/match.min.js",
10+
"keywords": [
11+
"Angular",
12+
"input",
13+
"form",
14+
"confirmation",
15+
"match",
16+
"validation"
17+
],
18+
"repository": {
19+
"type": "git",
20+
"url": "git://github.com/TheSharpieOne/angular-input-match"
2121
},
22-
"licenses": [
23-
{
24-
"type": "MIT",
25-
"url": "http://www.opensource.org/licenses/MIT"
22+
"licenses": [
23+
{
24+
"type": "MIT",
25+
"url": "http://www.opensource.org/licenses/MIT"
26+
}
27+
],
28+
"ignore": [
29+
"**/.*",
30+
"node_modules",
31+
"bower_components",
32+
"test",
33+
"tests"
34+
],
35+
"dependencies": {
36+
"angular": ">=1.2.0 <2.0.0"
37+
},
38+
"devDependencies": {
39+
"angular-mocks": ">=1.2.0 <2.0.0"
2640
}
27-
],
28-
"ignore": [
29-
"**/.*",
30-
"node_modules",
31-
"bower_components",
32-
"test",
33-
"tests"
34-
],
35-
"dependencies": {
36-
"angular": ">=1.2.0 <2.0.0"
37-
}
3841
}

build/angular-input-match.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*!
2+
* angular-input-match
3+
* Checks if one input matches another
4+
* @version v1.0.0
5+
* @link https://github.com/TheSharpieOne/angular-input-match
6+
* @license MIT License, http://www.opensource.org/licenses/MIT
7+
*/
8+
(function(window, angular, undefined){'use strict';
9+
10+
angular.module('validation.match', []);
11+
12+
angular.module('validation.match').directive('match', match);
13+
14+
function match () {
15+
return {
16+
require: '?ngModel',
17+
restrict: 'A',
18+
scope: {
19+
match: '='
20+
},
21+
link: function(scope, elem, attrs, ctrl) {
22+
if(!ctrl) {
23+
console && console.warn('Match validation requires ngModel to be on the element');
24+
return;
25+
}
26+
27+
scope.$watch(function() {
28+
var modelValue = angular.isUndefined(ctrl.$modelValue)? ctrl.$$invalidModelValue : ctrl.$modelValue;
29+
return (ctrl.$pristine && angular.isUndefined(modelValue)) || scope.match === modelValue;
30+
}, function(currentValue) {
31+
ctrl.$setValidity('match', currentValue);
32+
});
33+
}
34+
};
35+
}
36+
})(window, window.angular);

build/angular-input-match.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-input-match.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*!
2+
* angular-input-match
3+
* Checks if one input matches another
4+
* @version v1.0.0
5+
* @link https://github.com/TheSharpieOne/angular-input-match
6+
* @license MIT License, http://www.opensource.org/licenses/MIT
7+
*/
8+
(function(window, angular, undefined){'use strict';
9+
10+
angular.module('validation.match', []);
11+
12+
angular.module('validation.match').directive('match', match);
13+
14+
function match () {
15+
return {
16+
require: '?ngModel',
17+
restrict: 'A',
18+
scope: {
19+
match: '='
20+
},
21+
link: function(scope, elem, attrs, ctrl) {
22+
if(!ctrl) {
23+
console && console.warn('Match validation requires ngModel to be on the element');
24+
return;
25+
}
26+
27+
scope.$watch(function() {
28+
var modelValue = angular.isUndefined(ctrl.$modelValue)? ctrl.$$invalidModelValue : ctrl.$modelValue;
29+
return (ctrl.$pristine && angular.isUndefined(modelValue)) || scope.match === modelValue;
30+
}, function(currentValue) {
31+
ctrl.$setValidity('match', currentValue);
32+
});
33+
}
34+
};
35+
}
36+
})(window, window.angular);

dist/angular-input-match.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

files.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
var pkg = require('./package.json');
2+
3+
var pkgFiles = {
4+
angular: [
5+
'bower_components/angular/angular.js'
6+
],
7+
karma: [
8+
'bower_components/angular/angular.js',
9+
'bower_components/angular-mocks/angular-mocks.js'
10+
],
11+
'karma-build': [
12+
'@karma',
13+
'build/' + pkg.name + '.js',
14+
'@karma-tests'
15+
],
16+
'karma-min': [
17+
'@karma',
18+
'build/' + pkg.name + '.min.js',
19+
'@karma-tests'
20+
],
21+
'karma-src': [
22+
'@karma',
23+
'@src',
24+
'@karma-tests'
25+
],
26+
'karma-tests': [
27+
'test/**/*.spec.js'
28+
],
29+
src: [
30+
'src/**/*.js',
31+
]
32+
};
33+
34+
if (module.exports) {
35+
module.exports.files = pkgFiles;
36+
module.exports.mergeFilesFor = function() {
37+
var files = [];
38+
39+
Array.prototype.slice.call(arguments, 0).forEach(function(filegroup) {
40+
pkgFiles[filegroup].forEach(function(file) {
41+
// replace @ref
42+
var match = file.match(/^\@(.*)/);
43+
if (match) {
44+
files = files.concat(pkgFiles[match[1]]);
45+
} else {
46+
files.push(file);
47+
}
48+
});
49+
});
50+
51+
return files;
52+
};
53+
}

gulpfile.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
var ngAnnotate = require('gulp-ng-annotate');
5+
var uglify = require('gulp-uglifyjs');
6+
var wrap = require('gulp-wrap');
7+
var bump = require('gulp-bump');
8+
var gulpKarma = require('gulp-karma');
9+
var gulpSequence = require('gulp-sequence').use(gulp);
10+
var pkg = require('./package.json');
11+
var files = require('./files');
12+
13+
var karmaTestConfig = gulpKarma({configFile: 'karma.conf.js', action: 'run'});
14+
15+
var banner = '/*!\n' +
16+
' * <%= pkg.name %>\n' +
17+
' * <%= pkg.description %>\n' +
18+
' * @version v<%= pkg.version %>\n' +
19+
' * @link <%= pkg.homepage %>\n' +
20+
' * @license MIT License, http://www.opensource.org/licenses/MIT\n' +
21+
' */\n'
22+
23+
gulp.task('bump', function(){
24+
gulp.src('./*.json')
25+
.pipe(bump({type:'minor'}))
26+
.pipe(gulp.dest('./'));
27+
});
28+
29+
gulp.task('buildDev', function () {
30+
gulp.src(files.mergeFilesFor('src'))
31+
.pipe(wrap(banner+'(function(window, angular, undefined){<%= contents %>})(window, window.angular);', {pkg: pkg}))
32+
.pipe(ngAnnotate())
33+
.pipe(gulp.dest('./build/'));
34+
});
35+
36+
gulp.task('minBuild', function () {
37+
gulp.src('./build/'+pkg.name+'.js')
38+
.pipe(uglify(pkg.name+'.min.js', {
39+
outSourceMap: false,
40+
mangle: true,
41+
preserveComments: 'some'
42+
}))
43+
.pipe(gulp.dest('./build/'));
44+
});
45+
46+
gulp.task('copyBuild', function () {
47+
gulp.src('./build/*.js')
48+
.pipe(gulp.dest('./dist/'));
49+
});
50+
51+
gulp.task('default', function(){
52+
gulp.watch(files.mergeFilesFor('src'), ['test']);
53+
})
54+
55+
gulp.task('test', function () {
56+
return gulp.src(files.mergeFilesFor('karma-src')).pipe(karmaTestConfig);
57+
});
58+
59+
gulp.task('testBuild', function () {
60+
return gulp.src(files.mergeFilesFor('karma-build')).pipe(karmaTestConfig);
61+
});
62+
63+
gulp.task('testMin', function () {
64+
return gulp.src(files.mergeFilesFor('karma-min')).pipe(karmaTestConfig);
65+
});
66+
67+
gulp.task('blah', gulpSequence('testBuild','buildDev','minBuild'));
68+
69+
gulp.task('build', gulpSequence('buildDev', 'minBuild', ['testBuild','testMin']));
70+
71+
gulp.task('release', gulpSequence('build','copyBuild','bump'));

karma.conf.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Karma configuration
2+
// Generated on Thu Jan 09 2014 13:59:16 GMT-0500 (EST)
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: './',
7+
8+
frameworks: ['mocha', 'chai-sinon'],
9+
10+
exclude: [],
11+
12+
reporters: ['progress'],
13+
14+
port: 9876,
15+
16+
runnerPort: 9100,
17+
18+
colors: true,
19+
20+
logLevel: config.LOG_INFO,
21+
22+
autoWatch: true,
23+
24+
// Start these browsers, currently available:
25+
// - Chrome
26+
// - ChromeCanary (has to be installed with `npm install karma-chrome-canary-launcher`)
27+
// - Firefox (has to be installed with `npm install karma-firefox-launcher`)
28+
// - Opera (has to be installed with `npm install karma-opera-launcher`)
29+
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
30+
// - PhantomJS
31+
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
32+
browsers: ['PhantomJS'],
33+
34+
captureTimeout: 60000,
35+
36+
singleRun: false
37+
});
38+
};

0 commit comments

Comments
 (0)