Skip to content

Commit

Permalink
Better file/line detection in sinatra_warn
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomayko committed Jan 13, 2009
1 parent 17cb177 commit 4cddd70
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/sinatra/compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4cddd70

Please sign in to comment.