From a89932799c914d1864fc91f33d6461592dbfd3fb Mon Sep 17 00:00:00 2001 From: "NARUSE, Yui" Date: Thu, 24 Dec 2020 17:19:16 +0900 Subject: [PATCH] gen-release-note.rb: Avoid to depend release metadata Because it doesn't have metadata when I edit draft. --- tool/releng/gen-release-note.rb | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tool/releng/gen-release-note.rb b/tool/releng/gen-release-note.rb index e3dbe13945..559ddeba1b 100755 --- a/tool/releng/gen-release-note.rb +++ b/tool/releng/gen-release-note.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby -require "open-uri" -require "yaml" +require 'open-uri' +require 'time' +require 'yaml' # Confirm current directory is www.ruby-lang.org's working directory def confirm_w_r_l_o_wd @@ -11,8 +12,6 @@ def confirm_w_r_l_o_wd end confirm_w_r_l_o_wd -releases = YAML.load_file('_data/releases.yml') - %w[ https://hackmd.io/@naruse/ruby-relnote-en/download https://hackmd.io/@naruse/ruby-relnote-ja/download @@ -28,18 +27,10 @@ releases = YAML.load_file('_data/releases.yml') end puts "#{url} -> #{version}" - release = releases.find{|rel|rel['version'] == version} - unless release - abort "#{version} is not found in '_data/releases.yml'" - end # Write release note article - lang = url[/ja|en/] - if %r<\A/en/news/(\d+/\d+/\d+/ruby-[\w\-]+-released)> =~ release['post'] - path = "#{lang}/news/_posts/#{$1.tr('/', '-')}.md" - else - abort "unexpected path pattern '#{release['post']}'" - end + path = Time.parse(src[/^date: (.*)/, 1]). + strftime("./#{src[/^lang: (\w+)/, 1]}/news/_posts/%Y-%m-%d-ruby-#{version}-released.md") puts path File.write(path, src) end