From 38871ad4e5e3b367256ac0a950b2ed7eb0335091 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 11 Jan 2023 11:00:58 +0100 Subject: Get rid of anonymous eval calls Things declared in anonymous eval are always annoying to locate. --- lib/psych/class_loader.rb | 2 +- lib/psych/tree_builder.rb | 4 ++-- test/psych/test_encoding.rb | 4 ++-- test/psych/test_parser.rb | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/psych/class_loader.rb b/lib/psych/class_loader.rb index c2e4ea4..50efc35 100644 --- a/lib/psych/class_loader.rb +++ b/lib/psych/class_loader.rb @@ -35,7 +35,7 @@ module Psych constants.each do |const| konst = const_get const - class_eval <<~RUBY + class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{const.to_s.downcase} load #{konst.inspect} end diff --git a/lib/psych/tree_builder.rb b/lib/psych/tree_builder.rb index 414ca02..83115bd 100644 --- a/lib/psych/tree_builder.rb +++ b/lib/psych/tree_builder.rb @@ -41,7 +41,7 @@ module Psych Sequence Mapping }.each do |node| - class_eval %{ + class_eval <<~RUBY, __FILE__, __LINE__ + 1 def start_#{node.downcase}(anchor, tag, implicit, style) n = Nodes::#{node}.new(anchor, tag, implicit, style) set_start_location(n) @@ -54,7 +54,7 @@ module Psych set_end_location(n) n end - } + RUBY end ### diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb index 7d33814..1867d59 100644 --- a/test/psych/test_encoding.rb +++ b/test/psych/test_encoding.rb @@ -13,13 +13,13 @@ module Psych (Handler.instance_methods(true) - Object.instance_methods).each do |m| - class_eval %{ + class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{m} *args @strings += args.flatten.find_all { |a| String === a } end - } + RUBY end end diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index e087e31..3b67a8e 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -16,13 +16,13 @@ module Psych (Handler.instance_methods(true) - Object.instance_methods).each do |m| - class_eval %{ + class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{m} *args super @marks << @parser.mark if @parser @calls << [:#{m}, args] end - } + RUBY end end -- cgit v1.2.1