Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Ruby Script to .exe
Index -> Programming, Ruby -> Ruby Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
[Gandalf]




PostPosted: Fri Aug 26, 2005 2:54 am   Post subject: Ruby Script to .exe

Well, I finally got around to trying this out, and it works like a charm Smile.

All you need is a single ruby file, and you just add it before your own ruby program to compile:
code:
ruby rubyscript2exe.rb HelloWorld.rb

You have the option of adding some parameters if you like, but they are not neccessary as default is fine.

Anways, I was just going to ask someone to test out the .exe (someone who doesn't have Ruby installed) to see if it works. The final executable is smaller than a Turing executable, at least under windows - the following code "compiled" to 665kb as opposed to Turing's 709kb. I could probably minimize the by using some parameters though (not sure).

Ruby:
puts "Hello"
print "Enter your name: "
name = gets
puts "Hello, #{name}"
exit = gets


Attached is the exe .rar'ed.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Fri Aug 26, 2005 2:59 am   Post subject: (No subject)

Note: when you run "ruby rubyscript2exe.rb HelloWorld.rb", you're not passing "HelloWorld.rb" to ruby itself. You're passing it to the application created by running "ruby rubyscript2exe.rb".
Hikaru79




PostPosted: Fri Aug 26, 2005 8:15 am   Post subject: (No subject)

Works great for me Smile Now, what I'm curious about is, if you use some third-party libraries that you install, will it be smart enough to package those too by default, or do you have to manually specify those to the program?
wtd




PostPosted: Fri Aug 26, 2005 3:50 pm   Post subject: (No subject)

I would further suggest installing this via the gem.

Just:

code:
gem install rubyscript2exe.gem


Then you should just be able to call:

code:
rubyscript2exe HelloWorld.rb
wtd




PostPosted: Fri Aug 26, 2005 3:54 pm   Post subject: (No subject)

Hikaru79 wrote:
Works great for me Smile Now, what I'm curious about is, if you use some third-party libraries that you install, will it be smart enough to package those too by default, or do you have to manually specify those to the program?


code:
~/Desktop $ cat > hello.rb
def say_hello
   puts "Hello!"
end
~/Desktop $ cat > application.rb
require "hello"

say_hello
~/Desktop $ rubyscript2exe application.rb
Tracing application ...
Hello!
Gathering files...
Copying files...
Stripping...
Creating application_linux ...
~/Desktop $ ./application_linux
Hello!
~/Desktop $
[Gandalf]




PostPosted: Fri Aug 26, 2005 7:34 pm   Post subject: (No subject)

Well then looks good Smile.
Now I have to try some other things with it, like with that tar2rubyscript and some other things.

I noticed that although the executable is smaller than Turing's, the reason is that it is already heavily compressed, while Turing's is not. Therefore, if you try to compress the Ruby .exe, it will not seem as effective as with a Turing .exe.
wtd




PostPosted: Fri Aug 26, 2005 7:51 pm   Post subject: (No subject)

In an era of widespread broadband and large hard drives... does it really matter?
[Gandalf]




PostPosted: Fri Aug 26, 2005 8:08 pm   Post subject: (No subject)

Well... It's always nice to have something smaller. If I compiled my whole programming directory on this comp that would be a gigabyte instead of a managable 25mb of source. If I had each of those compressed though, that would be 4 times less to carry around, and 4 times faster to store, download, move, scan, or whatever you are doing.
There are also cases like when you have a cheap website, say 20mb, where having a 100kb file is better than a 1mb one.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Fri Aug 26, 2005 8:11 pm   Post subject: (No subject)

Then just store the Ruby script there and simply ask people to install Ruby. Smile
Tony




PostPosted: Fri Aug 26, 2005 8:33 pm   Post subject: (No subject)

[Gandalf] wrote:
Well... It's always nice to have something smaller.

Unless we're not talking about space your program takes up Laughing

Seriously though, just keep Ruby as is and let users install the interpreter. Not everybody can run .exe's anyways.
wtd




PostPosted: Fri Aug 26, 2005 8:41 pm   Post subject: (No subject)

Tony wrote:
[Gandalf] wrote:
Well... It's always nice to have something smaller.

Unless we're not talking about space your program takes up Laughing

Seriously though, just keep Ruby as is and let users install the interpreter. Not everybody can run .exe's anyways.


Indeed. You'd have to store versions for Windows, Linux, and Mac OS X, as well as probably having versions on hand for numerous other *nixes.
[Gandalf]




PostPosted: Sat Aug 27, 2005 3:41 am   Post subject: (No subject)

Laughing Well... Ya... It was in my comparison to Turing though, and the same applies to it.

I'm not going to be making commercial programs with it (obviously), but I just like to have the reassurance that I can use my program on another computer without installing Ruby.

Anyways, tomorrow I will try to learn a bit more Ruby to try and put all this to use Smile.
wtd




PostPosted: Sat Aug 27, 2005 3:52 am   Post subject: (No subject)

[Gandalf] wrote:
I'm not going to be making commercial programs with it (obviously)


Why not? Smile

Ruby's certainly capable.
[Gandalf]




PostPosted: Sat Aug 27, 2005 3:57 am   Post subject: (No subject)

It's myself that's not capable Wink.

No, but my point was that I will not be distributing my programs to many people in the near future, so it doesn't matter as much.
wtd




PostPosted: Sat Aug 27, 2005 4:15 am   Post subject: (No subject)

[Gandalf] wrote:
It's myself that's not capable Wink.


That'll change.
Display posts from previous:   
   Index -> Programming, Ruby -> Ruby Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: