June 27, 2006

Week Four - Tuesday

I was afraid my plans to finally finish the Ruby/MySQL code were going to be delayed yet again; Anon was using Thanatos when I came in yesterday morning. It just so happened that he ended up leaving before I did, so I was able to do it after all. I'd gone ahead and written all of the code on my laptop while I was waiting, so really all that was left was to test it. This is, of course, the tricky part. I actually didn't have to change much, as it turns out. I did have to go through and add backticks in the appropriate places in the MySQL queries, but that wasn't too big of a deal. The most vexing problem by far was allowing for apostrophes in names and titles. On the surface, the fix seems easy: just use String's gsub method to insert a backslash escape in front of the offending punctuation. Problem is, the gsub method helpfully provides backslash sequences in substitution strings, and the sequence \' indicates "the part of the string after the match." So the regular expressions /\\'/ and /\\\'/ won't work. After a bit of head-scratching and a Google search, I found the solution: /\\\\\'/ (yes, five backslashes). I didn't really have time to test it last night, so I saved it for the morning.

The gsub fix proved adequate, but my test runs this morning revealed a slew of other niggling little problems. I've spent the better part of the day so far tracking down syntax errors and errant nil entries, but I think I'm almost done. I've put in a few more conditional statements to catch the nil entries, changed a couple of data types in the MySQL database, and made a couple of other little fixes that should solve most (if not all) of the problems. I still have to do a couple more test runs, but we should be ready to go by the end of the day. That's a relief. The test runs themselves are a bit tedious, given the sleeps in between queries. A run that makes only 60 queries will take at least two minutes, and even my abbreviated test cases make more queries than that.