Deploying "double-clickable" ruby scripts on OSX

I have a menu driven ruby script to copy some files from servers to
local machines.

I’d like to be able to deploy this to OSX users in as pain-free a way as
possible… preferably they could just double click the script and have
it launch in Terminal and do its thing.

I’ve tried accomplishing this a few different ways and ran into some
problems. Here’s a quick breakdown:

  1. Tried associating “” to .rb files via the OSX Get Info
    dialog and adding a reference to the ruby shell at the top of the
    script. This works, but the script needs to reference its current
    location via the Dir.getwd method and this method always returns the
    users Home folder (regardless of the scripts actual location) when it is
    ran this way.

  2. Tried simply renaming the script and giving it the ‘.command’
    extension along with a reference to the ruby shell. This works, but has
    the same problem as associating .rb files to Terminal.

  3. Tried using script-to-app converters such as Platypus and ScriptGUI.
    Platypus doesn’t allow me to interact with my scripts menu and ScriptGUI
    is returning errors that I could maybe iron out, but it doesn’t really
    seem worth the battle.

Any ideas how to get around this problem? Seems like I might need to
find a different approach to getting the current working directory. I’d
just prefer not to go mucking around with those parts of the script as
they work fine on Windows and also when ran from Terminals command line
on OSX.

Instead of the cwd you seem to need File.dirname(FILE).

Top-posted from my iPhone

Xavier N. wrote in post #977824:

Instead of the cwd you seem to need File.dirname(FILE).

Top-posted from my iPhone

That works and is a very simple change, thank you!!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs