Skip to content

Commit 919a91c

Browse files
committed
final documentation
1 parent a7b640f commit 919a91c

File tree

7 files changed

+92
-70
lines changed

7 files changed

+92
-70
lines changed

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,25 @@ A darksky API consumer UI
44

55
# Installation
66

7-
npm start
7+
npm install
8+
9+
Use 'gulp connect' to start the application then go to http://localhost:8000/index.html#!/main
10+
11+
Use 'gulp default' to start the development environment go to http://localhost:8000/index.html#!/main
12+
13+
For the build use 'gulp build' then go to http://localhost:9000/index.html#!/main
14+
15+
# Documentation
16+
17+
gulp ngdocs
18+
19+
gulp connect
20+
21+
go to http://localhost:8000/docs
822

923
# Tests
1024

11-
karma start
25+
Are run automatically when invoking 'gulp default' (for TDD) or run only once when invoking 'gulp build'
1226

1327
# License
1428

app/components/location/locationDirective.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* @ngdoc directive
33
* @name location
4-
* @plm
54
*
65
* @description
76
* A directive for rendering an icon with label underneath and a tooltip

app/main/locationsService.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
'use strict';
1010

1111
angular.module('darkskyForecast.main')
12-
.service('locationsService', function ($q, $http) {
12+
.service('locationsService', ['$q', '$http', function ($q, $http) {
1313

1414
/**
15-
* @ngdoc function
15+
* @ngdoc method
16+
* @methodOf locationsService
1617
* @name getLocations
1718
*
1819
* @returns {Array} list of locations
@@ -31,4 +32,4 @@ angular.module('darkskyForecast.main')
3132

3233
return deferred.promise;
3334
}
34-
});
35+
}]);

app/main/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ angular.module('darkskyForecast.main', ['ngRoute'])
2626
})
2727

2828
/**
29-
* @ngdoc function
29+
* @ngdoc method
30+
* @methodOf MainCtrl
3031
* @name displayWeather
3132
* @description A function that fetches the coordinates and the current weather for a
3233
* selected location and stores them in the local storage

app/services/coordinatesService.js

+38-43
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,48 @@
11
/**
2-
* @ngdoc overview
3-
* @name service.coordService
4-
*/
5-
'use strict';
6-
7-
angular.module('service.coordService', [])
8-
9-
/**
10-
* @ngdoc method
11-
* @methodOf service.coordService.coordService
2+
* @ngdoc service
123
* @name coordService
134
*
145
* @description
156
* A service used for fetching the coordinates of a location via http.
167
*/
17-
.service('coordService', function ($q, $http, GOOGLE_API) {
8+
'use strict';
9+
10+
angular.module('service.coordService', [])
11+
.service('coordService', ['$q', '$http', 'GOOGLE_API', function ($q, $http, GOOGLE_API) {
1812

19-
/**
20-
* @ngdoc function
21-
* @name getCoords
22-
*
23-
* @param {String} location the location name
24-
* @returns {Object} object containing the latitude and longitude
25-
*
26-
*/
27-
this.getCoords = function (location) {
28-
var deferred = $q.defer();
13+
/**
14+
* @ngdoc method
15+
* @methodOf coordService
16+
* @name getCoords
17+
*
18+
* @param {String} location the location name
19+
* @returns {Object} object containing the latitude and longitude
20+
*
21+
*/
22+
this.getCoords = function (location) {
23+
var deferred = $q.defer();
2924

30-
$http({
31-
method: 'GET',
32-
timeout: 300000,
33-
url: GOOGLE_API.URL,
34-
params: {
35-
'address': location,
36-
'key': GOOGLE_API.KEY
37-
}
38-
})
39-
.then(function (data) {
40-
if (parseInt(data.status) === 200) {
41-
deferred.resolve(data.data.results[0].geometry.location);
42-
} else {
43-
deferred.reject(data.status);
44-
}
25+
$http({
26+
method: 'GET',
27+
timeout: 300000,
28+
url: GOOGLE_API.URL,
29+
params: {
30+
'address': location,
31+
'key': GOOGLE_API.KEY
32+
}
33+
})
34+
.then(function (data) {
35+
if (parseInt(data.status) === 200) {
36+
deferred.resolve(data.data.results[0].geometry.location);
37+
} else {
38+
deferred.reject(data.status);
39+
}
4540

46-
})
47-
.catch(function (data) {
48-
deferred.reject(data.error_message);
49-
});
41+
})
42+
.catch(function (data) {
43+
deferred.reject(data.error_message);
44+
});
5045

51-
return deferred.promise;
52-
}
53-
});
46+
return deferred.promise;
47+
}
48+
}]);

app/services/forecastService.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @ngdoc function
2+
* @ngdoc service
33
* @name forecastService
44
*
55
* @description
@@ -8,10 +8,11 @@
88
'use strict';
99

1010
angular.module('service.forecastService', [])
11-
.service('forecastService', function ($q, $http, $sce, DARKSKY_API) {
11+
.service('forecastService', ['$q', '$http', '$sce', 'DARKSKY_API', function ($q, $http, $sce, DARKSKY_API) {
1212

1313
/**
14-
* @ngdoc function
14+
* @ngdoc method
15+
* @methodOf forecastService
1516
* @name getWeather
1617
*
1718
* @param {Object} coords an object with lat (latitude) and lng (longitude) parameters
@@ -62,4 +63,4 @@ angular.module('service.forecastService', [])
6263
//return a promise that needs to be resolved before data can be used
6364
return deferred.promise;
6465
}
65-
});
66+
}]);

gulpfile.js

+27-16
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ gulp.task('ngdocs', [], function () {
3131

3232

3333
// tasks
34-
gulp.task('lint', function () {
35-
gulp.src('./app/**/*.js')
36-
.pipe(jshint())
37-
.pipe(jshint.reporter('default'))
38-
.pipe(jshint.reporter('fail'));
39-
});
4034
gulp.task('clean', function () {
4135
gulp.src('./dist/*')
4236
.pipe(clean({
@@ -48,14 +42,20 @@ gulp.task('minify-css', function () {
4842
comments: true,
4943
spare: true
5044
};
51-
gulp.src(['./app/**/*.css', './app.css'])
45+
gulp.src('./app.css')
5246
.pipe(minifyCSS(opts))
53-
.pipe(gulp.dest('./dist/'))
47+
.pipe(gulp.dest('./dist/'));
48+
gulp.src('./app/**/*.css')
49+
.pipe(minifyCSS(opts))
50+
.pipe(gulp.dest('./dist/app/'));
5451
});
5552
gulp.task('minify-js', function () {
53+
gulp.src('./app.js')
54+
.pipe(uglify())
55+
.pipe(gulp.dest('./dist/'));
5656
gulp.src('./app/**/*.js')
5757
.pipe(uglify())
58-
.pipe(gulp.dest('./dist/'))
58+
.pipe(gulp.dest('./dist/app/'));
5959
});
6060
gulp.task('copy-npm-dependencies', function () {
6161
gulp.src(gnf(), {
@@ -64,21 +64,32 @@ gulp.task('copy-npm-dependencies', function () {
6464
.pipe(gulp.dest('./dist/'));
6565
});
6666
gulp.task('copy-html-files', function () {
67-
gulp.src(['./app/**/*.html', './index.html'])
68-
.pipe(gulp.dest('dist/'));
67+
gulp.src('./index.html')
68+
.pipe(gulp.dest('./dist/'));
69+
gulp.src('./app/**/*.html')
70+
.pipe(gulp.dest('./dist/app/'));
71+
});
72+
gulp.task('copy-json-files', function () {
73+
gulp.src('./app/**/*.json')
74+
.pipe(gulp.dest('./dist/app/'));
75+
});
76+
gulp.task('copy-assets', function () {
77+
return gulp.src(['./assets/**/*'], {
78+
base: '.'
79+
}).pipe(gulp.dest('dist'));
6980
});
7081
// Run tests once and exit
7182
gulp.task('test', function (done) {
7283
new Server({
73-
configFile: './karma.conf.js',
84+
configFile: __dirname + '/karma.conf.js',
7485
singleRun: true
7586
}, done).start();
7687
});
7788

7889
// detect changes on files and rerun tests
7990
gulp.task('tdd', function (done) {
8091
new Server({
81-
configFile: './karma.conf.js'
92+
configFile: __dirname + '/karma.conf.js'
8293
}, done).start();
8394
});
8495

@@ -92,16 +103,16 @@ gulp.task('connect', function () {
92103
//run this task to see how the distribution files look before deployment
93104
gulp.task('connectDist', function () {
94105
connect.server({
95-
root: '.',
106+
root: './dist',
96107
port: 9000
97108
});
98109
});
99110

100111

101112
// default task
102-
gulp.task('default', ['lint', 'tdd', 'connect']);
113+
gulp.task('default', ['tdd', 'connect']);
103114
gulp.task('build', function () {
104115
runSequence(
105-
['clean'], ['test', 'lint', 'minify-css', 'minify-js', 'copy-html-files', 'copy-npm-dependencies', 'connectDist']
116+
['clean'], ['test'], ['minify-css', 'minify-js', 'copy-html-files', 'copy-json-files', 'copy-assets', 'copy-npm-dependencies'], ['connectDist']
106117
);
107118
});

0 commit comments

Comments
 (0)