[前][次][番号順一覧][スレッド一覧]

ruby-changes:58149

From: Kazuhiro <ko1@a...>
Date: Mon, 7 Oct 2019 19:07:47 +0900 (JST)
Subject: [ruby-changes:58149] 96753e8475 (master): Create info.yml and info.json

https://git.ruby-lang.org/ruby.git/commit/?id=96753e8475

From 96753e8475ee69537134ab3d966c3d25cb5c467c Mon Sep 17 00:00:00 2001
From: Kazuhiro NISHIYAMA <zn@m...>
Date: Mon, 7 Oct 2019 19:05:42 +0900
Subject: 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

diff --git a/tool/make-snapshot b/tool/make-snapshot
index 68a9f51..ecc3cd5 100755
--- a/tool/make-snapshot
+++ b/tool/make-snapshot
@@ -7,6 +7,8 @@ require 'fileutils' https://github.com/ruby/ruby/blob/trunk/tool/make-snapshot#L7
 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 https://github.com/ruby/ruby/blob/trunk/tool/make-snapshot#L594
   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| https://github.com/ruby/ruby/blob/trunk/tool/make-snapshot#L604
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]