Skip to content

Commit f0f29c9

Browse files
authored
Merge pull request #224 from vim-jp/improve-magazine-tool
Improve magazine tool
2 parents a381b43 + 040a011 commit f0f29c9

File tree

3 files changed

+26639
-10
lines changed

3 files changed

+26639
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ _site
33
*.un~
44
Gemfile.lock
55
/.jekyll-metadata
6+
/tmp/

scripts/vimmagazinestate.json

Lines changed: 26611 additions & 1 deletion
Large diffs are not rendered by default.

scripts/vimmagazinetools.rb

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
require 'date'
1010

1111

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"
1413
VIMSCRIPT_URL = "http://www.vim.org/scripts/script.php?script_id=%s"
1514
VIMSCRIPT_LIST_URL = "http://www.vim.org/scripts/script_search_results.php?&show_me=99999"
1615
VIM_GITHUB_COMMIT_URL = "https://github.com/vim/vim/commit/%s"
@@ -85,9 +84,19 @@ def mdescape(s)
8584

8685

8786
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)
8896
items = []
8997
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")
91100
for line in readme.split(/\r\n|\r|\n/)
92101
m = line.match(/^\s*(?#size)(\d+) (?#version)(\d\.\d\.\d{3,4}) (?#summary)(.*)$/)
93102
if !m
@@ -97,7 +106,6 @@ def vimpatch_all()
97106
e["size"] = m[1].to_i
98107
e["version"] = m[2]
99108
e["summary"] = m[3]
100-
# e["url"] = sprintf(VIMPATCH_URL, e["version"])
101109
major, minor, patchlevel = e["version"].split(".")
102110
tag = "v#{major}.#{minor}.#{patchlevel}"
103111
e["tag"] = tag
@@ -269,7 +277,7 @@ def cmd_githubissuelist(args)
269277

270278

271279
def cmd_scriptjson(_args)
272-
puts JSON.dump(vimscript_all())
280+
puts JSON.pretty_generate(filter_vimscripts(vimscript_all()))
273281
end
274282

275283

@@ -351,7 +359,7 @@ def cmd_generate(args)
351359
},
352360
"script" => {
353361
"script_id" => vimscripts[-1]["script_id"],
354-
"state" => vimscripts,
362+
"state" => filter_vimscripts(vimscripts),
355363
},
356364
"vim-jp/issues" => {
357365
"opencount" => opencount,
@@ -361,13 +369,23 @@ def cmd_generate(args)
361369
}
362370

363371
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
367375
end
368376
end
369377

370378

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+
371389
def main()
372390
cmd = ARGV.shift()
373391
args = {}

0 commit comments

Comments
 (0)