module SciolyFF::Validator::Canonical

Logic for checking against canonical lists of events and schools

Constants

BASE

Private Instance Methods

canonical?(rep, file, logger) click to toggle source
# File lib/sciolyff/validator/canonical.rb, line 10
def canonical?(rep, file, logger)
  return true if @canonical_warned || !logger.options[:canonical_checks]

  @canonical_list ||= CSV.parse(URI.open(BASE + file))
  # don't try to make this more efficient, harder than it looks because of
  # nil comparisons
  @canonical_list.include?(rep)
rescue StandardError => e
  logger.warn "could not read canonical names file: #{BASE + file}"
  logger.debug "#{e}\n  #{e.backtrace.first}"
  @canonical_warned = true
end