Skip to content

Commit

Permalink
move sinatra_warn into base.rb and use for 1.0 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomayko committed Mar 4, 2010
1 parent e419cd8 commit 7a74c72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 12 additions & 4 deletions lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 0 additions & 8 deletions lib/sinatra/compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 7a74c72

Please sign in to comment.