12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/garner/strategies/keys/caller_strategy.rb', line 12
def apply(key, context = {})
rc = key ? key.dup : {}
if context.keys.include?(field)
rc[field] = context[field]
return rc
end
caller.each do |line|
split = line.split(":")
next unless split.length >= 2
path = (Pathname.new(split[0]).realpath.to_s rescue nil)
next if path.blank? || path.include?("lib/garner")
next unless path.include?("/app/") || path.include?("/spec/")
rc[field] = "#{path}:#{split[1]}"
break
end
rc
end
|