To use Ruby's Mechanize gem, I just wrote a small Ruby script that allows messages to be sent to Ruby objects. It runs an augmented XMLRPC server that caches non-XMLRPC Ruby objects and passes back an identifier to Smalltalk.
Here's a snippet of my post to squeak-dev. All of the messages return proxies to Ruby objects, except the last, which returns an array of strings. Check the "Wrapping Ruby libraries - what is the best way?" thread for more info... ...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 HTH, Sean -- View this message in context: http://forum.world.st/Pharo-and-Astronomy-tp3027615p3029271.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
