Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A script to create an agenda for dev-meeting https://bugs.ruby-lang.org/issues/14770
#!/usr/bin/env ruby
require "open-uri"
require "json"
unless ARGV[0] =~ %r{\Ahttps://bugs.ruby-lang.org/issues/(\d+)\z}
puts "Usage: #$0 https://bugs.ruby-lang.org/issues/XXXX"
exit 1
end
URI.open("https://bugs.ruby-lang.org/issues/#$1.json?include=journals") do |f|
comments = JSON.parse(f.read, symbolize_names: true)[:issue][:journals]
comments.each do |comment|
comment[:notes].gsub("\r\n", "\n").scan(/^[*\-] (\[(?:Bug|Feature|Misc) #(\d+)\]) (.*?)( \(\w+\))?\s*\n((?: [*\-] .*(?:\n|$))+)/) do
issue, nb, title, author, summary = $~.captures
author = " (#{comment[:user][:name].split(' ').first})" unless author
puts "### [#{issue}](https://bugs.ruby-lang.org/issues/#{nb}) #{title}#{author}"
puts
puts summary.gsub(/^ /, "")
puts
puts "Discussion:"
puts
puts "* in short: "
puts
end
end
end
@ioquatix

This comment has been minimized.

Copy link

@ioquatix ioquatix commented Apr 24, 2020

@mame this ignores some markdown like this:

- [Feature ...] ...
 - Point 1

When there is only one space before the point 1, the entire feature is ignored.

@XrXr

This comment has been minimized.

Copy link

@XrXr XrXr commented May 13, 2021

@mame I tried running the script on Ruby 3 and it didn't work because calling Kernel#open to use URI.open stopped working. Had to fix it like this:

diff --git a/orig.rb b/patched.rb
index 5587203..4aea74a 100644
--- a/orig.rb
+++ b/patched.rb
@@ -8,7 +8,7 @@ unless ARGV[0] =~ %r{\Ahttps://bugs.ruby-lang.org/issues/(\d+)\z}
   exit 1
 end
 
-open("https://bugs.ruby-lang.org/issues/#$1.json?include=journals") do |f|
+URI.open("https://bugs.ruby-lang.org/issues/#$1.json?include=journals") do |f|
   comments = JSON.parse(f.read, symbolize_names: true)[:issue][:journals]
   comments.each do |comment|
     comment[:notes].gsub("\r\n", "\n").scan(/^[*\-] (\[(?:Bug|Feature|Misc) #(\d+)\]) (.*?)( \(\w+\))?\s*\n((?:  [*\-] .*(?:\n|$))+)/) do
@mame

This comment has been minimized.

Copy link
Owner Author

@mame mame commented May 14, 2021

@XrXr Yeah, I have fixed the issue only on my local machine :-) Fixed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment