Executable gem - Windows - ruby

I am trying to create an executable gem on windows machine. But i am not sure how do make the file executable in windows? Is there any way i can create the same on windows? Here is what i did so far: created a file and then right click and update the permission to read and execute. But its not working. I am keeping this file under bin folder as mentioned " here " in the link

A gem is not executable itself, it is a bundled collection of Ruby scripts and other files which can be executable. You can compare it with a Zip file.
The purpose is to easily distribute your projects tot other computers.
When you gem install the gem and require the gem in a script then you can use what the gem has to offer.
It is possible to execute the scripts and executable files when you use the full path in your console or when the path is included in the Windows path environtment variable. Sometimes a .bat or .cmd (in Windows) is provided that can be called but it just executes some other Ruby scripts.

Related

How can I make a gem perform an action on install?

Update:
Mainly, I need a .bat file to be placed in RUBY_HOME/bin, similar to how rails.bat gets placed in bin when the Rails gem is installed
I'm building a gem that can be used for generating automation test frameworks for testing web application written in any language, with any framework.
I need one file within my gem to be run every time the gem is installed. This file generates either a .bat or .sh file.
I have already built this script and it works great, I just need it be run each time the gem is installed using bundler. Is this possible?

Ruby gems path file on windows returns different path?

I am setting up a ruby script on windows (and I'm not a windows person) but I have run into the SSL problem. So I am creating a script to copy the correct PEM file into the ssl_certs directory. However, here is the problem I am running into.
The directory I am looking for is:
C:\Ruby21\lib\ruby\2.1.0\
But the command gem which rubygems returns:
C:/Ruby21/lib/ruby/site_ruby/2.1.0/
Is there a way to get the path to 2.1.0 without the site_ruby?
Or should I manually remove this from the path?

Using a Windows executable within a Ruby gem

I'm looking to include a Windows .exe in my gem and call on that executable from within the gem. All the suggestions I've seen for including executable in gems calls for a hashbang to indicate which program should run the executable (typically "#!/usr/bin/env ruby
"). I don't know of any program to call; I simply want to call the .exe. What would be the best way to do this?
Those are for *nix systems.
You can do
%x{full path to your .exe}
Use
$?
to get the exit status.
http://www.ruby-doc.org/core-1.9.3/Kernel.html
The hashbang can make a gem executable but isn't necessary to simply call the .exe within the gem itself. The calling module was in the gem's lib/ and the .exe in bin/. I was able to call the .exe from the ruby code with
exe_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "bin", "foo.exe"))
return_value = `#{exe_path}`
This works as long as you copy both lib/ and bin/ in the gemspec.

How execute a self contained rake build?

We have an application which is compiled using Rake (on windows). We have a new requirement that one of our clients needs to compile the source code in their own environment using a bat file.
So I need to find a way to execute a rake build without installing anything on the host environment (i.e. everything required to do the build needs to be in the source directory, ruby, gems, etc...) from a batch file.
Anyone have any clues how I could get started with this?
Download and install ruby to a folder inside your project (do not add it to your PATH). After go to this folder and delete any "uninstall" file. Go to the folder again with the console (cmd and then use cd path\to\ruby\folder) and run gem install ... to install everything you need. After add a .bat file to run your app. Something like:
#echo off
rubyfolder\bin\ruby.exe myscript.rb
This is a fully portable ruby installation, you can put it in any computer and it will work as well. (I use it as a portable ruby in my pendrive to let me play everywhere with ruby!)
PS.: rake is a script from bin, you can open it with:
rubyfolder\bin\ruby.exe rubyfolder\bin\rake

Install a Ruby located on local system using RVM

How would one install a Ruby VM (JRuby, Ruby MRI, etc.) on a machine that doesn't have internet access?
I'd like to just drop the tar.gz file somewhere that RVM is able to see (or checks before it goes out and tries to retrieve the package itself). Any ideas?
This blog post explains that you can drop the source archive in your $HOME/.rvm/archives directory.
cp ruby-enterprise-1.8.7-2010.02.tar.gz /home/minhajuddin/.rvm/archives
rvm install ree-1.8.7
Or the docs say that you can specify the archives directory from the command line:
--archives - directory for downladed files (~/.rvm/archives/)

Resources