Posts in Ruby
Rails Performance Optimization
Been doing some research and I found some good articles for Rails performance optimization. For those interested in such things, I thought I'd share:

Enjoy. And please, share some other links if you have em.
Build a list of all files in a directory structure in Ruby
When testing web services it's often nice to be able to process a set of XML files. In other automation it can be nice to process batches of files as well. For some reason I can never find the following code when I need it and I always have to re-code it from scratch. That's always good practice, but it's annoying when I need it quickly.


def getFiles(directory)
returnFiles = []
Dir.glob(directory + '/*').each do | file |
if File.file?(file) then
returnFiles.push(file)
else
returnFiles.push(getFiles(file))
end
end
return returnFiles
end



So there it is. Google can now help me find my code whenever I need to build a list of all files in a directory structure.

Here is an example of how I might use that:


getFiles("C:/Regression Files").each do | testCaseFile |
resultsFile.puts(testCaseFile.to_s.split('/')[-1].chomp +
', methodName, ' + object.methodName(testCaseFile))
end