Posts tagged with “macruby”

January 30 2012

scripting tip

This make much more sense (at least to me) than using the Applescript Editor’s dictionary
if only because it’s more in the same form as the Obj-C type specs..
I am trying to learn both MacRuby and Cocoa at the same time and finding a consistent style of header file helps a lot

from
F-Script/Documentation/SystemWideScriptingWithFScript/index.htm

F-Script is cool = Occupy the CPU!

To get more information about the scripting interface of an application, we can generate an Objective-C interface file (that is, a .h file) that describes the application scripting interface. This is done by using together the sdef (scripting definition extractor) and sdp (scripting definition processor) commands provided by Mac OS X . We first use sdef to asks an application for its scripting definition, and we then pass this definition to sdp to produce an Objectice-C interface file. For example, to get a detailed description of how iTunes can be controlled with the Scripting Bridge, we can execute the following command in a UNIX shell:

sdef /Applications/iTunes.app | sdp -fh —basename “iTunes”
This will create a file named iTunes.h. Here is a short extract of this file, as displayed by Xcode:

output text

The sdp command might not work well with some applications. In such cases, looking at the output of sdef can still provide useful information about an application interface.

this process will place a file in your home directory
with the name given in the “—basename”

then after that – here is a seperate way to see what the current methods available are

object.methods(true,true)

think here something like

#!/usr/local/bin/macruby
framework "ScriptingBridge"
puts "loaded ScriptingBridge"
itunes = SBApplication.applicationWithBundleIdentifier("com.apple.itunes")
puts itunes.methods (true,false).sort

will return the Macruby (ruby) methods

and the
“puts itunes.methods (false,true).sort” returns the scripting methods

#!/usr/local/bin/macruby
framework "ScriptingBridge"
puts "loaded ScriptingBridge"
itunes = SBApplication.applicationWithBundleIdentifier("com.apple.itunes")
puts itunes.methods (false,true).sort
itunes.run
puts "******"
puts "******"
puts itunes.currentTrack
12:43 AM | | 0 Comments | Tags:

use macruby in textmate

uugh this took too long to find

answer:

Install MacRuby

Go to TextMate->Preferences->Advanced->Shell Variables and add a variable named TM_RUBY set to /usr/local/bin/macruby.

from:
http://stackoverflow.com/questions/4909335/how-do-i-get-textmate-to-use-macruby

12:32 AM | | 0 Comments | Tags: