[ruby/prism] Add the ability to convert nodes to dot

https://github.com/ruby/prism/commit/3e4b4fb947
This commit is contained in:
Kevin Newton 2023-11-03 13:36:28 -04:00
parent db8803d583
commit bc84334af7
No known key found for this signature in database
GPG Key ID: 0EAD74C79EC73F26

21
bin/dot Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
$:.unshift(File.expand_path("../lib", __dir__))
require "prism"
result =
if ARGV[0] == "-e"
Prism.parse(ARGV[1])
else
Prism.parse_file(ARGV[0] || "test.rb")
end
File.write(
"out.svg",
IO.popen("dot -Tsvg", "w+") do |file|
file.write(result.value.to_dot)
file.close_write
file.read
end
)