Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DotHelper that generates Agents Diagram #3240

Merged
merged 2 commits into from Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions app/helpers/dot_helper.rb
Expand Up @@ -27,22 +27,20 @@ def render_agents_diagram(agents, layout: nil)
private def dot_to_svg(dot)
command = ENV['USE_GRAPHVIZ_DOT'] or return nil

IO.popen(*%W[#{command} -Tsvg -q1 -o/dev/stdout /dev/stdin], 'w+') do |dot|
dot.print dot
dot.close_write
dot.read
IO.popen(%W[#{command} -Tsvg -q1 -o/dev/stdout /dev/stdin], 'w+') do |rw|
rw.print dot
rw.close_write
rw.read
rescue StandardError
end
end

class DotDrawer
def initialize(vars = {})
@dot = ''
@vars = vars.symbolize_keys
end

def method_missing(var, *args)
@vars.fetch(var) { super }
vars.each do |key, value|
define_singleton_method(key) { value }
end
end

def to_s
Expand Down