module FileData
  # Operations common to all files
  class FileInfo
    class << self
      attr_reader :info_maps
    end

    @info_maps ||= {}

    def self.creation_date(filename)
      File.open(filename, 'rb') do |stream|
        reader_class(filename).creation_date(stream)
      end
    end

    def self.origin_date(filename)
      File.open(filename, 'rb') do |stream|
        reader_class(filename).origin_date(stream)
      end
    end

    def self.reader_class(filename)
      info_maps[File.extname(filename).downcase]
    end
  end
end

module FileData
  # Operations common to all files
  class FileInfo
    class << self
      attr_reader :info_maps
    end

    @info_maps ||= {}

    def self.creation_date(filename)
      File.open(filename, 'rb') do |stream|
        reader_class(filename).creation_date(stream)
      end
    end

    def self.origin_date(filename)
      File.open(filename, 'rb') do |stream|
        reader = reader_class(filename)
        raise "No metadata parser class found for the file #{filename}" if reader.nil?
        
        reader_class(filename).origin_date(stream)
      end
    end

    def self.reader_class(filename)
      info_maps[File.extname(filename).downcase]
    end
  end
end

Add a check to make sure that a reader class is found for a given file in the FileInfo methods
Add a check to make sure that a reader class is found for a given file in the FileInfo methods
