User:CasaShea/Possibles/OCRA

From Helpful
Jump to navigation Jump to search

One-Click Ruby Application

Once you have the "Command prompt with Ruby" shortcut working (I believe it comes with Ruby for Windows), or something similar:

gem install ocra

You can also download a stand-alone from here, but I haven't played with that one at all.

After you have a working foo.rb (or .rbw):

ocra foo.rb

It will run the program once (to find dependencies) and then tell you some information about what it's doing. When it's done, you should have a brand new foo.exe waiting for you.

If your program does any input or output at all (like, you know, 99+% of all DOS/Windows programs), Ruby will await input and present output while OCRA is doing its thing. To prevent this, add the following line to the top of your program / right after entering your main loop / etc.:

exit if Object.const_defined?(:Ocra)


There are tons of options you can give ocra (list them by using ocra --help), but I haven't yet written anything complex enough to require them, sorry.