Sinatra v1.0 Release Notes
Release Date: 2010-03-23 // about 14 years ago-
It's now possible to register blocks to run after each request using after filters. After filters run at the end of each request, after routes and error handlers. (Jimmy Schementi)
Sinatra now uses Tilt http://github.com/rtomayko/tilt for rendering templates. This adds support for template caching, consistent template backtraces, and support for new template engines, like mustache and liquid. (Ryan Tomayko)
ERB, Erubis, and Haml templates are now compiled the first time they're rendered instead of being string eval'd on each invocation. Benchmarks show a 5x-10x improvement in render time. This also reduces the number of objects created, decreasing pressure on Ruby's GC. (Ryan Tomayko)
New 'settings' method gives access to options in both class and request scopes. This replaces the 'options' method. (Chris Wanstrath)
New boolean 'reload_templates' setting controls whether template files are reread from disk and recompiled on each request. Template read/compile is cached by default in all environments except development. (Ryan Tomayko)
New 'erubis' helper method for rendering ERB template with Erubis. The erubis gem is required. (Dylan Egan)
New 'cache_control' helper method provides a convenient way of setting the Cache-Control response header. Takes a variable number of boolean directives followed by a hash of value directives, like this: cache_control :public, :must_revalidate, :max_age => 60 (Ryan Tomayko)
New 'expires' helper method is like cache_control but takes an integer number of seconds or Time object: expires 300, :public, :must_revalidate (Ryan Tomayko)
New request.secure? method for checking for an SSL connection. (Adam Wiggins)
Sinatra apps can now be run with a
-o <addr>
argument to specify the address to bind to. (Ryan Tomayko)Rack::Session::Cookie is now added to the middleware pipeline when running in test environments if the :sessions option is set. (Simon Rozet)
Route handlers, before filters, templates, error mappings, and middleware are now resolved dynamically up the inheritance hierarchy when needed instead of duplicating the superclass's version when a new Sinatra::Base subclass is created. This should fix a variety of issues with extensions that need to add any of these things to the base class. (Ryan Tomayko)
Exception error handlers always override the raise_errors option now. Previously, all exceptions would be raised outside of the application when the raise_errors option was enabled, even if an error handler was defined for that exception. The raise_errors option now controls whether unhandled exceptions are raised (enabled) or if a generic 500 error is returned (disabled). (Ryan Tomayko)
The X-Cascade response header is set to 'pass' when no matching route is found or all routes pass. (Josh Peek)
Filters do not run when serving static files anymore. (Ryan Tomayko)
pass takes an optional block to be used as the route handler if no subsequent route matches the request. (Blake Mizerany)
๐ The following Sinatra features have been obsoleted (removed entirely) in ๐ the 1.0 release:
The
sinatra/test
library is obsolete. This includes theSinatra::Test
module, theSinatra::TestHarness
class, and theget_it
,post_it
,put_it
,delete_it
, andhead_it
helper methods. TheRack::Test
library should be used instead.Test framework specific libraries (
sinatra/test/spec
,sinatra/test/bacon
,sinatra/test/rspec
, etc.) are obsolete. See http://www.sinatrarb.com/testing.html for instructions on setting up a testing environment under each of these frameworks.Sinatra::Default
is obsolete; useSinatra::Base
instead.Sinatra::Base
acts more likeSinatra::Default
in development mode. For example, static file serving and sexy development error pages are enabled by default.Auto-requiring template libraries in the
erb
,builder
,haml
, andsass
methods is obsolete due to thread-safety issues. You must require the template libraries explicitly in your app.The
:views_directory
option to rendering methods is obsolete; use:views
instead.The
:haml
and:sass
options to rendering methods are obsolete. Template engine options should be passed in the second Hash argument instead.The
use_in_file_templates
method is obsolete. Useenable :inline_templates
orset :inline_templates, 'path/to/file'
The 'media_type' helper method is obsolete. Use 'mime_type' instead.
The 'mime' main and class method is obsolete. Use 'mime_type' instead.
The request-level
send_data
method is no longer supported.The
Sinatra::Event
andSinatra::EventContext
classes are no longer supported. This may effect extensions written for versions prior to 0.9.2. See Writing Sinatra Extensions for the officially supported extensions API.The
set_option
andset_options
methods are obsolete; useset
instead.The
:env
setting (settings.env
) is obsolete; use:environment
instead.The request level
stop
method is obsolete; usehalt
instead.The request level
entity_tag
method is obsolete; useetag
instead.The request level
headers
method (HTTP response headers) is obsolete; useresponse['Header-Name']
instead.Sinatra.application
is obsolete; useSinatra::Application
instead.Using
Sinatra.application = nil
to reset an application is obsolete. This should no longer be necessary.Using
Sinatra.default_options
to set base configuration items is obsolete; useSinatra::Base.set(key, value)
instead.The
Sinatra::ServerError
exception is obsolete. All exceptions raised within a request are now treated as internal server errors and result in a 500 response status.The
:methodoverride' option to enable/disable the POST _method hack is obsolete; use
:method_override` instead.