Skip to content

Commit 33b2761

Browse files
committed
chore: create non-minified dist file (#1)
1 parent 03d15c3 commit 33b2761

File tree

5 files changed

+174
-13
lines changed

5 files changed

+174
-13
lines changed

Gruntfile.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
11
module.exports = function(grunt) {
22

3+
var banner = '/**\n @name: <%= pkg.name %> \n @version: <%= pkg.version %> (<%= grunt.template.today("dd-mm-yyyy") %>) \n @author: <%= pkg.author %> \n @url: <%= pkg.homepage %> \n @license: <%= pkg.license %>\n*/\n';
4+
35
grunt.initConfig({
46
pkg: grunt.file.readJSON('package.json'),
57
uglify: {
68
js: {
79
files : {
8-
'dist/angular-github-api-factory.min.js' : ['src/angular-github-api-factory.js']
10+
'dist/angular-github-api-factory.min.js' : ['src/*.js']
911
}
1012
},
1113
options: {
12-
banner: '\n/*! <%= pkg.name %> v<%= pkg.version %> (<%= grunt.template.today("dd-mm-yyyy") %>) by <%= pkg.author %> */\n',
14+
banner: banner,
1315
}
1416
},
17+
concat: {
18+
options: {
19+
separator: ';',
20+
banner: banner,
21+
},
22+
dist: {
23+
files : {
24+
'dist/angular-github-api-factory.js' : ['src/*.js']
25+
}
26+
},
27+
},
1528
watch: {
1629
minifiyJs: {
1730
files: [
18-
'src/angular-github-api-factory.js'
31+
'src/*.js'
1932
],
20-
tasks: ['uglify'],
33+
tasks: ['uglify', 'concat'],
2134
options: {
2235
spawn: true,
2336
},
@@ -27,6 +40,7 @@ module.exports = function(grunt) {
2740

2841
grunt.loadNpmTasks('grunt-contrib-uglify');
2942
grunt.loadNpmTasks('grunt-contrib-watch');
43+
grunt.loadNpmTasks('grunt-contrib-concat');
3044

3145
grunt.registerTask('default', ['watch']);
3246

dist/angular-github-api-factory.js

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/**
2+
@name: angular-github-api-factory
3+
@version: 0.5.0 (06-01-2016)
4+
@author: Jonathan Hornung
5+
@url: https://github.com/JohnnyTheTank/angular-github-api-factory#readme
6+
@license: MIT
7+
*/
8+
"use strict";
9+
10+
angular.module("jtt_github", [])
11+
.factory('githubFactory', ['$http', 'githubSearchDataService', function ($http, githubSearchDataService) {
12+
13+
var githubFactory = {};
14+
15+
githubFactory.getUser = function (_params) {
16+
var searchData = githubSearchDataService.getNew("user", _params);
17+
return $http({
18+
method: 'GET',
19+
url: searchData.url,
20+
params: searchData.object,
21+
});
22+
};
23+
24+
githubFactory.getReposByUser = function (_params) {
25+
var searchData = githubSearchDataService.getNew("reposByUser", _params);
26+
return $http({
27+
method: 'GET',
28+
url: searchData.url,
29+
params: searchData.object,
30+
});
31+
};
32+
33+
githubFactory.getReposByName = function (_params) {
34+
var searchData = githubSearchDataService.getNew("reposByName", _params);
35+
return $http({
36+
method: 'GET',
37+
url: searchData.url,
38+
params: searchData.object,
39+
});
40+
};
41+
42+
githubFactory.getRepoByUserAndName = function (_params) {
43+
var searchData = githubSearchDataService.getNew("repoByUserAndName", _params);
44+
return $http({
45+
method: 'GET',
46+
url: searchData.url,
47+
params: searchData.object,
48+
});
49+
};
50+
51+
githubFactory.getEventsByUser = function (_params) {
52+
var searchData = githubSearchDataService.getNew("eventsByUser", _params);
53+
return $http({
54+
method: 'GET',
55+
url: searchData.url,
56+
params: searchData.object,
57+
});
58+
};
59+
60+
githubFactory.getEventsFromRepoByUserAndName = function (_params) {
61+
var searchData = githubSearchDataService.getNew("eventsFromRepoByUserAndName", _params);
62+
return $http({
63+
method: 'GET',
64+
url: searchData.url,
65+
params: searchData.object,
66+
});
67+
};
68+
69+
return githubFactory;
70+
}])
71+
.service('githubSearchDataService', function () {
72+
this.getApiBaseUrl = function (_params) {
73+
return "https://api.github.com/";
74+
};
75+
76+
this.fillDataInObjectByList = function (_object, _params, _list) {
77+
78+
angular.forEach(_list, function (value, key) {
79+
if (typeof _params[value] !== "undefined") {
80+
_object.object[value] = _params[value];
81+
}
82+
});
83+
84+
return _object;
85+
};
86+
87+
this.getNew = function (_type, _params) {
88+
var githubSearchData = {
89+
object: {
90+
access_token: _params.access_token,
91+
},
92+
url: "",
93+
};
94+
95+
if (typeof _params.per_page !== "undefined") {
96+
githubSearchData.object.per_page = _params.per_page;
97+
}
98+
99+
switch (_type) {
100+
case "user":
101+
githubSearchData.object.per_page = undefined;
102+
githubSearchData = this.fillDataInObjectByList(githubSearchData, _params, []);
103+
githubSearchData.url = this.getApiBaseUrl() + "users/" + _params.user;
104+
break;
105+
106+
case "reposByUser":
107+
githubSearchData = this.fillDataInObjectByList(githubSearchData, _params, [
108+
'q', 'sort', 'order', 'page'
109+
]);
110+
githubSearchData.url = this.getApiBaseUrl() + "users/" + _params.user + "/repos";
111+
break;
112+
113+
case "reposByName":
114+
githubSearchData = this.fillDataInObjectByList(githubSearchData, _params, [
115+
'sort', 'order', 'page'
116+
]);
117+
githubSearchData.url = this.getApiBaseUrl() + "search/repositories?q=" + _params.q;
118+
break;
119+
120+
case "repoByUserAndName":
121+
githubSearchData.object = {
122+
access_token: _params.access_token,
123+
};
124+
125+
githubSearchData = this.fillDataInObjectByList(githubSearchData, _params, []);
126+
127+
githubSearchData.url = this.getApiBaseUrl() + "repos/" + _params.user + "/" + _params.repo;
128+
break;
129+
130+
case "eventsByUser":
131+
githubSearchData = this.fillDataInObjectByList(githubSearchData, _params, [
132+
'q', 'sort', 'order', 'page'
133+
]);
134+
githubSearchData.url = this.getApiBaseUrl() + "users/" + _params.user + "/events";
135+
break;
136+
137+
case "eventsFromRepoByUserAndName":
138+
githubSearchData = this.fillDataInObjectByList(githubSearchData, _params, [
139+
'q', 'sort', 'order', 'page'
140+
]);
141+
githubSearchData.url = this.getApiBaseUrl() + "repos/" + _params.user + "/" + _params.repo + "/events";
142+
break;
143+
}
144+
145+
return githubSearchData;
146+
};
147+
});

dist/angular-github-api-factory.min.js

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-github-api-factory",
3-
"version": "0.5.2",
3+
"version": "0.5.0",
44
"description": "angularjs factory for github json rest api requests",
55
"main": "dist/angular-github-api-factory.js",
66
"scripts": {
@@ -28,6 +28,7 @@
2828
},
2929
"devDependencies": {
3030
"grunt": "^0.4.5",
31+
"grunt-contrib-concat": "^0.5.1",
3132
"grunt-contrib-uglify": "^0.11.0",
3233
"grunt-contrib-watch": "^0.6.1"
3334
}

src/angular-github-api-factory.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
"use strict";
22

3-
/**
4-
@author Jonathan Hornung (https://github.com/JohnnyTheTank)
5-
@url https://github.com/JohnnyTheTank/angular-github-api-factory
6-
@licence MIT
7-
*/
8-
93
angular.module("jtt_github", [])
104
.factory('githubFactory', ['$http', 'githubSearchDataService', function ($http, githubSearchDataService) {
115

0 commit comments

Comments
 (0)