Skip to content

Commit

Permalink
Loading order of units is broken in Ruby 1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
esb committed Feb 24, 2012
1 parent c6eea95 commit 32a8d6f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/unit/system.rb
Expand Up @@ -45,7 +45,11 @@ def load(input)
load_factors(data['factors']) if data['factors']
load_units(data['units']) if data['units']

@unit.each {|name, unit| validate_unit(unit[:def]) }
@unit.each do |name, unit|
defs = unit.delete(:defs)
unit[:def] = parse_unit(defs) if defs
validate_unit(unit[:def])
end

true
end
Expand Down Expand Up @@ -151,7 +155,7 @@ def load_units(units)
name = name.to_sym
symbols = [unit['sym'] || []].flatten
$stderr.puts "Unit #{name} already defined" if @unit[name]
@unit[name] = { :symbol => symbols.first, :def => parse_unit(unit['def']) }
@unit[name] = { :symbol => symbols.first, :defs => unit['def'] }
symbols.each do |sym|
$stderr.puts "Unit symbol #{sym} for #{name} already defined" if @unit_symbol[name]
@unit_symbol[sym] = name
Expand Down

0 comments on commit 32a8d6f

Please sign in to comment.