Permalink
Browse files

Better file/line detection in sinatra_warn

  • Loading branch information...
1 parent 17cb177 commit 4cddd7054123cebac7d9bc58b7187a0acbccded8 @rtomayko rtomayko committed Jan 13, 2009
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/sinatra/compat.rb
View
@@ -10,7 +10,9 @@
# Like Kernel#warn but outputs the location that triggered the warning.
def sinatra_warn(*message)
- line = caller[1].sub(/:in .*/, '')
+ line = caller.
+ detect { |line| line !~ /(?:lib\/sinatra\/|__DELEGATE__)/ }.
+ sub(/:in .*/, '')
warn "#{line}: warning: #{message.join(' ')}"
end

0 comments on commit 4cddd70

Please sign in to comment.