Labels

Milestone

Assignee

2 participants

Doing so is a good practice. In the case of tilt, it's also a PITA because so many of the template gems generate warnings. It's possible to filter them in 1.8.7 using the module below... but I couldn't get it to work on 1.9.2 (I'm not sure why). At any rate this pull request fixes a few warnings in tilt itself. I split it into one commit that turns on the warnings and one that fixes them in case you want to cherry-pick.

WarnFilter Add to test folder and require in test/contest to enable.

# Filter warnings from vendored gems. Must be included before the filtered
# code is required (obviously).
#
# WarnFilter can be turned off by specifying ENV['WARN_FILTER'] = 'false'.
module WarnFilter
FILTER_PATHS = [File.expand_path('../../vendor', __FILE__), 'test.haml', '(__TEMPLATE__)']
@@count = 0
# A running tally of warnings that have been filtered.
def self.count
@@count
end
# Writes the message unless it begins with one of the FILTER_PATHS, in
# which case the message is interpreted as a warning. In that case
# count is incremented and the message is ignored.
def write(message)
FILTER_PATHS.any? {|path| message.index(path) == 0 } ? @@count += 1 : super
end
end
unless ENV['WARN_FILTER'] == 'false'
$stderr.extend(WarnFilter)
at_exit do
if WarnFilter.count > 0
$stderr.puts "(WarnFilter filtered #{WarnFilter.count} warnings, set WARN_FILTER=false in ENV to see warnings)"
end
end
end