Transcript of "Client Server Applications With Sinatra And Mac Ruby"
Client-Server applications with
Sinatra and MacRuby
JULIO JAVIER CICCHELLI
Software & Web Engineer @ Rock & Code
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!
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 ﬁll in information for every ﬁeld!
I like simple but beautiful User Interfaces.
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.
My best solution...?!?!
Centralized RESTful Web Service that manages the information given to and provided by
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
Representational State Transfer
Protocol that is client-server, stateless, cacheable, layered.
Use of resources through an URI (global identiﬁer)
A minimal set of HTTP operations: GET, POST, PUT, DELETE
Document-oriented database stored as JSON documents.
Written in Erlang.
Views: aggregate functions and ﬁlters.
Exposes a RESTful HTTP API for connections.
Beneﬁts: extreme Scalability and easy Deployment.
DSL for creating Web Applications and Services effortlessly.
Minimal features set, it assumes that your application is written in Ruby and that have URLs.
Maximum ﬂexibility and control over the code.
Not Another MVC web framework!
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!
Ruby 1.9 running on top of CoreFoundation framework, Objective-C common runtimes and
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.
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.
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!
What are the next steps?
Generalize the Model object to support several kinds of collection items.
Update IKImageBrowserView instance into CovertFlow.
Rewrite the User Interface in HotCocoa.
So... what’s my point?
Lose the fear for empiricism.
Test the boundaries of new technologies and tools by applying them to speciﬁc real problems.
Ruby beyond Rails.
You MUST check them out!
Contact me if anything!
Rock & Code