Sinatra 1.0 Frequently Asked Questions
Sinatra is going 1.0. Here are some things you should know:
Is Sinatra 1.0 a rewrite / major conceptual overhaul?
No. Sinatra 1.0 is very much the same codebase as the current stable 0.9 release (0.9.6). The largest changes are internal - we’re dropping the backward compatibility module and test suite that’s been maintained since the 0.3 release. The majority of obsoleted features are simple class/method name changes that have been documented for some time. Very few features have been removed in their entirety.
Some new features have been introduced.
Will my existing Sinatra app work with 1.0? How can I check?
Maybe.
If you’ve kept up with deprecations and use officially documented features, your app should be fine under Sinatra 1.0.
The latest Sinatra 0.9.x release (0.9.6 at time of writing) includes comprehensive deprecation warnings for all incompatibilities introduced in Sinatra 1.0. Run your test suite and app under 0.9.6 and watch for warnings on standard error. When no more deprecation warnings remain, upgrade your staging environment to Sinatra 1.0 and verify that stuff works.
Can I install and run under Sinatra 1.0 today?
YES! Install the latest 1.0 release with:
gem install sinatra
Alternatively, you can grab a clone of the master branch:
git clone git://github.com/sinatra/sinatra.git
RUBYLIB="$(pwd)/sinatra/lib:$RUBYLIB"
What incompatibilities are being introduced in Sinatra 1.0?
The following is a comprehensive list of features obsoleted in the 1.0 release. All of these have been deprecated for some time:
-
The
sinatra/testlibrary is obsolete. This includes theSinatra::Testmodule, theSinatra::TestHarnessclass, and theget_it,post_it,put_it,delete_it, andhead_ithelper methods. TheRack::Testlibrary should be used instead. -
Test framework specific libraries (
sinatra/test/spec,sinatra/test/bacon,sinatra/test/rspec, etc.) are obsolete. See Testing Sinatra for instructions on setting up a testing environment under each of these frameworks. -
Sinatra::Defaultis obsolete; useSinatra::Baseinstead.Sinatra::Baseacts more likeSinatra::Defaultin 1.0. For example, static files and error handlers are enabled by default in all environment and classy development error pages are enabled in development environments. -
Auto-requiring template libraries in the
erb,builder,haml, andsassmethods is obsolete due to thread-safety issues. You must require the template libraries explicitly in your app. -
The
:views_directoryoption to rendering methods is obsolete; use:viewsinstead. -
The
:hamland:sassoptions to rendering methods are obsolete. Template engine options should be passed in the second Hash argument instead. -
The
media_typehelper method is obsolete. Usemime_typeinstead. -
The
mimemain and class method is obsolete. Usemime_typeinstead. -
The request-level
send_datamethod is no longer supported. -
The
Sinatra::EventandSinatra::EventContextclasses 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_optionandset_optionsmethods are obsolete; usesetinstead. -
The
:envsetting (settings.env) is obsolete; use:environmentinstead. -
The request level
stopmethod is obsolete; usehaltinstead. -
The request level
entity_tagmethod is obsolete; useetaginstead. -
The request level
headersmethod (HTTP response headers) is obsolete; useresponse['Header-Name']instead. -
Sinatra.applicationis obsolete; useSinatra::Applicationinstead. -
Using
Sinatra.application = nilto reset an application is obsolete. This should no longer be necessary. -
Using
Sinatra.default_optionsto set base configuration items is obsolete; useSinatra::Base.set(key, value)instead. -
The
Sinatra::ServerErrorexception is obsolete. All exceptions raised within a request are now treated as internal server errors and result in a 500 response status.
What about new features?
See the CHANGES file for a list of features added in the 1.0 release. There’s also a comprehensive diff of all changes between the 0.9.x and 1.0 releases.
Lastly, the 1.0 Lighthouse milestone page includes 80 tickets with details on various features and bug fixes.
How will versions be handled in the 1.x series?
We’ve adopted the Semantic Versioning Model. All 1.x releases will be backward compatible with the initial 1.0 release.
(This is one of the reasons we’ve waited so long to do an official 1.0 release. We’re required not to break anything shipped in 1.0 for a very long time, so interfaces we don’t like require considerable scrutiny.)
Will the 0.9.x series continue to be maintained?
Yes. There will be additional Sinatra 0.9.x releases for security issues or major defects. No new features will be added to the 0.9.x series.
The 0.9.x series will be maintained for as long as people use it.
How can I pin my app to 0.9.x to avoid upgrading to 1.0?
You shouldn’t have to do anything if you bundle/vendor sinatra with your
app. Just make sure you’re pulling from the 0.9.x branch or vendoring an
0.9.x gem.
If you use Rubygems, there’s a very real possibility that Sinatra will be upgraded to 1.0 on your system. You can force your apps to use an 0.9.x version with:
gem 'sinatra', '< 1.0'
