start 2
[sinatra.git] / lib / sinatra.rb
blob5722132da19d264ed1bc11ceb74d9f15855cb9f0
1 # Copyright (c) 2007 Blake Mizerany
2
3 # Permission is hereby granted, free of charge, to any person
4 # obtaining a copy of this software and associated documentation
5 # files (the "Software"), to deal in the Software without
6 # restriction, including without limitation the rights to use,
7 # copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following
10 # conditions:
11
12 # The above copyright notice and this permission notice shall be
13 # included in all copies or substantial portions of the Software.
14
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 # OTHER DEALINGS IN THE SOFTWARE.
24 %w(rubygems rack).each do |library|
25   begin
26     require library
27   rescue LoadError
28     raise "== Sinatra cannot run without #{library} installed"
29   end
30 end
32 SINATRA_ROOT = File.dirname(__FILE__) + '/..'
34 require File.dirname(__FILE__) + '/sinatra/loader'
36 Sinatra::Loader.load_files Dir.glob(SINATRA_ROOT + '/lib/sinatra/core_ext/*.rb')
37 Sinatra::Loader.load_files Dir.glob(SINATRA_ROOT + '/lib/sinatra/rack_ext/*.rb')
38 Sinatra::Loader.load_files Dir.glob(SINATRA_ROOT + '/lib/sinatra/*.rb')
40 Sinatra::Environment.prepare
42 Sinatra::Loader.load_files Dir.glob(SINATRA_ROOT + '/vendor/*/init.rb')
43 Sinatra::Loader.load_files Dir.glob(File.dirname($0) + '/vendor/*/init.rb')
45 at_exit do
46   raise $! if $!
47   Sinatra::Environment.prepare_loggers unless Sinatra::Environment.test?
48   Sinatra::Irb.start! if Sinatra::Options.console
49   Sinatra::Server.new.start unless Sinatra::Server.running
50 end