From 5f131b865d36ed593fba37767f3ee4658a909d65 Mon Sep 17 00:00:00 2001 From: Eric Guo Date: Sat, 1 Aug 2015 12:28:33 +0800 Subject: [PATCH] need lookahead match for windows file path contain 'c:/git/' So we will got full file path instead of only c if caller.first is: c:/git/emberjs/ember-crm-backend/app/serializers/lead_serializer.rb:1:in `' CALLER_FILE = / /A # start of string \S+ # one or more non-spaces (?= # stop previous match when :\d+:in # a colon is followed by one or more digits # followed by a colon followed by in ) /x credit from https://gist.github.com/mikezter/540132 and @bf4 --- lib/active_model/serializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index c267e5f0f..ee43f4ba9 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -29,8 +29,8 @@ def self.inherited(base) base._attributes = self._attributes.try(:dup) || [] base._attributes_keys = self._attributes_keys.try(:dup) || {} base._urls = [] - serializer_file = File.open(caller.first[/^[^:]+/]) - base._cache_digest = Digest::MD5.hexdigest(serializer_file.read) + serializer_file_path = caller.first[/\A\S+(?=:\d+:in)/] + base._cache_digest = Digest::MD5.hexdigest(File.read(serializer_file_path)) super end