-
Notifications
You must be signed in to change notification settings - Fork 369
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
Deprecate safe_level of ERB.new in Ruby 2.6 #297
Conversation
98e584d
to
d9999a0
Compare
Hi, and thanks for the PR! Apologies on not responding sooner; my workflow for being notified of new issues broke such that I received some notifications, but not all, and unfortunately yours was one I missed. If you have the time, could you rebase and resubmit? I recently merged fixes for minitest that may help clear up your test failures. |
This PR suppresses the following warnings. ```console bundle exec rake /Users/koic/src/github.com/voormedia/rails-erd/lib/rails_erd/diagram/graphviz.rb:313: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments. /Users/koic/src/github.com/voormedia/rails-erd/lib/rails_erd/diagram/graphviz.rb:313: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead. ``` The interface of `ERB.new` will change from Ruby 2.6. > Add :trim_mode and :eoutvar keyword arguments to ERB.new. > Now non-keyword arguments other than first one are softly deprecated > and will be removed when Ruby 2.5 becomes EOL. [Feature #14256] https://github.com/ruby/ruby/blob/2311087/NEWS#stdlib-updates-outstanding-ones-only
d9999a0
to
11b3fff
Compare
@kerrizor I rebased this PR. Thanks for the replying! |
@@ -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+ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Thanks again, @koic |
This PR suppresses the following warnings.
The interface of
ERB.new
will change from Ruby 2.6.https://github.com/ruby/ruby/blob/2311087/NEWS#stdlib-updates-outstanding-ones-only