Book Image

Ruby on Rails Web Mashup Projects

Book Image

Ruby on Rails Web Mashup Projects

Overview of this book

Table of Contents (14 chapters)
Ruby on Rails Web Mashup Projects
Credits
About the Author
Acknowledgements
About the Reviewer
Preface

Web mashups


Welcome to the world of web mashups! A web mashup is a new type of web application that uses data and services from one or more external sources (usually from the Internet) to build entirely new and different web applications. This book shows you how to write web mashups using Ruby on Rails—the new web application development framework.

The idea of taking data and services from various places and making them available in a single application is not new. Data feeds such as RSS and ATOM feeds have been around for a while, making information available for anyone to re-use in another application. Screen scraping was a commonly used older technology that takes content directly from another application's display. Portals where different data and services were aggregated into portlets and displayed on the portal were popular during the dot-com era. What's so different about web mashups?

The answer is that while older data and service aggregation technologies aggregate and integrate in a fashion, a true web mashup creates a completely different and new function out of the existing content and services, driving different purposes and objectives.

The word mashup itself comes from the world of hip-hop music, where two or more songs are mixed together to form a new song. Web mashups are primarily web applications (though it is not a strict requirement). Web mashups also usually mash up data and services that are available on the Internet—freely, commercially or through other partnership agreements. The external sources that a mashup uses are known as mashup APIs.

Ruby and Ruby on Rails

Ruby is a dynamic, object-oriented programming language that is highly suitable for integrating various pieces of data and software together:

  • Ruby is designed for programmer productivity and can be used to quickly develop maintainable pieces of software.

  • Ruby is interpreted in real time, meaning that whatever is coded can be executed immediately without compilation.

  • Ruby has a significant number of libraries that can be easily re-used through the gem packaging mechanism.

Ruby on Rails is an open-source full stack web application framework built on Ruby. Ruby on Rails follows two basic guiding principles—Convention over Configuration and Don't Repeat Yourself (DRY).

Convention over Configuration is a programming design that favors following a certain set of programming conventions instead of configuring an application framework. Certain commonly used configurations (by convention and not by rule) are pre-set and the framework just works if you follow those conventions. For example in Ruby on Rails, the convention states that a controller for a model object Book will be called BookController and all view pages relating to that controller will be kept in a folder called book.

DRY is a principle that focuses on reducing information duplication by keeping any piece of knowledge in a system in only one place. For example, in ActiveRecord (a major component of Ruby on Rails), schema information doesn't need to be duplicated in complex XML configuration files but is derived from the database schema itself. If the schema changes, the model changes accordingly, without the need to make changes in other parts of the system.

All this translates into a highly productive development framework in which web applications can be developed, deployed, and maintained easily. This framework, coupled with the fact that it uses Ruby, makes it an excellent platform for developing web mashups.

Note

For more in-depth discussion into Ruby's capabilities I would recommend you look at Programming Ruby: The Pragmatic Programmer's Guide by Dave Thomas, Chad Fowler, and Andy Hunt as well as The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming by Hal Fulton.

The recommended reading for Ruby on Rails is Agile Web Development with Rails, Second Edition by Dave Thomas and David Heinemeier Hansson.

A note of caution here—this book is written with Rails 1.2.x in mind and the projects and examples in this book follows this version. There is no significant change in the projects though, if you choose to use Rails 2.x instead. As of writing, Rails does not work with Ruby 1.9. If you're a complete beginner with Ruby and Ruby on Rails I would recommend you flip through the books mentioned in the information box opposite before plunging into this one.