Listing 12-18. Access Data Loader (training_loader.rb)
require 'dbi'
require 'xmlsimple'
require 'yaml'
require 'open-uri'
require 'swin'
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.microsoft.com/en-us/library/ms646949.aspx
# You can find the header file with the full list of constants
# here:
# http://doc.ddart.net/msdn/header/include/commdlg.h.html
CHAPTER 12 n CREATING REPORTS WITH RUBY AND MICROSOFT OFFICE 251
OFN_HIDEREADONLY = 0x0004
OFN_PATHMUSTEXIST = 0x0800
OFN_FILEMUSTEXIST = 0x1000
filetype_filter =[['Access Database (*.mdb)','*.mdb'],
['All files (*.*)', '*.*']]
database_path = SWin::CommonDialog::openFilename(
nil,
filetype_filter,
OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST |
OFN_FILEMUSTEXIST,
'Choose a database')
exit if database_path.nil?
end
begin
domain = '127.0.0.1'
port = '3000'
xml = open("http://#{domain}:#{port}/log/all").read
grades = XmlSimple.
Pages:
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360