Module: Distil::FileVendor

Included in:
Project
Defined in:
lib/distil/file-vendor.rb

Instance Method Summary collapse

Instance Method Details

#cache_file(file) ⇒ Object



5
6
7
8
# File 'lib/distil/file-vendor.rb', line 5

def cache_file(file)
  @file_cache={} if @file_cache.nil?
  @file_cache[file.full_path]= file
end

#file_from_path(filepath) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/distil/file-vendor.rb', line 10

def file_from_path(filepath)
  return if !filepath
  @file_cache={} if @file_cache.nil?
  full_path= File.expand_path(filepath)
  file= @file_cache[full_path]
  return file if file

  extension= File.extname(filepath)[1..-1]

  SourceFile.subclasses.each { |handler|
    next if (handler.extension != extension)
    return handler.new(filepath, self)
  }

  return SourceFile.new(filepath, self)
end