No worries, we wont short-change you on the reference aspects; you can certainly return to this book to recall how to perform daily tasks without excessive searching.
With that said, lets get you up and running.
Who This Book Is For
Sinatra: Up and Running is for developers with some Ruby experience under their belt, and ideally some web development experience as well. Some concepts that are core to web development (the HTTP specification, HTML, CSS, etc.) are critical to understanding how to be productive with Sinatra; we recommend that you have at least a passing familiarity with these concepts to make the experience a little easier.
If youve written some web applications before but not specifically in Ruby, thats no problem. Our discussion of other tools is primarily limited to comparing and contrasting with how Sinatra does things.
Our plan is to try to address the needs of several distinct camps of readers: those with a Ruby web development background in Rails but no experience with Sinatra, as well those who are familiar with Sinatra but would like a tour of its internals and philosophy. Where possible, wed also like to help bring developers without direct web experience into the fold. Pretty tricky if you think about it, but well do our best to speak to all the seats in the house by the conclusion.
Given these stated goals, weve divided the materials into three sections. The beginning of the book focuses on the bare minimum you need to know to work with Sinatra. Here youll find the fundamentals, such as how to craft routes, manage sessions, create views, and so on. Immediately afterward, we will lift the veil and examine some of the techniques behind the scenes, which will open up a world of possibilities for implementation and integration. Finally, we will wrap up the discussion with some practical applications, including developing a GitHub-powered blog.
Note
Weve also tried to inject as much related information as possible for the various topics covered within, ranging from gotchas to other resources where one could explore subtopics in greater depth.
One aside: if you encounter a section explaining information youre already well-versed in, please bear with us as other readers may benefit from the discussion. We strive to keep the pace brisk, but wed prefer not to leave any folks out.
How This Book Is Organized
Sinatra: Up and Running is organized as follows.
The Basics
, Taking the Stage , serves as a high-level introduction to some of the core concepts in Sinatra. It also discusses how to install the Sinatra gem, and walks through the creation of a simple application.
, Fundamentals , covers the different features of Sinatra, such as route definitions, creating views, managing sessions, and so on. It also serves as something of a reference chapter, with each topic discussed in granular fashion.
Note
If youve already built some Sinatra applications of your own and are fairly comfortable doing so, you can likely just skim through Chapters 1 and 2, although the newest release of Sinatra (version 1.3.1) contains a number of changes that are worth exploring (including support for the HTTP PATCH verb, streaming, etc.).
Digging Deeper
In , A Peek Behind the Curtain , we discuss the internals of Sinatra and its implementation; this includes coverage of Rack, building middleware, and other topics that clarify what really happens under the hood.
, Modular Applications , covers the various approaches available for subclassing Sinatra, allowing you to create significantly more flexible and robust architectures.
Note
If youve built some Sinatra applications but have never really explored the source code (or written Rack applications directly), this section will help to flesh out your knowledge. Understanding the modular application approach is critical to taking full advantage of what Sinatra offers.
Hands On
In , Your Own Blog Engine , we put the theory into application and create a Markdown-powered blog that takes advantage of the service hooks provided by the GitHub API.
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This icon signifies a tip, suggestion, or general note.
Caution
This icon indicates a warning or caution.
Using Code Examples
This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.