Page 1 of 1

Referencing a Ruby script

Posted: Sun Mar 01, 2009 8:06 pm
by TheBigDuck
I am using Rev to make an UI which then passes data via ARGV to a Ruby script.

I am using Ruby here because the external API I need is written in Ruby.

so I am using:

Code: Select all

put shell ("./ruby.rb" && item1 && item2 & " ") into field "results"
to pass data to Ruby and get data (usually confirmation) back.

Now this is working fine, but it requires that the Ruby file be in the same directory as the application.

Question: Is there a BETTER way to do this? Is there is a better way to send/receive data to this Ruby file?

Question2(Mac): How can I hide the Ruby.rb file within the .app package?

Posted: Mon Mar 02, 2009 12:50 am
by Mark Smith
You can either add the ruby script files in the standalone builder under the 'copy files' tab, or you can just copy them into the app bundle after building.

Best,

Mark

Ummm...

Posted: Mon Mar 02, 2009 12:59 am
by TheBigDuck
Hi,

Thanks for the response, but once I copy INTO the bundle, how do I make the shell call to it?

I tried

Code: Select all

put shell ("cd Application.app/MacOS/ | ./ruby.rb" ) into ....
or

Code: Select all

 put shell ("./Application.app/MacOS/ruby.rb") into ...
but that doesn't work.

Posted: Mon Mar 02, 2009 1:30 am
by Mark Smith
if you put it into myapp.app/Contents/MacOS/

then

put shell("ruby.rb") into.... should do it, since the default folder is now where the app's executable is.

the other way is to use the complete path which you can get with something like this in the mainstack script:

set the itemDelimiter to "/"
put the effective filename of me into tPath
put "ruby.rb" into item -1 of tPath
put shell(tPath && <params>) into ...

No....

Posted: Tue Mar 03, 2009 10:10 pm
by TheBigDuck
Mark Smith wrote:if you put it into myapp.app/Contents/MacOS/

then

put shell("ruby.rb") into.... should do it, since the default folder is now where the app's executable is.
No, sorry, that doesn't work. I get:

/bin/sh: line 1: test.rb: command not found

Further, to execute the Ruby script I need to preface it with ./
the other way is to use the complete path which you can get with something like this in the mainstack script:

set the itemDelimiter to "/"
put the effective filename of me into tPath
put "ruby.rb" into item -1 of tPath
put shell(tPath && <params>) into ...
I'l give this a try mate....