embeding ruby into a MacOS X ruby app

U

Une bévue

i'd like to embed ruby 1.8.4 and dependencies :
'iconv', 'osx/aeosa', 'xml/smart' ans 'xml/xslt'.

into a Ruby app working on MacOS X.

i've a installed ruby, osx/aeosa, xml/smart and xml/xslt in a folder
"RubyEmbeded".


if i move this folder down to another folder "MacOS", for example, i get
errors like :
AddressBook2vCardXml.rb:3:in `require': no such file to load --
osx/aeosa (LoadError)
from AddressBook2vCardXml.rb:3


then, if i change the require line from :

require 'osx/aeosa'

to :

require '../lib/ruby/site_ruby/1.8/osx/aeosa'

(the relative path)

i get other errors :

.../lib/ruby/site_ruby/1.8/osx/aeosa.rb:10:in `require': no such file to
load -- osx/aeosa/aeosa (LoadError)
from ../lib/ruby/site_ruby/1.8/osx/aeosa.rb:10
from AddressBook2vCardXml.rb:3


i don't want to change all of ther require statement within the
dependencies.


i don't want also to install this ruby + dependencies into /ur/local nor
/opt/local

because i want the app to be trashable by drag'n drop...


then how could i solve the relative path probs ???

what is the mecanism for ruby to retrieve internal paths ?
 
A

Andreas Schwarz

Une said:
i'd like to embed ruby 1.8.4 and dependencies :
'iconv', 'osx/aeosa', 'xml/smart' ans 'xml/xslt'.

into a Ruby app working on MacOS X.

i've a installed ruby, osx/aeosa, xml/smart and xml/xslt in a folder
"RubyEmbeded".


if i move this folder down to another folder "MacOS", for example, i get
errors like :
AddressBook2vCardXml.rb:3:in `require': no such file to load --
osx/aeosa (LoadError)
from AddressBook2vCardXml.rb:3


then, if i change the require line from :

require 'osx/aeosa'

to :

require '../lib/ruby/site_ruby/1.8/osx/aeosa'

(the relative path)

i get other errors :

Try this:
$LOAD_PATH = __FILE__ + '/RubyEmbed'
 
U

Une bévue

Andreas Schwarz said:
Try this:
$LOAD_PATH = __FILE__ + '/RubyEmbed'


ok, i see, here is more about my file structure :

RubyEmbeded/
app/
AddressBook2vCardXml.rb
run.zsh //<<== the app launcher
xml2html.rb
bin/
ruby
gem*
lib/
libruby-static.a
ruby/
["same" dir structure as in /usr/local/lib/ruby]


i want to change that to :

MacOS/
AddressBook2vCardXml.rb
run.zsh //<<== the app launcher
xml2html.rb
bin/
ruby
gem*
lib/
libruby-static.a
ruby/
["same" dir structure as in /usr/local/lib/ruby]

in order to be compatible with MacOS X app bundle structure...

the line :
$LOAD_PATH = __FILE__ + '/RubyEmbed'
as to be etup in my launcher script (zsh) ?

thanks a lot for yuor reply ;-)
 
U

Une bévue

Andreas Schwarz said:
Try this:
$LOAD_PATH = __FILE__ + '/RubyEmbed'

if i put that in one of my ruby script i get :
AddressBook2vCardXml.rb:8: $LOAD_PATH is a read-only variable
(NameError)


however i think i'm starting to understand how it works because after
changing "RubyEmeded" to "MacOS" and printing out :

p $LOAD_PATH
(from one of my ruby script) i get :
["/Users/yvon/work/RubyEmbeded/lib/ruby/site_ruby/1.8",
"/Users/yvon/work/RubyEmbeded/lib/ruby/site_ruby/1.8/powerpc-darwin8.4.0
", "/Users/yvon/work/RubyEmbeded/lib/ruby/site_ruby",
"/Users/yvon/work/RubyEmbeded/lib/ruby/1.8",
"/Users/yvon/work/RubyEmbeded/lib/ruby/1.8/powerpc-darwin8.4.0", "."]

(this is after the change from "RubyEmbeded" to "MacOS")

the $LOAD_PATH is in absolute form

then, i need a way to change this $LOAD_PATH from zsh script...
something related to `pwd` in which case the app could be moved from
folder to folder (as usual over MacIntosh) without effect...
 
U

Une bévue

Andreas Schwarz said:
Try this:
$LOAD_PATH = __FILE__ + '/RubyEmbed'

thanks a lot Andreas, i've found i way to do it, using your advice, here
it is :

----------run.zsh-------------------------------------------------------
PWD=`pwd`
RED=$PWD/..
export RUBY=$PWD/../bin/ruby
export RUBYOPT=
export
LOAD_PATH=$RED/lib/ruby/site_ruby/1.8:$RED/lib/ruby/site_ruby/1.8/powerp
c-darwin8.4.0:$RED/lib/ruby/site_ruby:$RED/lib/ruby/1.8:$RED/lib/ruby/1.
8/powerpc-darwin8.4.0
$RUBY -I $LOAD_PATH AddressBook2vCardXml.rb
$RUBY -I $LOAD_PATH xml2html.rb $HOME
 

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,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top