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

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.

kpkilburn@gmail.com wrote:

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.

···

--
RMagick: http://rmagick.rubyforge.org/

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

···

<kpkilburn@gmail.com> wrote:

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.

--
matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
Leopard - http://www.takecontrolbooks.com/leopard-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com

unknown wrote:

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

···

--
Posted via http://www.ruby-forum.com/.

Thanks everyone. I'll give these a try.

Tim Hunter wrote:

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

···

--
Posted via http://www.ruby-forum.com/.

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

···

2009/3/22 <kpkilburn@gmail.com>

Thanks everyone. I'll give these a try.

Torli Birnbauer wrote:

Tim Hunter wrote:

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

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 :frowning:

···

--
RMagick: http://rmagick.rubyforge.org/

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

···

2009/3/23 Louis-Philippe <default@spiralix.org>

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
2009/3/22 <kpkilburn@gmail.com>

Thanks everyone. I'll give these a try.