Skip to content

Improve magazine tool #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ _site
*.un~
Gemfile.lock
/.jekyll-metadata
/tmp/
26,612 changes: 26,611 additions & 1 deletion scripts/vimmagazinestate.json

Large diffs are not rendered by default.

36 changes: 27 additions & 9 deletions scripts/vimmagazinetools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
require 'date'


VIMPATCH_URL = "http://ftp.vim.org/pub/vim/patches/7.4/%s"
VIMPATCH_README_URL = "http://ftp.vim.org/pub/vim/patches/7.4/README"
VIMPATCH_README_URL = "http://ftp.vim.org/pub/vim/patches/%s/README"
VIMSCRIPT_URL = "http://www.vim.org/scripts/script.php?script_id=%s"
VIMSCRIPT_LIST_URL = "http://www.vim.org/scripts/script_search_results.php?&show_me=99999"
VIM_GITHUB_COMMIT_URL = "https://github.com/vim/vim/commit/%s"
Expand Down Expand Up @@ -85,9 +84,19 @@ def mdescape(s)


def vimpatch_all()
[].tap do |patches|
# XXX: stop to fetch patches of 7.4 after 2016/09 was released
patches.concat vimpatch('7.4')
patches.concat vimpatch('8.0')
end
end

# vimpatch fetches info of patches for Vim x.x (ver)
def vimpatch(ver)
items = []
tag2sha = github_git_tags("vim", "vim")
readme = httpget(VIMPATCH_README_URL).entity.force_encoding("UTF-8")
url = sprintf(VIMPATCH_README_URL, ver)
readme = httpget(url).entity.force_encoding("UTF-8")
for line in readme.split(/\r\n|\r|\n/)
m = line.match(/^\s*(?#size)(\d+) (?#version)(\d\.\d\.\d{3,4}) (?#summary)(.*)$/)
if !m
Expand All @@ -97,7 +106,6 @@ def vimpatch_all()
e["size"] = m[1].to_i
e["version"] = m[2]
e["summary"] = m[3]
# e["url"] = sprintf(VIMPATCH_URL, e["version"])
major, minor, patchlevel = e["version"].split(".")
tag = "v#{major}.#{minor}.#{patchlevel}"
e["tag"] = tag
Expand Down Expand Up @@ -269,7 +277,7 @@ def cmd_githubissuelist(args)


def cmd_scriptjson(_args)
puts JSON.dump(vimscript_all())
puts JSON.pretty_generate(filter_vimscripts(vimscript_all()))
end


Expand Down Expand Up @@ -351,7 +359,7 @@ def cmd_generate(args)
},
"script" => {
"script_id" => vimscripts[-1]["script_id"],
"state" => vimscripts,
"state" => filter_vimscripts(vimscripts),
},
"vim-jp/issues" => {
"opencount" => opencount,
Expand All @@ -361,13 +369,23 @@ def cmd_generate(args)
}

if args["update"]
open(args["statefile"], "w") {|f|
JSON.dump(newstate, f)
}
open(args["statefile"], "w") do |f|
f.write JSON.pretty_generate(newstate)
end
end
end


def filter_vimscripts(scripts)
scripts.map do |item|
{
'script_id': item['script_id'],
'rating': item['rating'],
'downloads': item['downloads'],
}
end
end

def main()
cmd = ARGV.shift()
args = {}
Expand Down