1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Deprecate Sinatra::Default; use Sinatra::Application [#240]

This commit is contained in:
Ryan Tomayko 2009-06-07 05:39:59 -07:00
parent 578fe06e42
commit 7f5d4dfb8a
2 changed files with 13 additions and 14 deletions

View file

@ -1035,8 +1035,9 @@ module Sinatra
end
end
# Base class for classic style (top-level) applications.
class Default < Base
# The top-level Application. All DSL methods executed on main are delegated
# to this class.
class Application < Base
set :raise_errors, Proc.new { test? }
set :show_exceptions, Proc.new { development? }
set :dump_errors, true
@ -1053,10 +1054,8 @@ module Sinatra
end
end
# The top-level Application. All DSL methods executed on main are delegated
# to this class.
class Application < Default
end
# Deprecated.
Default = Application
# Sinatra delegation mixin. Mixing this module into an object causes all
# methods to be delegated to the Sinatra::Application class. Used primarily
@ -1089,11 +1088,11 @@ module Sinatra
# Extend the top-level DSL with the modules provided.
def self.register(*extensions, &block)
Default.register(*extensions, &block)
Application.register(*extensions, &block)
end
# Include the helper modules provided in Sinatra's request context.
def self.helpers(*extensions, &block)
Default.helpers(*extensions, &block)
Application.helpers(*extensions, &block)
end
end

View file

@ -1,7 +1,7 @@
require 'sinatra/base'
module Sinatra
class Default < Base
class Application < Base
# we assume that the first file that requires 'sinatra' is the
# app_file. all other path related options are calculated based
@ -19,6 +19,11 @@ module Sinatra
op.on('-p port') { |val| set :port, val.to_i }
}.parse!(ARGV.dup)
end
at_exit do
raise $! if $!
run! if run?
end
end
end
@ -28,8 +33,3 @@ def mime(ext, type)
ext = ".#{ext}" unless ext.to_s[0] == ?.
Rack::Mime::MIME_TYPES[ext.to_s] = type
end
at_exit do
raise $! if $!
Sinatra::Application.run! if Sinatra::Application.run?
end