Skip to content

Instantly share code, notes, and snippets.

@texpert
Forked from acuppy/document_types.rb
Last active March 15, 2017 16:22
Show Gist options
  • Save texpert/498080d450abfadc46ffd1af7584e44c to your computer and use it in GitHub Desktop.
Save texpert/498080d450abfadc46ffd1af7584e44c to your computer and use it in GitHub Desktop.
All major document mime types (Microsoft Office, Apple iWork, Adobe PDF) as a Ruby Module
module DocumentFileTypes
module Microsoft
WORD = %w(
application/msword
application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.openxmlformats-officedocument.wordprocessingml.template
application/vnd.ms-word.document.macroEnabled.12
application/vnd.ms-word.template.macroEnabled.12
).freeze
EXCEL = %w(
application/vnd.ms-excel
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.openxmlformats-officedocument.spreadsheetml.template
application/vnd.ms-excel.sheet.macroEnabled.12
application/vnd.ms-excel.template.macroEnabled.12
application/vnd.ms-excel.addin.macroEnabled.12
application/vnd.ms-excel.sheet.binary.macroEnabled.12
).freeze
POWER_POINT = %w(
application/vnd.ms-powerpoint
application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.openxmlformats-officedocument.presentationml.template
application/vnd.openxmlformats-officedocument.presentationml.slideshow
application/vnd.ms-powerpoint.addin.macroEnabled.12
application/vnd.ms-powerpoint.presentation.macroEnabled.12
application/vnd.ms-powerpoint.template.macroEnabled.12
application/vnd.ms-powerpoint.slideshow.macroEnabled.12
).freeze
end
module Apple
IWORK = ['application/x-iwork-pages-sffpages'].freeze
end
module Adobe
PDF = ["application/pdf"].freeze
end
TEXT_DOC_MIME_TYPES = Microsoft::WORD + ['text/plain']
SPREADSHEET_MIME_TYPES = Microsoft::EXCEL + ['text/csv']
PRESENTATION_MIME_TYPES = Microsoft::POWER_POINT
ALL = TEXT_DOC_MIME_TYPES + SPREADSHEET_MIME_TYPES + PRESENTATION_MIME_TYPES + Apple::IWORK + Adobe::PDF
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment