Appendix A. Scripting with MacRuby
Sometimes a window-based Cocoa application is too much for what you need to accomplish. Ruby developers are accustomed to using the language to write quick scripts that perform occasional lightweight tasks that don’t need a graphical interface. MacRuby is no different and lets you accomplish the same thing while being able to interact with Mac OS X applications that conform to Apple’s Open Scripting Architecture (OSA) through the Scripting Bridge framework.
AppleScript is Apple’s language for interacting with applications that are OSA compliant. For a long time, AppleScript has been the language of choice for scripting on the Mac. With Apple’s continued Ruby and MacRuby support, we wouldn’t be surprised to hear that MacRuby was AppleScript’s replacement. Throughout this appendix, you’ll learn more about AppleScript, Apple Events, and how to interact with other applications using MacRuby.
OSA allows for inter-application communication by using Apple Events. Apple Events are standardized data formats used to send information to compatible Mac applications. Until recently, most people used AppleScript to interact with Apple Events. Apple made all this available through the Scripting Bridge framework released with Mac OS X 10.5.