Remove support for source file reloading [#166]
Use shotgun: http://rtomayko.github.com/shotgun/
This commit is contained in:
parent
9dec74e3d8
commit
13fc79d388
8
CHANGES
8
CHANGES
|
@ -1,3 +1,11 @@
|
|||
= 0.9.2 / unreleased
|
||||
|
||||
* Development mode source file reloading has been removed. The
|
||||
"shotgun" (http://rtomayko.github.com/shotgun/) program can be
|
||||
used to achieve the same basic functionality in most situations.
|
||||
Passenger users should use the "tmp/always_restart.txt"
|
||||
file (http://tinyurl.com/c67o4h). [#166]
|
||||
|
||||
= 0.9.1.1 / 2009-03-09
|
||||
|
||||
* Fix directory traversal vulnerability in default static files
|
||||
|
|
14
README.rdoc
14
README.rdoc
|
@ -285,13 +285,7 @@ A route can punt processing to the next matching route using <tt>pass</tt>:
|
|||
The route block is immediately exited and control continues with the next
|
||||
matching route. If no matching route is found, a 404 is returned.
|
||||
|
||||
== Configuration and Reloading
|
||||
|
||||
Sinatra supports multiple environments and reloading. Reloading happens
|
||||
before each request when running under the <tt>:development</tt>
|
||||
environment. Wrap your configurations (e.g., database connections, constants,
|
||||
etc.) in <tt>configure</tt> blocks to protect them from reloading or to
|
||||
target specific environments.
|
||||
== Configuration
|
||||
|
||||
Run once, at startup, in any environment:
|
||||
|
||||
|
@ -300,14 +294,14 @@ Run once, at startup, in any environment:
|
|||
end
|
||||
|
||||
Run only when the environment (RACK_ENV environment variable) is set to
|
||||
<tt>:production</tt>.
|
||||
<tt>:production</tt>:
|
||||
|
||||
configure :production do
|
||||
...
|
||||
end
|
||||
|
||||
Run when the environment (RACK_ENV environment variable) is set to
|
||||
either <tt>:production</tt> or <tt>:test</tt>.
|
||||
Run when the environment is set to either <tt>:production</tt> or
|
||||
<tt>:test</tt>:
|
||||
|
||||
configure :production, :test do
|
||||
...
|
||||
|
|
|
@ -797,7 +797,6 @@ module Sinatra
|
|||
# Set configuration options for Sinatra and/or the app.
|
||||
# Allows scoping of settings for certain environments.
|
||||
def configure(*envs, &block)
|
||||
return if reloading?
|
||||
yield if envs.empty? || envs.include?(environment.to_sym)
|
||||
end
|
||||
|
||||
|
@ -845,22 +844,7 @@ module Sinatra
|
|||
end
|
||||
|
||||
def call(env)
|
||||
synchronize do
|
||||
reload! if reload?
|
||||
prototype.call(env)
|
||||
end
|
||||
end
|
||||
|
||||
def reloading?
|
||||
@reloading
|
||||
end
|
||||
|
||||
def reload!
|
||||
@reloading = true
|
||||
reset!
|
||||
$LOADED_FEATURES.delete("sinatra.rb")
|
||||
::Kernel.load app_file
|
||||
@reloading = false
|
||||
synchronize { prototype.call(env) }
|
||||
end
|
||||
|
||||
def reset!(base=superclass)
|
||||
|
@ -947,8 +931,7 @@ module Sinatra
|
|||
set :root, Proc.new { app_file && File.expand_path(File.dirname(app_file)) }
|
||||
set :views, Proc.new { root && File.join(root, 'views') }
|
||||
set :public, Proc.new { root && File.join(root, 'public') }
|
||||
set :reload, Proc.new { app_file? && app_file !~ /\.ru$/i && development? }
|
||||
set :lock, Proc.new { reload? }
|
||||
set :lock, false
|
||||
|
||||
# static files route
|
||||
get(/.*[^\/]$/) do
|
||||
|
|
|
@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
|
||||
s.name = 'sinatra'
|
||||
s.version = '0.9.1.1'
|
||||
s.date = '2009-03-09'
|
||||
s.version = '0.9.1.2'
|
||||
s.date = '2009-03-24'
|
||||
|
||||
s.description = "Classy web-development dressed in a DSL"
|
||||
s.summary = "Classy web-development dressed in a DSL"
|
||||
|
@ -78,7 +78,6 @@ Gem::Specification.new do |s|
|
|||
test/mapped_error_test.rb
|
||||
test/middleware_test.rb
|
||||
test/options_test.rb
|
||||
test/reload_test.rb
|
||||
test/request_test.rb
|
||||
test/response_test.rb
|
||||
test/result_test.rb
|
||||
|
@ -104,7 +103,8 @@ Gem::Specification.new do |s|
|
|||
s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/}
|
||||
|
||||
s.extra_rdoc_files = %w[README.rdoc LICENSE]
|
||||
s.add_dependency 'rack', '>= 0.9.1', '< 1.0'
|
||||
s.add_dependency 'rack', '>= 0.9.1', '< 1.0'
|
||||
s.add_development_dependency 'shotgun', '>= 0.2', '< 1.0'
|
||||
|
||||
s.has_rdoc = true
|
||||
s.homepage = "http://sinatra.rubyforge.org"
|
||||
|
|
|
@ -319,56 +319,8 @@ describe_option 'public' do
|
|||
end
|
||||
end
|
||||
|
||||
describe_option 'reload' do
|
||||
it 'is enabled when
|
||||
app_file is set,
|
||||
is not a rackup file,
|
||||
and we are in development' do
|
||||
@base.app_file = __FILE__
|
||||
@base.set(:environment, :development)
|
||||
assert @base.reload?
|
||||
|
||||
@default.app_file = __FILE__
|
||||
@default.set(:environment, :development)
|
||||
assert @default.reload?
|
||||
end
|
||||
|
||||
it 'is disabled if app_file is not set' do
|
||||
assert ! @base.reload?
|
||||
assert ! @default.reload?
|
||||
end
|
||||
|
||||
it 'is disabled if app_file is a rackup file' do
|
||||
@base.app_file = 'config.ru'
|
||||
assert ! @base.reload?
|
||||
|
||||
@default.app_file = 'config.ru'
|
||||
assert ! @base.reload?
|
||||
end
|
||||
|
||||
it 'is disabled if we are not in development' do
|
||||
@base.set(:environment, :foo)
|
||||
assert ! @base.reload
|
||||
|
||||
@default.set(:environment, :bar)
|
||||
assert ! @default.reload
|
||||
end
|
||||
end
|
||||
|
||||
describe_option 'lock' do
|
||||
it 'is enabled when reload is enabled' do
|
||||
@base.enable(:reload)
|
||||
assert @base.lock?
|
||||
|
||||
@default.enable(:reload)
|
||||
assert @default.lock?
|
||||
end
|
||||
|
||||
it 'is disabled when reload is disabled' do
|
||||
@base.disable(:reload)
|
||||
it 'is disabled by default' do
|
||||
assert ! @base.lock?
|
||||
|
||||
@default.disable(:reload)
|
||||
assert ! @default.lock?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/helper'
|
||||
|
||||
$reload_count = 0
|
||||
$reload_app = nil
|
||||
|
||||
describe "Reloading" do
|
||||
before {
|
||||
@app = mock_app(Sinatra::Default)
|
||||
$reload_app = @app
|
||||
}
|
||||
|
||||
after {
|
||||
$reload_app = nil
|
||||
}
|
||||
|
||||
it 'is enabled by default when in development and the app_file is set' do
|
||||
@app.set :app_file, __FILE__
|
||||
@app.set :environment, :development
|
||||
assert_same true, @app.reload
|
||||
assert_same true, @app.reload?
|
||||
end
|
||||
|
||||
it 'is disabled by default when running in non-development environment' do
|
||||
@app.set :app_file, __FILE__
|
||||
@app.set :environment, :test
|
||||
assert !@app.reload
|
||||
assert_same false, @app.reload?
|
||||
end
|
||||
|
||||
it 'is disabled by default when no app_file is available' do
|
||||
@app.set :app_file, nil
|
||||
@app.set :environment, :development
|
||||
assert !@app.reload
|
||||
assert_same false, @app.reload?
|
||||
end
|
||||
|
||||
it 'is disabled when app_file is a rackup (.ru) file' do
|
||||
@app.set :app_file, __FILE__.sub(/\.rb$/, '.ru')
|
||||
@app.set :environment, :development
|
||||
assert !@app.reload
|
||||
assert_same false, @app.reload?
|
||||
end
|
||||
|
||||
it 'can be turned off explicitly' do
|
||||
@app.set :app_file, __FILE__
|
||||
@app.set :environment, :development
|
||||
assert_same true, @app.reload
|
||||
@app.set :reload, false
|
||||
assert_same false, @app.reload
|
||||
assert_same false, @app.reload?
|
||||
end
|
||||
|
||||
it 'reloads the app_file each time a request is made' do
|
||||
@app.set :app_file, File.dirname(__FILE__) + '/data/reload_app_file.rb'
|
||||
@app.set :reload, true
|
||||
@app.get('/') { 'Hello World' }
|
||||
|
||||
get '/'
|
||||
assert_equal 200, status
|
||||
assert_equal 'Hello from reload file', body
|
||||
assert_equal 1, $reload_count
|
||||
|
||||
get '/'
|
||||
assert_equal 200, status
|
||||
assert_equal 'Hello from reload file', body
|
||||
assert_equal 2, $reload_count
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue