Class: AssetSync::MultiMime

Inherits:
Object
  • Object
show all
Defined in:
lib/asset_sync/multi_mime.rb

Class Method Summary collapse

Class Method Details

.lookup(ext) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/asset_sync/multi_mime.rb', line 6

def self.lookup(ext)
  overrides =
    ::AssetSync.config.file_ext_to_mime_type_overrides
  if overrides.key?(ext)
    return overrides.fetch(ext)
  end

  if defined?(::MIME::Types)
    ::MIME::Types.type_for(ext).first.to_s
  elsif defined?(::Mime::Type)
    ::Mime::Type.lookup_by_extension(ext).to_s
  elsif defined?(::Rack::Mime)
    ext_with_dot = ".#{ext}"
    ::Rack::Mime.mime_type(ext_with_dot)
  else
    raise "No library found for mime type lookup"
  end

end