Jump Start Sinatra – With this book and a little Ruby, you can make Sinatra sing – #programming #bookreview

Jump Start Sinatra
Get Up to Speed with Sinatra in a Weekend
Darren Jones
(SitePoint – Kindle, Paperback)

Many Ruby developers love Rails for its power and capabilities as a model-view-controller (MVC) framework. But some of them don’t like Rails’ size, complexity, and learning curve.

Meanwhile, many other Rubyists love Sinatra for its simplicity and ease of learning, plus its ability “to create a fully functional web app in just one file,” says Darren Jones in his new book, Jump Start Sinatra. “There are no complicated setup procedures or configuration to worry about. You can just open up a text editor and get started with minimal effort, leaving you to focus on the needs of your application.”

Jones does not temper his enthusiasm for Sinatra, adding that “there isn’t a single line of bloat anywhere in its source code, which weighs in at fewer than 2,000 lines!”

His 150-page book covers a lot of ground, from downloading and installing Sinatra to building websites, working with SQLite, Heroku, Rack, jQuery, and Git, and even using some CoffeeScript (to avoid “getting our hands dirty writing JavaScript…”). He also shows how to create modular Sinatra applications that use separate classes.

“Sinatra makes it easy–trivial almost–to build sites, services, and web apps using Ruby,” the author states. “A Sinatra application is basically made up of one or more Ruby files. You don’t need to be an expert Rubyist to use Sinatra, but the more Ruby you know, the better you’ll be at building Sinatra apps.”

Jones adds: “Unlike Ruby on Rails, Sinatra is definitely not a framework. It’s without conventions and imposes no file structure on you whatsoever. Sinatra apps are basically just Ruby programs; what Sinatra does is connect them to the Web. Rather than hide behind lots of magic, it exposes the way the Web works by making the key concepts of HTTP verbs and URLs an explicit part of it.”

Jump Start Sinatra is a well-written, appropriately illustrated guide to getting started with this popular free software. Ruby newcomers may wish for a few more how-to steps or code examples. But the counter argument is, if you’re brand-new to Ruby, save Sinatra for later; focus on getting learning Ruby first. 

Darren Jones does not buy into a common assessment that’s often heard when developers are asked their views of Rails vs. Sinatra. “Opinions abound that Sinatra can only be used for small applications or simple APIs, but this simply isn’t true,” he argues. “”While it is a perfect fit for these tasks, Sinatra also scales impressively, demonstrated by the fact that it’s been used to power some big production sites.”

Some of those “big production sites,” according to Wikipedia, include such notables as Apple, LinkedIn, the BBC, the British government, Heroku, and GitHub.

Si Dunn

Advertisements

Deploying Rails – A good how-to guide covering choices, tools & best practices – #programming #bookreview

Deploying Rails: Automate, Deploy, Scale, Maintain, and Sleep at Night
Anthony Burns and Tom Copeland (Pragmatic Bookshelf, paperback)

Maybe you have been studying Ruby and Rails and now feel ready for the next big step. Perhaps you are already on a job where a Rails application needs to be deployed and running on a server ASAP. Or, maybe you manage a team that must deploy and support a Rails app, and you want to understand more of what they actually must accomplish to get the app up and running – and keep it running.

Deploying Rails is a very good guide to the decisions that must be made and to the tools and best practices essential for success. The two writers are both professional Rails developers with strong backgrounds.

Their 217-page book, they note, “is “centered around an example social networking application called MassiveApp. While MassiveApp may not have taken the world by storm just yet, we’re confident that it’s going to be a winner, and we want to build a great environment in which MassiveApp can grow and flourish. This book will take us through that journey.”

That “journey” is organized into 10 chapters and two appendices, all well written and illustrated with code examples.

  • Chapter 1: Introduction – (including choosing a hosting location)
  • Chapter 2: Getting Started with Vagrant – (setting up and managing a virtual server and virtual machines)
  • Chapter 3: Rails on Puppet – (“arguably the most popular open source server provisioning tool.…”)
  • Chapter 4: Basic Capistrano – (“the premier Rails deployment utility….”)
  • Chapter 5: Advanced Capistrano – (deals with making deployments faster and also easier when “deploying to multiple environments.”)
  • Chapter 6: Monitoring with Naigos – (monitoring principles and how to apply them to Rails apps. Also, how to perform several types of checks.)
  • Chapter 7: Collecting Metrics with Ganglia – (how to gather a Rails app’s important metrics from an infrastructure level and an application level.)
  • Chapter 8: Maintaining the Application – (how to handle “the ongoing care and feeding of a production Rails application.”)
  • Chapter 9: Running Rubies with RVM – (using the Ruby enVironmental Manager [RVM] in development and deployment.)
  • Chapter 10: Special Topics – (“We’ll sweep through the Rails technology stack starting at the application level and proceed downward to the operating system, hitting on various interesting ideas as we go.”)

The two appendices cover (1) “a line-by-line review of a Capistrano deployment file” and (2) “deploying MassiveApp to an alternative technology stack consisting of nginx and Unicorn.”

A key focus of the book is building a set of configuration files and keeping the latest versions stored in Git, so deployment of a new or updated app can go smoother.

Deploying a Rails app involves making many different choices, and the process can go wrong quite easily if not set up properly.

“The most elegant Rails application,” the authors caution, “can be crippled by runtime environment issues that make adding new servers an adventure, unexpected downtime a regularity, scaling a difficult task, and frustration a constant.

“Good tools do exist for deploying, running, monitoring, and measuring Rails applications, but pulling them together into a coherent whole is no small effort.”

Deploying Rails can significantly ease the complicated process of getting a new Rails application running on a server. Equally important, Rails experts Anthony Burns and Tom Copeland can show you how to keep the app running smoothly and configured for growth as it gains users, functionality, and popularity.

Si Dunn

Rails Recipes: Rails 3 Edition – Solutions to 70 Problems & More – #bookreview #in #rails #programming

Rails Recipes: Rails 3 Edition
Chad Fowler
Pragmatic Bookshelf, paperback, list price $35.00)

Chad Fowler’s Rails Recipes: Rails 3 Edition is aimed at developers who need to solve tough problems while using Rails. But Rails beginners also can learn plenty from the 70 “recipes” in this excellent guide.

The 280-page book is divided into seven parts. Busy Rails developers can jump directly to any part that deals with their latest vexation. Those new to Rails also can read the book in any “recipe” order, or they can take it straight through like a textbook.

The seven parts are:

  1. Database Recipes
  2. Controller Recipes
  3. User Interface Recipes
  4. Testing Recipes
  5. Email Recipes
  6. Big-Picture Recipes
  7. Extending Rails

The author uses a simple problem-solution approach. For example, in Recipe 28, the problem is: “You notice a recurring pattern in your application. You’re writing code for the same actions over and over again in your controllers.” The solution Fowler presents involves learning how to use the Rails versions of macros to create “code that writes codes for you….” by taking “advantage of Ruby’s metaprogramming capabilities.”

He then shows how, noting that “Ruby, like Lisp and Smalltalk before it, allows programmers to easily write code that writes and loads code at runtime.” He adds: “This is a really deep topic, and we’re not going to attempt to dig too deep into it here. Instead, we’ll focus on the details necessary to implement our own Action Controller macros.”

Each recipe spans only a few pages but is presented clearly and is well illustrated with code examples.

Anyone working with Rails or still adding it to their programming capabilities should consider getting Rails Recipes: Rails 3 Edition and keeping it within easy reach.

Si Dunn

Ride Some Rails with The Rails View – #bookreview #in #rails #programming

The Rails View: Create a Beautiful and Maintainable User Experience
John Athayde and Bruce Williams
(Pragmatic Bookshelf, paperback, list price $35.00)

Rails was created in 2004 “and the web discovered the MVC (model-view-controller) pattern in earnest, which brought a whole new level of productivity and fun to a world of developers and designers,” the authors of this “very ambitious” book declare.

They note that many books “provide a firm foundation for writing controllers and models (which benefit greatly from being written top-to-bottom in plain Ruby), but when it comes to views—that meeting place of Ruby, HTML, JavaScript, and CSS (not to mention developers and designers)—what’s a disciplined craftsman to do?”

Athayde and Williams have written this views-centric book to help “widen the discussion of Rails best practices to include solid, objective principles we can follow when building and refactoring views.”

They add: “Many developers are uneasy around the view layer” and frequently in a hurry to just get out of it, leaving it “easy for the view layer to become a no-man’s land that no one owns or adequately polices or a junkyard that no one feels safe to walk through.”

The 245-page book’s nine chapters are well-written and adequately illustrated with code examples, screen shots and other illustrations, including highlighted tips.

The book follows a structure where chapters build upon the content of the previous chapter. The chapters are:

  • Creating an Application Layout
  • Improving Readability
  • Adding Cascading Style Sheets
  • Adding JavaScript
  • Building Maintainable Forms
  • Using Presenters
  • Handing Mobile Views
  • Working with Email
  • Optimizing Performance

One of the appendices is titled “The Rails View Rules.” It is a handy list of 10 “rules of thumb” when doing development work.

The book is aimed mostly at designers working with Rails and Rails developers working in the view layer. But newcomers curious about Rails or just getting started with Rails can learn from it, too.

The Rails View was built on top of Rails 3.2.1 and Ruby 1.9.3 and should be compatible with future stable releases for quite some time,” the authors say.

If you try to use earlier versions, you may run into some problems, they caution. “Much of the content and code would need to be modified to work with some earlier versions due to our coverage of the Rails 3.1+ asset pipeline and use of the new Ruby 1.9 Hash literal syntax.”

Si Dunn