rubycocoa embedded ruby interpreter.

E

Ezra Zygmuntowicz

rubies-


I have asked before but it got lost in the shuffle. I am working on
a bunch of rubycocoa apps for the newspaper I work for. And it is
time to deploy them on other machines. I would really like to be able
to embed the ruby interpreter binary and the libs I need inside of
the OSX .app executable. Does anyone out there know how this could be
done? Or maybe have already done so? SHould I be looking at
rubyscript2exe's osx support to see how that works?

I would really appreciate any direction on this as I am at a loss
and really need this functionality.

Thanks ever so much

-Ezra
 
S

Scott Willson

I "spiked" on this a while back. You have several options, especially
once you fire up Xcode.

Rubyscript2exe worked well the first time I tried it. I even threw
Rails + FXRuby at it. I followed the documentation and I had Windows
and OS X executables, as advertised. It even handled project-relative
file paths just fine.

Now, if I recall correctly, rubyscript2exe expands its contents into
a temp directory. That took a noticeable amount of time with my app.
I think it may need to repeat the expansion every time you launch the
app, but I could be wrong.

More recently, I tried rubyscript2exe again on the same app: more
code, but nothing else different. I kept running into "too many open
files." As far as I can tell, there is no fix or workaround on OS X.
The culprit is some rubyscript2exe file manipulation code. It does
look possible to debug and perhaps fix this code.

"Programming Ruby" (the pickaxe) chapter 21 is a good guide for
embedding Ruby. After some determined fiddling with Xcode, I was able
to write a simple nicely-packaged Cocoa app that called Ruby code.
Unfortunately, in my naive approach, Rails didn't load its required
files. I'm pretty sure that with a better understanding of Objective-
C, Xcode, and embedded Ruby, this approach should work just fine.

In the end, the FXRuby part of my app always runs on dev machines, so
I made a .term file that kicks off a bash script. That's really all I
need, though it bugs me that I don't have a nice icon on in the dock.

You may have an easier time of it with RubyCocoa, but then again, I
wonder if RubyCocoa embedded in a real Cocoa app might be like
putting two Siamese Fighting Fish in the same tank?

Hope that is of some help,
Scott
 
U

Une bévue

Jonathan Paisley said:
Please take a look at my little script which does this:

http://www.dcs.gla.ac.uk/~jp/standaloneify.rb

Fine, this isn't exactly my case, because my app isn't a cocoa one (no
ui but bundled with a plist).

For the time being i'm including, within my app, nearly all of the ruby
1.8.4 hierarchy, i've build in my HOME, a special ruby hierarchy to be
embeded.

basically my requires are :

require 'osx/aeosa'
require 'xml/xslt'
require "iconv"
require 'rexml/document'
include REXML

Do you think your script "standaloneify.rb" could be of any help ?

Apart ruby in HOME, i'm using a 1.8.4 ruby within the prefix :
/usr/local

with your script, do you i can embed the latest in my app ?

Here is the directory structure of my app :

/path/to/AB2Web.app/
Contents/
Info.plist
PkgInfo
Resources/
AB2Web.icns
MacOS/
AS/ // applescripts folder
bin/ // ruby bin folder
html/ // aux. files
lib/ // ruby lib folder
rb/ // ruby scripts folder
run // app launcher (zsh script)
xml/ // aux. files
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top