Skip to content

Commit 7e4f850

Browse files
committed
chore: create non-minified dist file (#1)
1 parent 91b1c66 commit 7e4f850

File tree

6 files changed

+156
-16
lines changed

6 files changed

+156
-16
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-openweathermap-api-factory.min.js' : ['src/angular-openweathermap-api-factory.js']
10+
'dist/angular-openweathermap-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-openweathermap-api-factory.js' : ['src/*.js']
25+
}
26+
},
27+
},
1528
watch: {
1629
minifiyJs: {
1730
files: [
18-
'src/angular-openweathermap-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

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "angular-openweathermap-api-factory",
33
"description": "angularjs factory for openweathermap json rest api requests",
4-
"version": "0.1.0",
5-
"main": "Gruntfile.js",
4+
"version": "0.5.0",
5+
"main": "dist/angular-openweathermap-api-factory.js",
66
"authors": [
77
"Jonathan Hornung"
88
],
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
@name: angular-openweathermap-api-factory
3+
@version: 0.5.0 (06-01-2016)
4+
@author: Jonathan Hornung
5+
@url: https://github.com/JohnnyTheTank/angular-openweathermap-api-factory#readme
6+
@license: MIT
7+
*/
8+
"use strict";
9+
10+
angular.module("jtt_openweathermap", [])
11+
.factory('openweathermapFactory', ['$http', 'openweathermapSearchDataService', function ($http, openweathermapSearchDataService) {
12+
13+
var openweathermapFactory = {};
14+
15+
openweathermapFactory.getWeatherFromCitySearchByName = function (_params) {
16+
var searchData = openweathermapSearchDataService.getNew("citySearchByName", _params);
17+
return $http({
18+
method: 'GET',
19+
url: searchData.url,
20+
params: searchData.object,
21+
});
22+
};
23+
24+
openweathermapFactory.getWeatherFromCityById = function (_params) {
25+
var searchData = openweathermapSearchDataService.getNew("cityById", _params);
26+
return $http({
27+
method: 'GET',
28+
url: searchData.url,
29+
params: searchData.object,
30+
});
31+
};
32+
33+
openweathermapFactory.getWeatherFromGroupOfCitiesById = function (_params) {
34+
var searchData = openweathermapSearchDataService.getNew("citiesById", _params);
35+
return $http({
36+
method: 'GET',
37+
url: searchData.url,
38+
params: searchData.object,
39+
});
40+
};
41+
42+
openweathermapFactory.getWeatherFromLocationByCoordinates = function (_params) {
43+
var searchData = openweathermapSearchDataService.getNew("locationByCoordinates", _params);
44+
return $http({
45+
method: 'GET',
46+
url: searchData.url,
47+
params: searchData.object,
48+
});
49+
};
50+
51+
openweathermapFactory.getWeatherFromLocationByZipcode = function (_params) {
52+
var searchData = openweathermapSearchDataService.getNew("locationByZipcode", _params);
53+
return $http({
54+
method: 'GET',
55+
url: searchData.url,
56+
params: searchData.object,
57+
});
58+
};
59+
60+
return openweathermapFactory;
61+
}])
62+
.service('openweathermapSearchDataService', function () {
63+
this.getApiBaseUrl = function (_params) {
64+
return "http://api.openweathermap.org/data/2.5/";
65+
};
66+
67+
this.fillDataInObjectByList = function (_object, _params, _list) {
68+
angular.forEach(_list, function (value, key) {
69+
if (typeof _params[value] !== "undefined") {
70+
_object.object[value] = _params[value];
71+
}
72+
});
73+
return _object;
74+
};
75+
76+
this.getNew = function (_type, _params) {
77+
78+
var openweathermapSearchData = {
79+
object: {
80+
appid: _params.appid,
81+
},
82+
url: "",
83+
};
84+
85+
switch (_type) {
86+
case "citySearchByName":
87+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
88+
'q', 'lang', 'type', "units",
89+
]);
90+
openweathermapSearchData.url = this.getApiBaseUrl() + "weather";
91+
break;
92+
93+
case "cityById":
94+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
95+
'id', 'lang', "units",
96+
]);
97+
openweathermapSearchData.url = this.getApiBaseUrl() + "weather";
98+
break;
99+
100+
case "citiesById":
101+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
102+
'id', 'lang', "units",
103+
]);
104+
openweathermapSearchData.url = this.getApiBaseUrl() + "group";
105+
break;
106+
107+
case "locationByCoordinates":
108+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
109+
'lat', 'lon', 'lang', "units",
110+
]);
111+
openweathermapSearchData.url = this.getApiBaseUrl() + "weather";
112+
break;
113+
114+
case "locationByZipcode":
115+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
116+
'zip', 'lang', "units",
117+
]);
118+
openweathermapSearchData.url = this.getApiBaseUrl() + "weather";
119+
break;
120+
}
121+
return openweathermapSearchData;
122+
};
123+
});

dist/angular-openweathermap-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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "angular-openweathermap-api-factory",
3-
"version": "0.1.0",
3+
"version": "0.5.0",
44
"description": "angularjs factory for openweathermap json rest api requests",
5-
"main": "Gruntfile.js",
5+
"main": "dist/angular-openweathermap-api-factory.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
@@ -25,7 +25,11 @@
2525
"homepage": "https://github.com/JohnnyTheTank/angular-openweathermap-api-factory#readme",
2626
"devDependencies": {
2727
"grunt": "^0.4.5",
28+
"grunt-contrib-concat": "^0.5.1",
2829
"grunt-contrib-uglify": "^0.11.0",
2930
"grunt-contrib-watch": "^0.6.1"
31+
},
32+
"dependencies": {
33+
"angular": "*"
3034
}
3135
}

src/angular-openweathermap-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://openweathermap.com/JohnnyTheTank)
5-
@url https://openweathermap.com/JohnnyTheTank/angular-openweathermap-api-factory
6-
@licence MIT
7-
*/
8-
93
angular.module("jtt_openweathermap", [])
104
.factory('openweathermapFactory', ['$http', 'openweathermapSearchDataService', function ($http, openweathermapSearchDataService) {
115

0 commit comments

Comments
 (0)