@@ -20,48 +20,46 @@ import GithubRateInfo = require('../model/GithubRateInfo');
2020class GithubLoader {
2121
2222 urls : GithubURLs ;
23-
24- cache : HTTPCache ;
2523 options : JSONPointer ;
26- shared : JSONPointer ;
27-
28- storeDir : string ;
29-
30- label : string = 'github-loader' ;
31- formatVersion : string = '0.0.0' ;
24+ cache : HTTPCache ;
25+ headers : { [ index : string ] : string } = { } ;
3226
33- headers = { } ;
27+ constructor (
28+ urls : GithubURLs ,
29+ options : JSONPointer ,
30+ shared : JSONPointer ,
31+ storeDir : string ,
32+ cacheKey : string ,
33+ label : string ,
34+ formatVersion : string ) {
3435
35- constructor ( urls : GithubURLs , options : JSONPointer , shared : JSONPointer , storeDir : string , label : string ) {
3636 assertVar ( urls , GithubURLs , 'urls' ) ;
3737 assertVar ( options , JSONPointer , 'options' ) ;
3838 assertVar ( shared , JSONPointer , 'shared' ) ;
3939 assertVar ( storeDir , 'string' , 'storeDir' ) ;
40+ assertVar ( cacheKey , 'string' , 'cacheKey' ) ;
41+ assertVar ( label , 'string' , 'label' ) ;
42+ assertVar ( formatVersion , 'string' , 'formatVersion' ) ;
4043
4144 this . urls = urls ;
4245 this . options = options ;
43- this . shared = shared ;
44- this . storeDir = storeDir ;
45- this . label = label ;
46- }
4746
48- _initGithubLoader ( cacheKey : string , formatVersion : string ) : void {
4947 var cache = new CacheOpts ( ) ;
5048 cache . allowClean = this . options . getBoolean ( 'allowClean' , cache . allowClean ) ;
5149 cache . cleanInterval = this . options . getDurationSecs ( 'cacheCleanInterval' , cache . cleanInterval / 1000 ) * 1000 ;
5250 cache . splitDirLevel = this . options . getNumber ( 'splitDirLevel' , cache . splitDirLevel ) ;
5351 cache . splitDirChunk = this . options . getNumber ( 'splitDirChunk' , cache . splitDirChunk ) ;
5452 cache . jobTimeout = this . options . getDurationSecs ( 'jobTimeout' , cache . jobTimeout / 1000 ) * 1000 ;
55- cache . storeDir = path . join ( this . storeDir , cacheKey ) ;
53+ cache . storeDir = path . join ( storeDir , cacheKey ) ;
5654
5755 var opts : HTTPOpts = {
5856 cache : cache ,
59- concurrent : this . shared . getNumber ( 'concurrent' , 20 ) ,
60- oath : this . shared . getString ( 'oath' , null ) ,
61- strictSSL : this . shared . getBoolean ( 'strictSSL' , true )
57+ concurrent : shared . getNumber ( 'concurrent' , 20 ) ,
58+ oath : shared . getString ( 'oath' , null ) ,
59+ strictSSL : shared . getBoolean ( 'strictSSL' , true )
6260 } ;
6361
64- opts . proxy = ( this . shared . getString ( 'proxy' )
62+ opts . proxy = ( shared . getString ( 'proxy' )
6563 || process . env . HTTPS_PROXY
6664 || process . env . https_proxy
6765 || process . env . HTTP_PROXY
@@ -70,7 +68,7 @@ class GithubLoader {
7068
7169 this . cache = new HTTPCache ( opts ) ;
7270 // required to have some header
73- this . headers [ 'user-agent' ] = this . label + '-v' + formatVersion ;
71+ this . headers [ 'user-agent' ] = label + '-v' + formatVersion ;
7472 }
7573
7674 copyHeadersTo ( target : any , source ?: any ) {
@@ -81,7 +79,6 @@ class GithubLoader {
8179 }
8280
8381 set verbose ( verbose : boolean ) {
84-
8582 }
8683}
8784
0 commit comments