lib/test_ids/allocator.rb in test_ids-1.1.0 vs lib/test_ids/allocator.rb in test_ids-1.1.1

- old
+ new

@@ -40,10 +40,14 @@ lines = File.readlines(file) # Remove any header comment lines since these are not valid JSON lines.shift while lines.first =~ /^\/\// && !lines.empty? s = JSON.load(lines.join("\n")) rangehash = s['pointers']['ranges'] - rangehash = Hash[rangehash.map { |k, v| [k.to_sym, v] }] + if rangehash.nil? + rangehash = store['pointers']['ranges'] ||= {} + else + rangehash = Hash[rangehash.map { |k, v| [k.to_sym, v] }] + end else # Create an alias for the databse that stores the pointers per range rangehash = store['pointers']['ranges'] ||= {} end # Check the database to see if the passed in range has already been included in the database hash