From 707db6198f629a35fc2aba08800398e769e52bc1 Mon Sep 17 00:00:00 2001 From: Iain Beeston Date: Thu, 5 Mar 2015 10:55:19 +0000 Subject: [PATCH] Stopped using the global variable $1 global It's a bad practice, plus it might cause problems with multithreaded code --- .../action_view/partial_renderer.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rails_view_annotator/action_view/partial_renderer.rb b/lib/rails_view_annotator/action_view/partial_renderer.rb index 7c86663..f134cf0 100644 --- a/lib/rails_view_annotator/action_view/partial_renderer.rb +++ b/lib/rails_view_annotator/action_view/partial_renderer.rb @@ -15,8 +15,14 @@ def self.augment_partial_renderer klass short_identifier = Pathname.new(identifier).relative_path_from Rails.root r = /^#{Regexp.escape(Rails.root.to_s)}\/([^:]+:\d+)/ - caller.find { |line| line.match r } - called_from = context = $1 + called_from = context = nil + caller.each do |line| + m = line.match(r) + unless m.nil? + called_from = context = m[1] + break + end + end descriptor = "#{short_identifier} (from #{called_from})"