Administrator
|
Squeakers,
I never want to leave my image!! That includes interacting with my web accounts (e.g. gmail, wordpress). I started using WebClient to access/script them in Squeak, but ran into SSL problems on the Mac. I switched to Ruby's Mechanize library, but as much as I was vibing with VI, the run-code cycle (yuck) and files (eww) were too much to bear. So I decided to wrap the library in Squeak. Where can I find examples/tutorials on how to do this? What advice do you have? My (possibly naive) plan is to: 1. write a Ruby app that includes the library and starts a socket server (done) 2. create classes in Squeak to mirror the library classes 3. use FFI to start the Ruby app (done) 4. send text commands via socket to do the real work in Ruby (proof of concept done) I got Ruby and Squeak talking through the socket, but wanted a sanity check before spending too much time. What do you think? Thanks. Sean
Cheers,
Sean |
You could look into implementing the Drb protocol in Squeak - this way, you'll only need to kickstart a Ruby process with Drb to be able to script Ruby from Smalltalk.
Another way to do this would be to look into using Maglev to bridge Smalltalk and Ruby. According to Konstantin Haase, it's possible to run a Pharo on a Maglev instance. Regards, Tim On Oct 29, 2010, at 12:46 AM, Sean P. DeNigris wrote: > > Squeakers, > > I never want to leave my image!! That includes interacting with my web > accounts (e.g. gmail, wordpress). I started using WebClient to > access/script them in Squeak, but ran into SSL problems on the Mac. I > switched to Ruby's Mechanize library, but as much as I was vibing with VI, > the run-code cycle (yuck) and files (eww) were too much to bear. So I > decided to wrap the library in Squeak. > > Where can I find examples/tutorials on how to do this? What advice do you > have? > > My (possibly naive) plan is to: > 1. write a Ruby app that includes the library and starts a socket server > (done) > 2. create classes in Squeak to mirror the library classes > 3. use FFI to start the Ruby app (done) > 4. send text commands via socket to do the real work in Ruby (proof of > concept done) > > I got Ruby and Squeak talking through the socket, but wanted a sanity check > before spending too much time. What do you think? > > Thanks. > Sean > -- > View this message in context: http://forum.world.st/Wrapping-Ruby-libraries-what-is-the-best-way-tp3018205p3018205.html > Sent from the Squeak - Dev mailing list archive at Nabble.com. > |
Am 2010-10-29 um 09:49 schrieb Tim Felgentreff:
> According to Konstantin Haase, it's possible to run a Pharo on a Maglev instance. > How should this possibly work? Doesn't he confuse connecting to a Stone (i.e. Maglev) using gemtools _in_ Pharo to run Pharo _on_ Maglev? So Long, -Tobias |
If you can use gemtools to connect to maglev, you can just use the ruby bridge, can't you?
On Oct 29, 2010, at 9:52 AM, Tobias Pape wrote: > Am 2010-10-29 um 09:49 schrieb Tim Felgentreff: >> According to Konstantin Haase, it's possible to run a Pharo on a Maglev instance. >> > How should this possibly work? > Doesn't he confuse connecting to a Stone (i.e. Maglev) using gemtools _in_ Pharo to > run Pharo _on_ Maglev? > > So Long, > -Tobias > > |
Administrator
|
In reply to this post by Tim Felgentreff
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
Cheers,
Sean |
Free forum by Nabble | Edit this page |