Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Running Ruby Program from Mac OS X Desktop (http://www.velocityreviews.com/forums/t842906-running-ruby-program-from-mac-os-x-desktop.html)

Alex DeCaria 08-01-2007 01:54 AM

Running Ruby Program from Mac OS X Desktop
 
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 Brown 08-01-2007 02:15 AM

Re: Running Ruby Program from Mac OS X Desktop
 
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



John Joyce 08-01-2007 02:44 AM

Re: Running Ruby Program from Mac OS X Desktop
 
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.
On Jul 31, 2007, at 9:15 PM, Ari Brown wrote:

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




Bill Dolinar 08-01-2007 02:58 AM

Re: Running Ruby Program from Mac OS X Desktop
 

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




12 34 08-01-2007 04:00 AM

Re: Running Ruby Program from Mac OS X Desktop
 
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/3...n-a-mac-draft/
--
Posted via http://www.ruby-forum.com/.


matt neuburg 08-01-2007 05:35 AM

Re: Running Ruby Program from Mac OS X Desktop
 
Alex DeCaria <alex.decaria@millersville.edu> 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.

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


All times are GMT. The time now is 08:52 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.