lib/test_ids/allocator.rb in test_ids-0.5.0 vs lib/test_ids/allocator.rb in test_ids-0.5.1

- old
+ new

@@ -20,51 +20,48 @@ name = "#{name}_#{options[:index]}" if options[:index] store['tests'][name] ||= {} t = store['tests'][name] # If the user has supplied any of these, that number should be used # and reserved so that it is not automatically generated later - if options[:bin] + if options[:bin] && options[:bin].is_a?(Numeric) t['bin'] = options[:bin] store['manually_assigned']['bin'][options[:bin].to_s] = true # Regenerate the bin if the original allocation has since been applied # manually elsewhere elsif store['manually_assigned']['bin'][t['bin'].to_s] t['bin'] = nil # Also regenerate these as they could be a function of the bin t['softbin'] = nil if config.softbins.function? t['number'] = nil if config.numbers.function? end - if options[:softbin] + if options[:softbin] && options[:softbin].is_a?(Numeric) t['softbin'] = options[:softbin] store['manually_assigned']['softbin'][options[:softbin].to_s] = true elsif store['manually_assigned']['softbin'][t['softbin'].to_s] t['softbin'] = nil # Also regenerate the number as it could be a function of the softbin t['number'] = nil if config.numbers.function? end - if options[:number] + if options[:number] && options[:number].is_a?(Numeric) t['number'] = options[:number] store['manually_assigned']['number'][options[:number].to_s] = true elsif store['manually_assigned']['number'][t['number'].to_s] t['number'] = nil end # Otherwise generate the missing ones t['bin'] ||= allocate_bin t['softbin'] ||= allocate_softbin(t['bin']) t['number'] ||= allocate_number(t['bin'], t['softbin']) - t['bin'] = nil if t['bin'] == :none - t['softbin'] = nil if t['softbin'] == :none - t['number'] = nil if t['number'] == :none # Record that there has been a reference to the final numbers time = Time.now.to_f - store['references']['bin'][t['bin'].to_s] = time if t['bin'] - store['references']['softbin'][t['softbin'].to_s] = time if t['softbin'] - store['references']['number'][t['number'].to_s] = time if t['number'] + store['references']['bin'][t['bin'].to_s] = time if t['bin'] && options[:bin] != :none + store['references']['softbin'][t['softbin'].to_s] = time if t['softbin'] && options[:softbin] != :none + store['references']['number'][t['number'].to_s] = time if t['number'] && options[:number] != :none # Update the supplied options hash that will be forwarded to the # program generator - options[:bin] = t['bin'] - options[:softbin] = t['softbin'] - options[:number] = t['number'] + options[:bin] = t['bin'] unless options.delete(:bin) == :none + options[:softbin] = t['softbin'] unless options.delete(:softbin) == :none + options[:number] = t['number'] unless options.delete(:number) == :none options end def store @store ||= begin