lib/avro/builder/file_handler.rb in avro-builder-0.14.0 vs lib/avro/builder/file_handler.rb in avro-builder-0.14.1

- old
+ new

@@ -23,19 +23,24 @@ # Ensure that the file_name that is searched for begins with a slash (/) # and ends with a .rb extension. Additionally, if the name contains # a namespace then ensure that periods (.) are replaced by forward # slashes. E.g. for 'test.example' search for '/test/example.rb'. file_name = "/#{name.to_s.tr('.', '/').sub(/^\//, '').sub(/\.rb$/, '')}.rb" - matches = self.class.load_paths.flat_map do |load_path| + matches = real_load_paths.flat_map do |load_path| Dir["#{load_path}/**/*.rb"].select do |file_path| file_path.end_with?(file_name) end - end + end.uniq raise "Multiple matches: #{matches}" if matches.size > 1 raise "File not found #{file_name}" if matches.empty? matches.first end + private + + def real_load_paths + self.class.load_paths.map { |path| File.realpath(path) }.uniq + end end end end