Referencing a Ruby script

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
TheBigDuck
Posts: 23
Joined: Tue Nov 11, 2008 5:52 pm
Contact:

Referencing a Ruby script

Post by TheBigDuck » Sun Mar 01, 2009 8:06 pm

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?

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Mon Mar 02, 2009 12:50 am

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

TheBigDuck
Posts: 23
Joined: Tue Nov 11, 2008 5:52 pm
Contact:

Ummm...

Post by TheBigDuck » Mon Mar 02, 2009 12:59 am

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.

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Mon Mar 02, 2009 1:30 am

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

TheBigDuck
Posts: 23
Joined: Tue Nov 11, 2008 5:52 pm
Contact:

No....

Post by TheBigDuck » Tue Mar 03, 2009 10:10 pm

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

Post Reply