Permalink
Browse files

Added SINATRA_ROOT to point to the root folder of the sinatra applica…

…tion.

Since this has problems with shotgun i have added Rack::Reloader in SinatraApp controller
to avoid shotgun usage.
  • Loading branch information...
sirfilip committed Mar 11, 2011
1 parent 8f1ea05 commit 7f8f38b3ad6e35952695ead810b0465a710533ed
Showing with 11 additions and 10 deletions.
  1. +10 −10 bootloader.rb
  2. +1 −0 controllers/sinatra_app.rb
View
@@ -1,7 +1,7 @@
require 'rubygems'
require 'bundler/setup'
-sinatra_root = File.dirname(__FILE__)
+SINATRA_ROOT = File.dirname(__FILE__)
Bundler.require(:default)
@@ -16,23 +16,23 @@ def underscore_to_camelcase
autoload_folders = %w[lib controllers models]
autoload_folders.each do |folder|
- files = Dir.entries(File.join(sinatra_root, folder)).reject! {|file| file.start_with?('.') }
+ files = Dir.entries(File.join(SINATRA_ROOT, folder)).reject! {|file| file.start_with?('.') }
files.each do |f|
- basename = File.basename(File.join(sinatra_root, folder, f), '.rb')
- Object.autoload basename.underscore_to_camelcase.to_sym, File.join(sinatra_root, folder, f)
+ basename = File.basename(File.join(SINATRA_ROOT, folder, f), '.rb')
+ Object.autoload basename.underscore_to_camelcase.to_sym, File.join(SINATRA_ROOT, folder, f)
end
end
# autolad the helpers
-files = Dir.entries(File.join(sinatra_root, 'helpers')).reject! {|file| file.start_with?('.') }
+files = Dir.entries(File.join(SINATRA_ROOT, 'helpers')).reject! {|file| file.start_with?('.') }
files.each do |f|
- basename = File.basename(File.join(sinatra_root, 'helpers', f), '.rb')
- Sinatra.autoload basename.underscore_to_camelcase.to_sym, File.join(sinatra_root, 'helpers', f)
+ basename = File.basename(File.join(SINATRA_ROOT, 'helpers', f), '.rb')
+ Sinatra.autoload basename.underscore_to_camelcase.to_sym, File.join(SINATRA_ROOT, 'helpers', f)
end
# load the initializers
-initializers = Dir.entries(File.join(sinatra_root, 'initializers')).reject {|file| file.start_with?('.')}
+initializers = Dir.entries(File.join(SINATRA_ROOT, 'initializers')).reject {|file| file.start_with?('.')}
initializers.each do |f|
- basename = File.basename(File.join(sinatra_root, 'initializers', f), '.rb')
- require File.join(sinatra_root, 'initializers', basename)
+ basename = File.basename(File.join(SINATRA_ROOT, 'initializers', f), '.rb')
+ require File.join(SINATRA_ROOT, 'initializers', basename)
end
@@ -2,6 +2,7 @@ class SinatraApp < Sinatra::Base
# use Rack::Auth::Basic do |username, password|
# username == 'filip' && password == 'pass'
# end
+ use Rack::Reloader
enable :sessions, :logging
set :environment, :development

0 comments on commit 7f8f38b

Please sign in to comment.