[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

embeding ruby into a MacOS X ruby app

pere.noel

1/15/2006 3:15:00 PM


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 ?
--
une bévue
5 Answers

Andreas Schwarz

1/15/2006 3:57:00 PM

0

Une bévue schrieb:
> 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'

pere.noel

1/15/2006 4:56:00 PM

0

Andreas Schwarz <usenet@andreas-s.net> wrote:

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


--
une bévue

pere.noel

1/15/2006 4:56:00 PM

0

Andreas Schwarz <usenet@andreas-s.net> wrote:

> 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...
--
une bévue

pere.noel

1/15/2006 8:59:00 PM

0

Andreas Schwarz <usenet@andreas-s.net> wrote:

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

-I appends the directories list to the internal $LOAD_PATH

--
une bévue

curtis.schofield@gmail.com

1/16/2006 11:47:00 PM

0


at run time..

$:.push("IncludePath")