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 `<top (required)>'

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
This commit is contained in:
Eric Guo 2015-08-01 12:28:33 +08:00
parent 6aba260491
commit f93a7e8b41

View File

@ -29,8 +29,8 @@ module ActiveModel
base._attributes = self._attributes.try(:dup) || [] base._attributes = self._attributes.try(:dup) || []
base._attributes_keys = self._attributes_keys.try(:dup) || {} base._attributes_keys = self._attributes_keys.try(:dup) || {}
base._urls = [] base._urls = []
serializer_file = File.open(caller.first[/^[^:]+/]) serializer_file_path = caller.first[/\A\S+(?=:\d+:in)/]
base._cache_digest = Digest::MD5.hexdigest(serializer_file.read) base._cache_digest = Digest::MD5.hexdigest(File.read(serializer_file_path))
super super
end end