In fact, it will work even if you install it on a machine
without Ruby installed, although you would need to change the hard-coded server
address in the script, since it always looks for a Rails application running on localhost.
You could store the information in a text file or in the Windows registry if you wanted.
CHAPTER 12 n CREATING REPORTS WITH RUBY AND MICROSOFT OFFICE 255
nNote The reason the call includes the reference to the database is that when you use rubyscript2exe,
it runs the program once to determine the required libraries. However, the database driver won??™t be loaded
until the connection to the database is made, and if you don??™t run the script until that point, the driver won??™t
be included.
Let??™s examine the code line by line.
Dissecting the Code
First, the loader script (Listing 12-18) checks to see whether a database was passed on the
command line:
database_path = ARGV[0]
unless database_path # If no path was specified on the command line,
# then ask for one.
# You can find out more about Windows common dialogs here:
# http://msdn2.
Pages:
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364