Permalink
Browse files

move sinatra_warn into base.rb and use for 1.0 deprecations

  • Loading branch information...
1 parent e419cd8 commit 7a74c72984b7a29659da2bc82d2a0da543450ecd @rtomayko rtomayko committed Mar 4, 2010
Showing with 12 additions and 12 deletions.
  1. +12 −4 lib/sinatra/base.rb
  2. +0 −8 lib/sinatra/compat.rb
View
16 lib/sinatra/base.rb
@@ -5,6 +5,14 @@
require 'rack/builder'
require 'sinatra/showexceptions'
+# Like Kernel#warn but outputs the location that triggered the warning.
+def sinatra_warn(*message) #:nodoc:
+ line = caller.
+ detect { |line| line !~ /(?:lib\/sinatra\/|__DELEGATE__)/ }.
+ sub(/:in .*/, '')
+ warn "#{line}: warning: #{message.join(' ')}"
+end
+
module Sinatra
VERSION = '0.9.4'
@@ -109,7 +117,7 @@ def mime_type(type)
end
def media_type(type)
- warn "media_type is deprecated; use mime_type instead"
+ sinatra_warn "media_type is deprecated; use mime_type instead"
mime_type(type)
end
@@ -346,7 +354,7 @@ def render_builder(template, data, options, locals, &block)
end
def require_warn(engine)
- warn "Auto-require of #{engine} is deprecated; add require '#{engine}' to your app."
+ sinatra_warn "auto-require of #{engine} is deprecated; add require '#{engine}' to your app."
require engine.downcase
end
end
@@ -678,7 +686,7 @@ def layout(name=:layout, &block)
end
def use_in_file_templates!(file=nil)
- warn "use_in_file_templates! is deprecated; " \
+ sinatra_warn "use_in_file_templates! is deprecated; " \
"use enable :inline_templates instead"
set :inline_templates, file
end
@@ -719,7 +727,7 @@ def mime_type(type, value=nil)
end
def media_type(type, value=nil)
- warn "media_type is deprecated; use mime_type instead"
+ sinatra_warn "media_type is deprecated; use mime_type instead"
mime_type(type, value)
end
View
8 lib/sinatra/compat.rb
@@ -8,14 +8,6 @@
require 'sinatra/base'
require 'sinatra/main'
-# Like Kernel#warn but outputs the location that triggered the warning.
-def sinatra_warn(*message) #:nodoc:
- line = caller.
- detect { |line| line !~ /(?:lib\/sinatra\/|__DELEGATE__)/ }.
- sub(/:in .*/, '')
- warn "#{line}: warning: #{message.join(' ')}"
-end
-
# Rack now supports evented and swiftiplied mongrels through separate
# handler.
if ENV['SWIFT']

0 comments on commit 7a74c72

Please sign in to comment.