Run a Ruby script (.rbw) from a dock shortcut in Mac OS X (Leopard)?

K

kpkilburn

I can't seem to find out how to do this... Thanks for any help.

I have Ruby installed on my Mac (OS X Leopard) and it works fine from
the terminal window. I'd like to create a dock shortcut or be able to
just double-click the .rbw file to run it. When I click it, it just
brings up a window that shows the code rather than running it.

Is there a way to put a shortcut down in the dock so I can just click
it to run the particular Ruby script (or click it from within
Finder)?

Thanks.
 
T

Tim Hunter

I can't seem to find out how to do this... Thanks for any help.

I have Ruby installed on my Mac (OS X Leopard) and it works fine from
the terminal window. I'd like to create a dock shortcut or be able to
just double-click the .rbw file to run it. When I click it, it just
brings up a window that shows the code rather than running it.

Is there a way to put a shortcut down in the dock so I can just click
it to run the particular Ruby script (or click it from within
Finder)?

Thanks.

From the Finder, right-click and choose Get Info. On the Get Info
window, use Open with to associate .rb files with ruby. Use Change
All... to associate ruby with all .rb files.
 
T

Torli Birnbauer

Tim said:
From the Finder, right-click and choose Get Info. On the Get Info
window, use Open with to associate .rb files with ruby. Use Change
All... to associate ruby with all .rb files.

This looks fine, except you will not find ruby from within the "Choose
Other Application" window!? Tim, could you tell us how exactly did you
find Ruby there.

Thank you in advance.
Torli
 
M

matt neuburg

I have Ruby installed on my Mac (OS X Leopard) and it works fine from
the terminal window. I'd like to create a dock shortcut or be able to
just double-click the .rbw file to run it. When I click it, it just
brings up a window that shows the code rather than running it.

Try FastScripts Lite. It's free and gives you a menu of scripts, and you
can assign each script a keyboard shortcut. m.
 
T

Tim Hunter

Torli said:
This looks fine, except you will not find ruby from within the "Choose
Other Application" window!? Tim, could you tell us how exactly did you
find Ruby there.

Thank you in advance.
Torli

Well, rats. I can find ruby but OS X doesn't think it qualifies as an
"Application".

I suppose you could do something with Automator, but every time I start
up Automator it makes me want to scream :-(
 
V

Vince Angeloni

unknown said:
Is there a way to put a shortcut down in the dock so I can just click
it to run the particular Ruby script (or click it from within
Finder)?

Thanks.

You should save the file as a Ruby file, but it must be made
'executable' to run as a script and not open in Terminal. To do this in
terminal you need to use:

chmod 755 /path/to/your/file

This will keep it from opening in Terminal. But it won't be an
application, so I don't think you can put it in the dock where you want
it.

If you want an Application which you can put on the dock, then you will
need to wrap your script using Platypus
(http://www.sveinbjorn.org/platypus). Platypus can take ruby (and other
script langs) and create double clickable applications from them.

You can also save your script with a unique prefix and name which will
allow you to use Spotlight to run it. For example, save your script as
xxMyScript.rb and you can access it relatively quickly using Spotlight
in 10.5 (much slower and different key combinations on Tiger):

1) type cmd-spacebar to set focus to spotlight search field
2) type 'xx.MyS' and wait a sec for it to appear in the "Top Hit" of the
Spotlight search results
3) type return when you see it as the "Top Hit" and it will launch and
run.

hth

vince
 
L

Louis-Philippe

[Note: parts of this message were removed to make it a legal post.]

Well, rats. I can find ruby but OS X doesn't think it qualifies as an
"Application".
Well, it doesn't need to, the Terminal is an application, so given you put a
shebang line on top of your program and make your file executable it could
work... if you want to go arround having to change the file association for
ruby files, change the extension to .command and it will open up and execute
in the terminal.

this only solves half of the problem though, you can click it, but still
can't put it in the dock.

L-P
 
L

Louis-Philippe

[Note: parts of this message were removed to make it a legal post.]

ok, here is two quick options, both have limitations but they work to some
point:

if you don't need a terminal output for your app, create a folder hierarchy
around it to make it a ruby app like this:
appname.rb.app/Contents/MacOS/your_excutable_script.rb

the .rb.app seems to be the important detail not to forget in here.

or, if you need a terminal display for your app, you can always drop your
command (a said in my previous answer) in the document part of your dock
(if you are on Leopard) and then clicking it will open a terminal and run
it.

L-P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top