[squeak-dev] Re: Wrapping Ruby libraries - what is the best way?

Sean P. DeNigris sean at clipperadams.com
Sun Oct 31 10:47:14 UTC 2010



Tim Felgentreff wrote:
> 
> You could look into implementing the Drb protocol in Squeak.
> 

While I'm investigating this, I made a small Ruby XMLRPC server that caches
Ruby objects locally and sends an object ID to Smalltalk, which gets wrapped
in a RubyObject proxy.

It allowed me to wrap part of the Mechanize gem, and run the following code
in Squeak:
agent := Mechanize new.
loginPage := agent get: 'https://www.[a site here].com/home'.
loginForm := loginPage formWith: #action -> '/login'.
loginForm set: 'username' fieldTo: 'username'.
loginForm set: 'password' fieldTo: 'password'.
homePage := loginForm submit.
mailPage := agent get: 'https://www.[a site here].com/messages'.
messageLinks := mailPage linksWith: #href ->
'messages\?readmsg=true&threadid='.
messages := messageLinks collect: [ :link | link click body ].

All of those messages were handled by the generic server code on the Ruby
side except for mailPage linksWith:, which passes a Ruby regex, which is not
supported by XMLRPC.

Todo:
* still deciding how much info to bring over to Squeak and when e.g. just
the id, the inst vars, etc.
* extending XMLRPC to handle Squeak/Ruby common types, like symbols
* toying with the idea of using DNU to dynamically create the methods on the
ST side (hand-written for now)
* thinking about whether to look at OMeta or PetitParser

Thanks for the support.  I'll put the code on SqS if anyone's interested.
Sean
-- 
View this message in context: http://forum.world.st/Wrapping-Ruby-libraries-what-is-the-best-way-tp3018205p3021004.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.



More information about the Squeak-dev mailing list