Ruby compiler for mac? - ruby

so I made a program in ruby (using FXRuby as well if that changes anything) and I was wondering how I would compile it so that another person could download and use the program? Thanks

You don't need to compile it you can just run it as a ruby script,
start your file with #!/path/to/your/ruby/interpreter/bin
after changing it to the appropriate file and it should just launch from the command line
$ chmod +x ./my_ruby_script
$ ./my_ruby_script
However if you are devloping a full fledged application in ruby for the mac then consider using MacRuby which provides ruby-cocoa bridge. It can be found here

Ruby is interpreted, not compiled. The code itself will be what runs on another person's computer, provided they have a Ruby interpreter.
A quick Google search, however, turned up this. I've never used it, but it's an interesting idea. Basically it wraps the Ruby application code with the executable(s) and library(s) needed to run it into one single all-encompassing application.

Related

Ruby and GTK3 without console window in background

Hello Stackoverflow user's. this is my first question. :)
I'm using ruby and gtk3 to make a few GUI's for scripts that I use a lot. The problem I'm having is that when I run the script it opens the console window as well as the GUI, which in my mind defeats the purpose of a GUI.
I'm currently trying to run the scripts by executing them on my desktop.
I tried packaging it inside OCRA but that generated a lot of errors. I don't mind packaging or running the script directly as long as it doesn't open a console window, or at the very least closes it when it launches.
I'm using windows, and ruby 2.0.x.
Basically I don't want a DOS console window to open when I run my script.
I'm intermediate with ruby so please, clear instructions and simple solutions.
Thanks in advance.
Found a simple solution. Save the script with .rbw extension instead of .rb extension.
Hopefully this will help other newbies.

Distributing ruby application as standalone in linux and windows

I have developed ruby application (desktop application) on version 1.9.1 with few gems(qtbindings). Now i would like to distribute my application to users as stand alone.I would like to distribute my application as stand alone in linux too. What is the best gem/script for doing this job.
Have a look at this link where several options are offered to distribute a Ruby script as a "native" executable.
Keep in mind that Linux users usually do not need this, bundle install and ruby myscript.rb is enough on those systems.
First define "stand alone," please. If you mean "I assume that you will have a suitable Ruby interpreter installed and on the PATH" then on Linux and other Unix-alikes it should suffice to add a shebang line at the top:
#! /bin/env ruby
and set the executable bits in the permission mask.
If you mean that your users may not have Ruby installed, and you don't want to make it a prerequisite, that's a much taller order and I have no advice.

Writing script that runs on Windows and Mac

I need to write a small script that renames some files in a directory. This script needs to be run on Mac and Windows.
What is the best scripting language for this? I want to write something that runs just by calling it and there is no need to install anything else.
For example, writing a Perl script and compiling it to run on Windows and then compiling it to run on Mac. Can I do this?
Any other, more elegant solution?
Nothing matches your criteria. You will need to install something (e.g. perl) if you want something that runs on both systems.
If you had perl on both systems, you could indeed write a program that runs on both. You wouldn't even need two binaries as you suggest since Perl programs are distributed as source. (perl compiles them when it loads them, and even then, they are compiled to the same form on all systems.)

bizarre behavior of system() in Ruby

I have set up shuffle_play.rb in Ruby by Example to work on Windows, with mpg123 instead of ogg123. The critical part is a method called play_file, which initially I wrote like this
def play_file(file)
system("mpg123 \"#{file}\"")
end
I have mpg123 in the same directory as my script ... it didn't work. But this does work:
def play_file(file)
system("mpg123.exe \"#{file}\"")
end
I reckon it's because I don't have working directory in %PATH% (and indeed the problem goes away when I add it) but even then I don't know enough about Windows to know the difference. Could someone explain the rationale for this?
Probably the examples assume that you're on a *nix variant such as Linux or Mac. In those Operating Systems, the program is called mpg123, because those OS, don't care about extensions, the just check that the file has an executable attribute
On windows things are very different. Windows decides if something is a program depending on the extension (.exe, .com, .bat, .cmd, etc.). So the program in windows has to be called mpg123.exe. If you open a command line on windows, you can run the program without specifying the extension, as windows automatically tries the different extensions. This behaviour of trying different extensions happens ONLY in the command line and not when you try to invoke a program from another one.
There a environment variable called PATHEXT that list in which order windows tries the different extensions. On my computer that list is:
C:\Windows\System32>echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW
I hope it was clear. And a suggestion if you want to code in ruby, install Linux or get a Mac.

Installing a perl application along with the supporting modules onto a Windows PC that doesn't have a compiler

I'm building a perl application that interacts with a PostgreSQL database via the DBD::Pg module, and that uses Perl/Tk for it's GUI. It works fairly well on my system, but I'm designing it for a family member to use for their business. They don't have a c++ compiler and don't have a clue what CPAN is. The goal is to not bog them down by having to load a c++ compiler and go to all of the trouble of building a module from source if I can avoid it.
I need to get the Tk module installed onto their computer along with Strawberry Perl (it includes DBD:Pg right out of the box). How do I go about including this module along with my application in order to make things easier on for my end user? Would simply copying my entire C:\strawberry\perl\site\lib\Tk folder into their computer during setup do the trick or does perl need more than that in order to use Tk and be happy with it?
Thanks for the help!
One way is to convert your application to an executable, using tools like perlapp, perl2exe, or par. If not, i think you can try Strawberry Perl portable versions.
You can use PAR::Packer module.
it generates exe on windows with a simple shell command.
> pp -o test.exe test.pl

Resources