minad/unit — pull request #21 by esb (2012-02-24 00:32:00+00:00)
Title: Loading order of units is broken in Ruby 1.8.7

The loading order of the unit definitions is important because one unit definition may refer to another unit definition, and the current load algorithm assumes the units are created in the order in which they are defined in the yaml file.

The load function uses a hash of unit definitions and under Ruby 1.9 the order of the hash keys is determined by the order in which they were created. Under Ruby 1.8, this order is undefined and it appears that until the recent changes to the hash algorithm this wasn't a problem, as the random order didn't cause any problems with undefined units. With the latest Ruby 1.8.7 release, this is no longer the case and the code breaks when it is loaded.

The solution is to load all unit definitions before attempting to parse them. This requires a simple change which defers the calling of the parse_unit function.