Skip to content

Commit

Permalink
need lookahead match for windows file path contain 'c:/git/'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Eric-Guo committed Aug 15, 2015
1 parent 8568ed5 commit f477666
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/active_model/serializer.rb
Expand Up @@ -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

Expand Down

0 comments on commit f477666

Please sign in to comment.