Making executable file from Ruby program - ruby

I wrote a program in Ruby but I want to make an executable file from my program in order to run it in any computers( that they don't have ruby).How can I make executable file?
thanks

You could use RubyScript2Exe
http://www.erikveen.dds.nl/rubyscript2exe/
.. it collects all necessary files to run your application on an other machine: the Ruby application, the Ruby interpreter and the Ruby runtime library (stripped down for your application)

You should look at this list of options given your needs:
http://ruby-toolbox.com/categories/packaging_to_executables.html
They all have their strengths and drawbacks. NOTE: I have not used any of them.

Take a look on my rb2exe. It supports Rails and Gemfile.
gem install rb2exe
echo "puts 'Hello world'" > test.rb
rb2exe test.rb
./test
You can also check my detailed step-by-step how to, here:
http://www.learnwithdaniel.com/2016/08/ruby-to-portable-exe-app/

Related

How to use ocra to pack script using fxruby gem into executable?

I'm new to ruby and I'm trying to use ocra to pack a script that uses the fxruby gem to create a GUI, however, my command creates an executable that doesn't perform any action, this is the command I'm using:
ocra --no-enc --no-dep-run --gem-full --add-all-core table.rbw
Can anyone tell me what I'm doing wrong? I've searched the internet but couldn't find any useful info, any help is much appreciated.
Are you trying to generate an *.exe for Windows?
I have some scripts that also use FX and they run nicely on Windows.
This is how I generate the file:
ocra MyScript.rb --gem-all --windows
You can also try
ocra --help
And this will display all the parameters available.

RSpec basics: bin/rspec --format doc

I've installed RSpec on a win7 lappy and am following along the http://rspec.info/ homepage tutorial to make sure everything works. If I am reading their demo correctly bin/rspec --format doc should run the specification test file.
Instead, I get a system prompt for a text editor... ? I am confused.
Any explanation of what is going on or guidance about how to get my RSPEC configuration working in accordance to the makers homepage would be great.
FWIW Ruby 2.2.5p319, Bundler version 1.13.1 and gem -v tells me 2.6.7 (originally I had 2.4 but that is broken on windows, so I upgraded according to http://guides.rubygems.org/ssl-certificate-update/) Also, I have basic RSpec functionality and have completed the tutorial here: https://www.tutorialspoint.com/rspec/rspec_writing_specs.htm
Ah, I figured out what I need to do... I just need to explicitly call ruby:
ruby bin/rspec --format doc
...and the test gets run - YaY!
Per #JörgWMittag, I confirmed my Environment Variable Path to make sure ruby.exe was in there (C:\Ruby22\bin;).
Then looking at my Program Defaults, I thought that maybe I could tell win7 to associate any file named "rspec" with ruby.exe per https://support.microsoft.com/en-us/help/18539/windows-7-change-default-programs ...but I couldn't actually add file type "extensions" or "protocols" - I could only change the association of existing ones, but .rb and .rbw were in there... Maybe there is a way to do this manually, but I am not a windows expert.
Thinking on all this it occurred to me that I just needed to explicitly tell ruby to ingest the command... Heh.
I apologize if this is off-topic.

How can I make executables included in a Ruby gem runnable on Windows?

I have a Ruby gem with some scripts that are distributed as executables. On Linux, this means that they go on the PATH with the executable bit set when the gem is installed. But on Windows, I don't see that or anything equivalent. So, how can I make those scripts usable from the command line on Windows?
I noticed that the Gem::Installer package has a generate_windows_script command, which from the brief description appears to match what I'm trying to do. Can I use that to help here, and if so, how?

How do i get list of all installed packages in ruby 2.0.0

I want to get list of all installed packages on my machine using ruby gem or plugin. Functionality is similar to dpkg -l command on ubuntu. Is there any appropriate ruby gem or plugin available to get the same?
If you mean Ruby gems, then
gem list
You can execute a shell command inside the ruby interpreter. In your case, simply run
`dpkg -l`
The output will be a string containing the output of the command. Please note the `.
Keep in mind there are several ways to perform a shell command in Ruby.
There is a Debian package called ruby-debian (in older Debian releases it is called dpkg-ruby) which contains Ruby bindings to dkpg.
Note: it relies on a C extension, so it will not work on Ruby implementations that don't support them, such as IronRuby.

run all selenium ruby webdriver scripts at a time.

Currently, I'm running each my Selenium Ruby Webdriver script (*.rb) on Ruby command prompt window with the syntax, ex: ruby test.rb. It works well.
However, I also have some other scripts and now I want to run all scripts once instead of calling ruby test1.rb, then wait for this script done, then continue to run: ruby test2.rb.....then, ruby test3.rb.....
Anybody please guide me a way to run all scripts I created at a time? Thanks so much.
You can use the rake gem, for this you need to create a file named rakefile.rb, and paste the below content:
task :default do
FileList['file*.rb'].each { |file| ruby file }
end
Now call rake in your terminal, you should be good.
What about making a feature file and running the entire feature?
Just create a ruby file like this:
require './Test1.rb'
require './Test2.rb'
Run it and see the result

Resources