From: BG - Ben Armstrong Date: 2005-01-20T03:06:11+09:00 Subject: Re: File naming conventions On Thu, 2005-01-20 at 02:46 +0900, Robert Klemme wrote: > File system portability: there are file systems out there that think > "foo.rb" is the same as "Foo.rb". Thanks so much for pointing that out. As OpenVMS Ruby users (using the ODS-2 filesystem,) we had to hack rubicon in the following fashion to work around a file casing problem that breaks on our platform: --- ../rubicon_cvs/rubicon_tests.rb 2004-11-30 08:22:14.000000000 -0400 +++ ./rubicon_tests.rb 2005-01-11 14:45:08.000000000 -0400 @@ -434,13 +437,32 @@ @files << fileName end + def classEach + list=[] + ObjectSpace.each_object(Class){|aClass| list << aClass} + list.sort{|a,b| a.to_s.upcase <=> b.to_s.upcase}.each{|entry| yield entry.to_s} + end + + def casedClassName(name) + upcasedName=name.upcase + cased=nil + classEach{|className| cased=className if className.upcase==upcasedName} + cased + end + def run Test::Unit.run = true @files.each do |file| require file - className = File.basename(file) - className.sub!(/\.rb$/, '') + # On systems which don't support mixed case filenames + # (principally VMS) the uncasedClassName will not match + # the casing of the actual class name. On such systems, + # casedClassName() ensures the filename is matched to a + # class of the same name already loaded into object space. + uncasedClassName = File.basename(file) + uncasedClassName.sub!(/\.rb$/, '') + className = casedClassName(uncasedClassName) klass = eval className runner = TestRunner.new(klass.suite, Test::Unit::UI::SILENT) #TestRunner.quiet_mode = true Thus, it is a bad idea from a portability perspective to write code such that the case of the filename conveys meaning. Ben