Running Ruby Program from Mac OS X Desktop

A

Alex DeCaria

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?
 
A

Ari Brown

You need to use the command line. Open up Applications -> Utilities -
Terminal, and the type 'cd Desktop'. then type 'ruby YOUR PROGRAM'


HTH,
Ari


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?

-------------------------------------------------------|
~ Ari
crap my sig won't fit
 
J

John Joyce

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.
 
B

Bill Dolinar

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
 
1

12 34

Alex said:
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/
 
M

matt neuburg

Alex DeCaria said:
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.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top