9
9
require 'date'
10
10
11
11
12
- VIMPATCH_URL = "http://ftp.vim.org/pub/vim/patches/7.4/%s"
13
- VIMPATCH_README_URL = "http://ftp.vim.org/pub/vim/patches/7.4/README"
12
+ VIMPATCH_README_URL = "http://ftp.vim.org/pub/vim/patches/%s/README"
14
13
VIMSCRIPT_URL = "http://www.vim.org/scripts/script.php?script_id=%s"
15
14
VIMSCRIPT_LIST_URL = "http://www.vim.org/scripts/script_search_results.php?&show_me=99999"
16
15
VIM_GITHUB_COMMIT_URL = "https://github.com/vim/vim/commit/%s"
@@ -85,9 +84,19 @@ def mdescape(s)
85
84
86
85
87
86
def vimpatch_all ( )
87
+ [ ] . tap do |patches |
88
+ # XXX: stop to fetch patches of 7.4 after 2016/09 was released
89
+ patches . concat vimpatch ( '7.4' )
90
+ patches . concat vimpatch ( '8.0' )
91
+ end
92
+ end
93
+
94
+ # vimpatch fetches info of patches for Vim x.x (ver)
95
+ def vimpatch ( ver )
88
96
items = [ ]
89
97
tag2sha = github_git_tags ( "vim" , "vim" )
90
- readme = httpget ( VIMPATCH_README_URL ) . entity . force_encoding ( "UTF-8" )
98
+ url = sprintf ( VIMPATCH_README_URL , ver )
99
+ readme = httpget ( url ) . entity . force_encoding ( "UTF-8" )
91
100
for line in readme . split ( /\r \n |\r |\n / )
92
101
m = line . match ( /^\s *(?#size)(\d +) (?#version)(\d \. \d \. \d {3,4}) (?#summary)(.*)$/ )
93
102
if !m
@@ -97,7 +106,6 @@ def vimpatch_all()
97
106
e [ "size" ] = m [ 1 ] . to_i
98
107
e [ "version" ] = m [ 2 ]
99
108
e [ "summary" ] = m [ 3 ]
100
- # e["url"] = sprintf(VIMPATCH_URL, e["version"])
101
109
major , minor , patchlevel = e [ "version" ] . split ( "." )
102
110
tag = "v#{ major } .#{ minor } .#{ patchlevel } "
103
111
e [ "tag" ] = tag
@@ -269,7 +277,7 @@ def cmd_githubissuelist(args)
269
277
270
278
271
279
def cmd_scriptjson ( _args )
272
- puts JSON . dump ( vimscript_all ( ) )
280
+ puts JSON . pretty_generate ( filter_vimscripts ( vimscript_all ( ) ) )
273
281
end
274
282
275
283
@@ -351,7 +359,7 @@ def cmd_generate(args)
351
359
} ,
352
360
"script" => {
353
361
"script_id" => vimscripts [ -1 ] [ "script_id" ] ,
354
- "state" => vimscripts ,
362
+ "state" => filter_vimscripts ( vimscripts ) ,
355
363
} ,
356
364
"vim-jp/issues" => {
357
365
"opencount" => opencount ,
@@ -361,13 +369,23 @@ def cmd_generate(args)
361
369
}
362
370
363
371
if args [ "update" ]
364
- open ( args [ "statefile" ] , "w" ) { |f |
365
- JSON . dump ( newstate , f )
366
- }
372
+ open ( args [ "statefile" ] , "w" ) do |f |
373
+ f . write JSON . pretty_generate ( newstate )
374
+ end
367
375
end
368
376
end
369
377
370
378
379
+ def filter_vimscripts ( scripts )
380
+ scripts . map do |item |
381
+ {
382
+ 'script_id' : item [ 'script_id' ] ,
383
+ 'rating' : item [ 'rating' ] ,
384
+ 'downloads' : item [ 'downloads' ] ,
385
+ }
386
+ end
387
+ end
388
+
371
389
def main ( )
372
390
cmd = ARGV . shift ( )
373
391
args = { }
0 commit comments