gen-release-note.rb: Avoid to depend release metadata

Because it doesn't have metadata when I edit draft.
This commit is contained in:
NARUSE, Yui 2020-12-24 17:19:16 +09:00
Родитель 6a6daf3803
Коммит a89932799c
1 изменённых файлов: 5 добавлений и 14 удалений

Просмотреть файл

@ -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