From: Dave Baldwin Date: 2005-04-28T17:05:48+09:00 Subject: Re: OSX drag and drop with ruby? On 28 Apr 2005, at 07:06, Logan Capaldo wrote: > On 4/27/05, tsuraan wrote: >> I'm wondering if there's a global variable or something that can tell >> if a ruby script was started by having a file dropped on its icon in >> the finder. I'm not even sure if drag and drop is the right term >> here, >> since I'm not actually planning on having a GUI; I just want a path to >> a file to operate upon. >> >> > > Well just for kicks I tried to figure out if there is one.... I then > discovered that double-clicking on ruby scripts doesn't execute > them... is there a setting for this? > Change it's extension name to command (i.e. test.rb becomes test.command) or change the application used to open the file to Terminal. You will also need the *first* line of the script to be #!/usr/bin/env ruby You will also need to make the file executable (chmod +x test.command) Now when you double click on the file it will launch and new terminal window and run the script. This will not allow you to drag and drop files onto the script as you will still need to flag which types of files can be dropped (I cann't help here). You may want to check out Platypus (http://sveinbjorn.sytes.net/platypus) as this will convert scripts to apps without using the terminal trick and also allows files to be dropped on the app. I have no experience in using it. Dave.