ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Replacing AppleScript with Ruby
Subject:   passing requests from applescripts to rb-appscripts
Date:   2008-04-08 11:21:34
From:   mattneub
Response to: passing requests from applescripts to rb-appscripts

Hi, gauvins -


I'm not sure why you'd want to do this; the whole point of my article here is that you can just start in Ruby and stay in Ruby, and never use any AppleScript code at all. However, my book explains about calling Perl, Ruby, etc. from AppleScript and vice versa. Here is a simple example.


Ruby file /Users/mattneub/Desktop/test.rb:


puts $*[0].reverse


AppleScript code:


set f to "/Users/mattneub/Desktop/test.rb"
set s to "ruby " & quoted form of f & space & quoted form of "Hello, World!"
do shell script s -- result: "!dlroW ,olleH"


Here is another example.


Ruby file /Users/mattneub/Desktop/test.rb:


require "appscript"
include Appscript
puts app('Finder').name.get


AppleScript code:


set f to "/Users/mattneub/Desktop/test.rb"
set s to "ruby " & quoted form of f
do shell script s -- result: "Finder"
That should get you started.



1 to 1 of 1
  1. passing requests from applescripts to rb-appscripts
    2008-04-08 16:23:08  gauvins [View]

1 to 1 of 1