Client Server Applications With Sinatra And Mac Ruby


Published on

Topic I presented on June 29th, 2009 at the Amsterdam.rb BarCamp, one of the side-events organized by Kings of Code 2009.

Published in: Technology, Education
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Client Server Applications With Sinatra And Mac Ruby

  1. 1. Client-Server applications with Sinatra and MacRuby JULIO JAVIER CICCHELLI Software & Web Engineer @ Rock & Code
  2. 2. Why I want to talk about this? Interesting new technologies and tools. See for yourself how the future of Ruby will be. Documentation is not usually complete. Example source code are vague and pointless. It’s always nice to do a little bit of R&D yourself!
  3. 3. Ok, here’s the problem! I’m an avid collector (LP records, DVDs, Games, etc.) I can’t never remember everything that I have. I want to store the information on a database. I’m too lazy to fill in information for every field! I like simple but beautiful User Interfaces.
  4. 4. So many choices to make! Architecture: SOA, Client-Server, Distributed, etc. Web Services: SOAP, REST. Databases: MySQL, PostgreSQL, SQLite3, DB2, CouchDB, etc. Ruby Interpreters: MRI, JRuby, MacRuby, IronRuby, Rubinius, etc. Ruby Web Frameworks: Rails, Merb, Sinatra, Ramaze, etc. Ruby UI Frameworks: FxRuby, QtRuby, GTK, Cocoa, HotCocoa, Shoes, etc. Delivery formats: HTML, XML, JSON, YAML, WAP, etc.
  5. 5. My best solution...?!?! Centralized RESTful Web Service that manages the information given to and provided by clients anywhere. Architecture is 100% supported by the Web infrastructure. Sinatra implements the Web Service and interacts via REST with both the CouchDB database and the Clients. MacRuby implements nice UI (if you’ve a Mac, of course!) due to the full access to the Cocoa Framework.
  6. 6. What’s REST? Representational State Transfer Protocol that is client-server, stateless, cacheable, layered. Use of resources through an URI (global identifier) A minimal set of HTTP operations: GET, POST, PUT, DELETE Example: WWW
  7. 7. What’s CouchDB? Document-oriented database stored as JSON documents. Written in Erlang. Views: aggregate functions and filters. Exposes a RESTful HTTP API for connections. Benefits: extreme Scalability and easy Deployment.
  8. 8. What’s CouchRest? RESTful CouchDB Ruby interface. Ruby gem. Wraps CouchDB’s API, JSON serialization, URI memorization. Object-Mapper agnostic. Easy applications/frameworks-specific object oriented API
  9. 9. What’s Sinatra? DSL for creating Web Applications and Services effortlessly. Ruby gem. Minimal features set, it assumes that your application is written in Ruby and that have URLs. Maximum flexibility and control over the code. Not Another MVC web framework!
  10. 10. Coding my Web Service! Erlang and CouchDB haven’t been compiled yet (CouchDBX). Record class CouchDB mapping is simple (CouchRest). Sinatra RESTful implementation is straight-forward. CouchDB’s views are still not clear to me. Let’s examine some Code!
  11. 11. What’s MacRuby? Ruby 1.9 running on top of CoreFoundation framework, Objective-C common runtimes and Garbage Collector. Ruby classes and instances are either Objective-C wrappers or re-implementations on top on their Cocoa equivalents. Full access to the Objective-C class hierarchy and frameworks. Is not a Bridge to the Ruby 1.9 interpreter.
  12. 12. What’s Amazon ECS? RESTful HTTP API provided by Amazon. Full access to the Amazon products database. XML is used as a delivery format. Excellent example of a complex RESTful API.
  13. 13. Coding my Desktop Client! MacRuby is still not mature enough. I’ve never got along with the Cocoa Framework... until now! Let’s examine some more code!
  14. 14. What are the next steps? Web Service Generalize the Model object to support several kinds of collection items. Desktop Client Update IKImageBrowserView instance into CovertFlow. Rewrite the User Interface in HotCocoa. iPhone Client
  15. 15. So... what’s my point? Lose the fear for empiricism. Test the boundaries of new technologies and tools by applying them to specific real problems. Ruby beyond Rails. Inspire you!
  16. 16. You MUST check them out! Sinatra Micro-Framework MacRuby CouchDB
  17. 17. Contact me if anything! Mail Twitter LinkedIn Github Rock & Code
  18. 18. Now... let’s discuss!