Skip to content

Commit dd5b203

Browse files
committed
initial commit
0 parents  commit dd5b203

13 files changed

+262
-0
lines changed

.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "bower_components"
3+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bower_components
2+
coverage
3+
node_modules

.jshintrc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"node": true,
3+
"browser": true,
4+
"esnext": true,
5+
"bitwise": true,
6+
"camelcase": true,
7+
"curly": true,
8+
"eqeqeq": true,
9+
"immed": true,
10+
"indent": 2,
11+
"latedef": true,
12+
"newcap": true,
13+
"noarg": true,
14+
"quotmark": "single",
15+
"regexp": true,
16+
"undef": true,
17+
"unused": true,
18+
"strict": true,
19+
"trailing": true,
20+
"smarttabs": true,
21+
"globals": {
22+
"angular": false
23+
}
24+
}

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js:
3+
- 0.10
4+
before_script:
5+
- npm install -g bower
6+
- bower install

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Angular slack
2+
3+
## Installation
4+
5+
`npm install --save angular-slack`
6+
7+
add `angular-slack` module to your app depedencies
8+
9+
## Usage
10+
11+
```js
12+
var message = {
13+
'text':'Hello world',
14+
'channel':'@someone',
15+
'username':'angular-slack'
16+
};
17+
18+
Slack.notify('myteam', 'token', message);
19+
```
20+
21+
## Build
22+
23+
`gulp`
24+
25+
## Test
26+
27+
`gulp test`
28+

bower.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "angular-slack",
3+
"version": "0.0.0",
4+
"authors": [
5+
"Paul-Emile MINY <[email protected]>"
6+
],
7+
"keywords": [
8+
"angular",
9+
"slack",
10+
"service"
11+
],
12+
"license": "MIT",
13+
"ignore": [
14+
"**/.*",
15+
"node_modules",
16+
"bower_components",
17+
"app/components",
18+
"test",
19+
"tests"
20+
],
21+
"devDependencies": {
22+
"angular-mocks": "~1.2.15",
23+
"angular": "~1.2.15"
24+
}
25+
}

gulpfile.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
3+
var gulp = require('gulp'),
4+
gulpLoadPlugins = require('gulp-load-plugins'),
5+
plugins = gulpLoadPlugins();
6+
7+
var testFiles = [
8+
'bower_components/angular/angular.js',
9+
'bower_components/angular-mocks/angular-mocks.js',
10+
'slack.js',
11+
'*.spec.js'
12+
];
13+
14+
gulp.task('scripts', function() {
15+
return gulp.src('slack.js')
16+
.pipe(plugins.rename('slack.min.js'))
17+
.pipe(plugins.ngmin())
18+
.pipe(plugins.uglify({
19+
preserveComments: 'some',
20+
outSourceMap: true
21+
}))
22+
.pipe(gulp.dest('.'));
23+
});
24+
25+
gulp.task('jshint', function() {
26+
gulp.src('*.js')
27+
.pipe(plugins.jshint())
28+
.pipe(plugins.jshint.reporter('jshint-stylish'));
29+
});
30+
31+
gulp.task('jasmine', function() {
32+
// Be sure to return the stream
33+
return gulp.src(testFiles)
34+
.pipe(plugins.karma({
35+
configFile: 'karma.conf.js',
36+
action: 'run'
37+
}))
38+
.on('error', function(err) {
39+
// Make sure failed tests cause gulp to exit non-zero
40+
throw err;
41+
});
42+
});
43+
44+
gulp.task('default', ['scripts']);
45+
46+
gulp.task('test', ['jasmine', 'jshint']);

karma.conf.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Karma configuration
2+
3+
module.exports = function (config) {
4+
config.set({
5+
basePath: '',
6+
files: [
7+
'bower_components/angular/angular.js',
8+
'bower_components/angular-mocks/angular-mocks.js',
9+
'slack.js',
10+
'*.spec.js'
11+
],
12+
13+
preprocessors: {
14+
'slack.js': ['coverage']
15+
},
16+
17+
reporters: ['progress', 'coverage'],
18+
19+
port: 9876,
20+
colors: true,
21+
22+
logLevel: config.LOG_INFO,
23+
24+
browsers: ['PhantomJS'],
25+
frameworks: ['jasmine'],
26+
27+
captureTimeout: 60000,
28+
29+
autoWatch: true,
30+
singleRun: true
31+
});
32+
};
33+

package.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "angular-slack",
3+
"version": "0.0.1",
4+
"main": "slack.min.js",
5+
"scripts": {
6+
"test": "grunt test"
7+
},
8+
"author": "Paul-Emile MINY",
9+
"license": "MIT",
10+
"devDependencies": {
11+
"gulp": "^3.6.0",
12+
"karma-coverage": "~0.1.4",
13+
"karma": "~0.10.2",
14+
"gulp-karma": "0.0.4",
15+
"gulp-util": "~2.2.14",
16+
"gulp-uglify": "^0.2.1",
17+
"gulp-rename": "^1.2.0",
18+
"gulp-ngmin": "~0.1.2",
19+
"karma-jasmine": "~0.1.3",
20+
"karma-firefox-launcher": "~0.1.0",
21+
"gulp-load-plugins": "^0.4.0",
22+
"karma-phantomjs-launcher": "^0.1.2",
23+
"gulp-jshint": "^1.5.2",
24+
"jshint-stylish": "^0.1.5"
25+
}
26+
}

slack.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
angular.module('angular-slack', [])
4+
.factory('Slack', ['$http', function ($http) {
5+
6+
var Slack = function() {
7+
};
8+
9+
Slack.prototype.notify = function (team, token, message) {
10+
11+
var config = {
12+
'params' : {
13+
'token': token
14+
},
15+
'headers': {'Content-Type': 'application/x-www-form-urlencoded'}
16+
};
17+
18+
var data = {
19+
'payload': message
20+
};
21+
22+
return $http.post('https://' + team + '.slack.com/services/hooks/incoming-webhook', data, config);
23+
24+
};
25+
26+
return new Slack();
27+
}]);
28+

slack.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

slack.min.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

slack.spec.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* global describe, it, beforeEach, inject */
2+
'use strict';
3+
4+
describe('slack', function () {
5+
6+
beforeEach(module('angular-slack'));
7+
8+
var Slack,
9+
$httpBackend;
10+
11+
beforeEach(inject(function ($injector) {
12+
Slack = $injector.get('Slack');
13+
$httpBackend = $injector.get('$httpBackend');
14+
}));
15+
16+
describe('#notify', function () {
17+
18+
it('should call http service with correct parameters', function () {
19+
20+
var message = {
21+
'text':'Hello world',
22+
'channel':'@someone',
23+
'username':'angular-slack'
24+
};
25+
26+
var data = {
27+
'payload': message
28+
};
29+
30+
$httpBackend.expectPOST('https://myteam.slack.com/services/hooks/incoming-webhook?token=token', data, undefined).respond(201, '');
31+
32+
Slack.notify('myteam', 'token', message);
33+
34+
$httpBackend.flush();
35+
});
36+
});
37+
38+
});

0 commit comments

Comments
 (0)