Windows Ruby

From Schmid.wiki
Jump to: navigation, search

Deploying a Local Ruby

To be able to use Ruby as a BATCH replacement for e.g. a company, we need to be able to run Ruby on machines that do not necessarily have Ruby installed.

Usually, this can be achieved with the Ruby bare essentials:

ruby.exe
msvcrt-ruby*.dll

So to deploy a set of ruby scripts on a Windows machine that doesn't have Ruby installed, a directory structure like the following could be used:

scripts/ruby.exe
scripts/msvcrt-ruby*.dll

scripts/some_ruby_class.rb  <- some class used by other scripts
scripts/popen4.rb           <- a rubygem

scripts/my_script.rb        <- main script #1
scripts/my_other_script.rb  <- main script #2

my_script.bat               <- launches scripts/my_script.rb
my_other_script.bat         <- launches scripts/my_other_script.rb

The launcher BATCH files could have a few different flavors, depending on your requirements.

Logging launcher:

@echo off

set SCRIPT_NAME=my_script

scripts\ruby -Iscripts scripts\%SCRIPT_NAME%.rb >%SCRIPT_NAME%.log 2>&1

Direct output launcher:

@echo off

set SCRIPT_NAME=my_other_script

scripts\ruby -Iscripts scripts\%SCRIPT_NAME%.rb
pause
Personal tools