summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorKazuhiro NISHIYAMA <zn@mbf.nifty.com>2019-10-07 19:05:42 +0900
committerKazuhiro NISHIYAMA <zn@mbf.nifty.com>2019-10-07 19:05:42 +0900
commit96753e8475ee69537134ab3d966c3d25cb5c467c (patch)
treea31568c9af65e7fa6364643e7543e6d99729592d /tool
parentbb86611c9b61b47ba7ff65c3b0a0737a20183460 (diff)
Create info.yml and info.json
- `info.yml` is for ruby/www.ruby-lang.org/_data/releases.yml - `info.json` is meta data for users of snapshot
Diffstat (limited to 'tool')
-rwxr-xr-xtool/make-snapshot27
1 files changed, 26 insertions, 1 deletions
diff --git a/tool/make-snapshot b/tool/make-snapshot
index 68a9f51446..ecc3cd53d2 100755
--- a/tool/make-snapshot
+++ b/tool/make-snapshot
@@ -7,6 +7,8 @@ require 'fileutils'
require 'shellwords'
require 'tmpdir'
require 'pathname'
+require 'yaml'
+require 'json'
require File.expand_path("../lib/vcs", __FILE__)
require File.expand_path("../lib/colorize", __FILE__)
STDOUT.sync = true
@@ -592,6 +594,9 @@ else
end
end
+release_date = Time.now.getutc
+info = {}
+
success = true
revisions.collect {|rev| package(vcs, rev, destdir, tmp)}.flatten.each do |name|
if !name
@@ -599,13 +604,33 @@ revisions.collect {|rev| package(vcs, rev, destdir, tmp)}.flatten.each do |name|
next
end
str = open(name, "rb") {|f| f.read}
+ pathname = Pathname(name)
+ basename = pathname.basename.to_s
+ extname = pathname.extname.sub(/\A\./, '')
+ version = basename[/\Aruby-(.*)\.(?:tar|zip)/, 1]
+ key = basename[/\A(.*)\.(?:tar|zip)/, 1]
+ info[key] ||= Hash.new{|h,k|h[k]={}}
+ info[key]['version'] = version if version
+ info[key]['date'] = release_date.strftime('%Y-%m-%d')
+ if version
+ info[key]['post'] = "/en/news/#{release_date.strftime('%Y/%m/%d')}/ruby-#{version.tr('.', '-')}-released/"
+ info[key]['url'][extname] = "https://cache.ruby-lang.org/pub/ruby/#{version[/\A\d+\.\d+/]}/#{basename}"
+ else
+ info[key]['filename'][extname] = basename
+ end
+ info[key]['size'][extname] = str.bytesize
puts "* #{$colorize.pass(name)}"
puts " SIZE: #{str.bytesize} bytes"
$digests.each do |alg|
- printf " %-8s%s\n", "#{alg}:", Digest.const_get(alg).hexdigest(str)
+ digest = Digest(alg).hexdigest(str)
+ info[key][alg.downcase][extname] = digest
+ printf " %-8s%s\n", "#{alg}:", digest
end
end
+File.write('info.yml', info.values.to_yaml)
+File.write('info.json', info.values.to_json)
+
exit false if !success
# vim:fileencoding=US-ASCII sw=2 ts=4 noexpandtab ff=unix