Running Ruby Program from Mac OS X Desktop


#1

I have a Ruby program on my Mac desktop and when I double click on it,
it doesn’t run the program…it just opens up the text editor. How do I
make it run the program when I double click on it?


#2

You need to use the command line. Open up Applications -> Utilities -

Terminal, and the type ‘cd Desktop’. then type ‘ruby YOUR PROGRAM’

HTH,
Ari

On Jul 31, 2007, at 9:54 PM, Alex DeCaria wrote:

I have a Ruby program on my Mac desktop and when I double click on it,
it doesn’t run the program…it just opens up the text editor. How
do I
make it run the program when I double click on it?

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

-------------------------------------------------------|
~ Ari
crap my sig won’t fit


#3

You need to set the permissions to make it executable.
You may also need to use Get Info to set the app to open it with. If
so, try setting it to open with terminal.


#4

On Jul 31, 2007, at 7:54 PM, Alex DeCaria wrote:

I have a Ruby program on my Mac desktop and when I double click on it,
it doesn’t run the program…it just opens up the text editor. How
do I
make it run the program when I double click on it?

It kind of depends on what your looking for. If your wanting to run
a script that has text IO on screen then you would probably want to
run it through the terminal. If you want a GUI app then you probably
want to check out RubyCocoa (http://rubycocoa.sourceforge.net/). If
everything would happen in the background with no interface, it’s
possible to throw a ruby script in the application package and you
could double click on it to start the script. For an example Xcode
project check out http://billdolinar.com/files/SillyBalls.tgz. To
get the sample to run you build the project from Xcode and then go to
the “build/Release” folder within the project folder and double click
on the built app. The script that’s being run is in the SillyBalls
file. To have your script run in the background you would want to
turn on the LSBackgroundOnly property list key for the app bundle.

Bill


#5

Alex DeCaria removed_email_address@domain.invalid wrote:

I have a Ruby program on my Mac desktop and when I double click on it,
it doesn’t run the program…it just opens up the text editor. How do I
make it run the program when I double click on it?

You need to give the program the .command extension and set it to open
in the Terminal. Example:

#!/usr/bin/env ruby
puts “Hello, world!”

Save that as hello.command. Use the Terminal (or whatever) to make
hello.command executable by user. Use Get Info in the Finder to specify
that hello.command should open with Terminal.

That’s all. Now when you double-click hello.command in the Finder, it
will run in the Terminal:

mattneub$ /Users/mattneub/Desktop/hello.command; exit
Hello, world!
logout
[Process completed]

m.


#6

Alex DeCaria wrote:

I have a Ruby program on my Mac desktop and when I double click on it,
it doesn’t run the program…it just opens up the text editor. How do I
make it run the program when I double click on it?

Look at Platypus which does exactly what you want.
http://www.sveinbjorn.org/platypus

Also look at the Double-Clickable Example section in
http://www.macdevcenter.com/lpt/a/4954 which uses Pashua
http://www.bluem.net/downloads/pashua_en/.

I’ve started to put together some notes on this since I’ve been delving
into the same subject.
http://knobby.ws/wordpress/2007/07/30/easy-gui-for-ruby-on-a-mac-draft/