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

Deprecate safe_level of ERB.new in Ruby 2.6 #297

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/rails_erd/diagram/graphviz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ def specialization_options(specialization)
end

def read_template(type)
ERB.new(File.read(File.expand_path("templates/#{NODE_LABEL_TEMPLATES[type]}", File.dirname(__FILE__))), nil, "<>")
template_text = File.read(File.expand_path("templates/#{NODE_LABEL_TEMPLATES[type]}", File.dirname(__FILE__)))
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be easier and clearer to just use the RUBY_VERSION constant instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR uses ERB.instance_method(:initialize).parameters.assoc(:key) instead of RUBY_VERSION of ERB.new. This approach is built into Ruby.
ruby/ruby@3406c5d

ERB.new(template_text, trim_mode: "<>")
else
ERB.new(template_text, nil, "<>")
end
end
end
end
Expand Down