Thank you very much for your comments guys (and for not beating me for my stupid idea) ! ;-) I don't know why I started with this sockets thing (low-level performance seeking maybe ?)
Yes, I will move to "net/http" and "json" from Ruby stdlib (rather than implementing the http client myself). I will come back to share the code when it's ready. :-) Two good links I found on the topic : http://wiki.apache.org/couchdb/Getting_started_with_Ruby (what I was trying to achieve) http://www.youtube.com/watch?v=zEMfvCqVL4E (CouchDB & Ruby: you're doing it wrong by Tim Anglade) And by the way, I love the name ElephantOnCouch lol. On Tue, Nov 12, 2013 at 4:41 AM, Mark Deibert <[email protected]>wrote: > What is ElephantOnCouch?!?! There is zero info on the github. I'm very > intrigued... > > > On Mon, Nov 11, 2013 at 9:54 PM, Filippo Fadda < > [email protected]> wrote: > > > Just use PHP and ElephantOnCouch! :-) > > > > -Filippo > > > > On Nov 12, 2013, at 3:40 AM, Alexander Shorin wrote: > > > > > I wonder why you prefer to work with raw sockets instead of using one > > > of many available http clients for Ruby... > > > Just pick one that you like: > > > http://www.slideshare.net/HiroshiNakamura/rubyhttp-clients-comparison > > > To really work with simple rest api you don't need to reimplement > > > baseline things that have been already done and tested. > > > -- > > > ,,,^..^,,, > > > > > > > > > On Tue, Nov 12, 2013 at 5:40 AM, Sébastien Durand <[email protected]> > > wrote: > > >> Hi ! > > >> > > >> I want to use CouchDB for a Ruby project. I downloaded CouchRest, but > > this > > >> driver seems to be overkill for what I want : a simple REST API. > > >> > > >> So, is it wrong to design my own driver (using tcp sockets) ? Like > this > > : > > >> > > >> > > >> class CouchDB > > >> > > >> def initialize(database, host = 'localhost', port = 5984) > > >> @database, @host, @port = database, host, port > > >> end > > >> > > >> def get(uri) > > >> if block_given? > > >> yield get(uri) > > >> else > > >> socket = TCPSocket.open(@host, @port) > > >> request = "" > > >> request << "GET /#{@database}/#{uri} HTTP/1.0\r\n" > > >> request << "\r\n" > > >> socket.write(request) > > >> response = socket.read > > >> socket.close > > >> # TODO : parsing json > > >> end > > >> end > > >> > > >> end > > >> > > >> > > >> It's just a dead simple draft, it works, but what are the drawbacks ? > > Do I > > >> put myself in trouble ? (I don't have a deep tcp/http background and I > > fear > > >> it's not that simple.) > > >> > > >> Thank U for you help ! > > >> > > >> Sébastien > > > > >
