Sha256: 2d4cca58133a11751962fd45f5e79cc06e51886be5592f4e1b3113a20ae4fff8
Contents?: true
Size: 754 Bytes
Versions: 5
Compression:
Stored size: 754 Bytes
Contents
require 'multi_mime/adapter' module MultiMime module Adapters # Use the Mime::Type library class MimeType < Adapter def type_for(mime_type, opts = {}) ::Mime::Type.parse_data_with_trailing_star(mime_type).first || MultiMime::NullType.new end def type_for_extension(extension, opts = {}) extension = extension[/(?:.*\.)(.*$)/, 1] if extension.include?('.') # requires just the extension, without the dot ::Mime::Type.lookup_by_extension(extension) || MultiMime::NullType.new end def type_for_path(path, opts = {}) type_for_extension(File.extname(path)) end def type_for_file(file, opts = {}) type_for_extension(File.extname(file)) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems