| Class | RDig::FileDocument |
| In: |
lib/rdig/documents.rb
|
| Parent: | Document |
# File lib/rdig/documents.rb, line 62
62: def self.find_files(path)
63: links = []
64: Dir.glob(File.expand_path(File.join(path, '*'))) do |filename|
65: # Skip files not matching known mime types
66: pattern = /.+\.(#{File::FILE_EXTENSION_MIME_TYPES.keys.join('|')})$/i
67: if File.directory?(filename) || filename =~ pattern
68: links << "file://#{filename}"
69: end
70: end
71: links
72: end
# File lib/rdig/documents.rb, line 78
78: def fetch
79: if File.directory? @uri.path
80: # directories are treated like a link collection
81: @content = { :links => self.class.find_files(@uri.path) }
82: else
83: # process this file's contents
84: open(@uri.path) do |file|
85: @content = ContentExtractors.process(file.read, file.content_type)
86: @content[:links] = nil if @content # don't follow links inside files
87: end
88: end
89: @content ||= {}
90: end