-
Notifications
You must be signed in to change notification settings - Fork 35
/
gulpfile.js
46 lines (41 loc) · 1.28 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
var gulp = require( 'gulp' );
var download = require( 'gulp-download' );
var decompress = require( 'gulp-decompress' );
var convertEncoding = require( 'gulp-convert-encoding' );
var chmod = require( 'gulp-chmod' );
var postal2json = require( './lib/postal2json.js' );
var jigyosyo2json = require( './lib/jigyosyo2json.js' );
var v1 = require( './lib/v1.js' );
gulp.task( 'download', function () {
var urls = [
'http://www.post.japanpost.jp/zipcode/dl/roman/ken_all_rome.zip',
'http://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jigyosyo.zip'
];
return download( urls )
.pipe( decompress() )
.pipe( convertEncoding( { from: "shift_jis", to: "utf-8" } ) )
.pipe( chmod( 644 ) )
.pipe( gulp.dest( 'api' ) );
} );
/**
* Create an API of the postal code.
*/
gulp.task( 'v1', [ 'download' ], function () {
gulp.src( 'api/KEN_ALL_ROME.CSV' )
.pipe( postal2json() )
.pipe( v1() )
.pipe( chmod( 644 ) )
.pipe( gulp.dest( 'api/v1' ) );
} );
/**
* Create an API of the Jigyosyo postal code.
*/
gulp.task( 'v1-jigyosyo', ['download'], function () {
gulp.src( 'api/JIGYOSYO.CSV' )
.pipe( jigyosyo2json() )
.pipe( v1() )
.pipe( chmod( 644 ) )
.pipe( gulp.dest( 'api/v1' ) );
} );
gulp.task( 'default', [ 'v1', 'v1-jigyosyo' ] );