Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

file_groups

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file_groups

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

FileGroups

File extensions and media types, grouped by application and type. Useful when you need to process or restrict processing to certain types of files.

Usage

Methods on FileGroups return an object containing a set of media types and file extensions. These are accessible via the .media_types and .extensions methods, which return an Array of Strings. By default only commonly used values are returned. To return all know values pass true to either method, e.g., object.media_types(true)

In some cases additional methods can be called on the object to further restrict the set.

Let's look at some examples.

Images & Video

Retrieve a list of file extensions or media types used by images and video:

require "file_groups"

FileGroups.image.extensions   # ["bmp", "gif", "ico", "jpeg", ... ]
FileGroups.image.media_types  # ["image/bmp", "image/x-ms-bmp", "image/gif", ... ]
FileGroups.video.extensions   # ["asf", "mov", "qt", "movie", ... ]
FileGroups.video.media_types  # ["video/x-ms-asf", "video/quicktime", ... ]

Images can be filtered on by raster, vector, or web:

FileGroups.image.web.extensions     # ["gif", "jpeg", "jpg", "png", "svg", "webp"]
FileGroups.image.raster.extensions  # ["bmp", "gif", "ico", "jpeg", "jpg", "tif", "tiff", "webp"]
FileGroups.image.vector.extensions  # ["svg"]

For a complete list pass in true to any of these methods:

FileGroups.image.web.extensions(true)  # ["bmp", "dib", "gif", "ico", "jfif", "jpe", "jpeg", ... ]

Spreadsheets

Retrieve a list of file extensions or media types used by spreadsheets:

require "file_groups"

FileGroups.spreadsheet.extensions       # ["csv", "xls", "xlsx", "xlt", ... ]
FileGroups.spreadsheet.media_types      # ["text/csv", "application/vnd.ms-excel", ... ]

If you only want values specific to CSVs:

FileGroups.spreadsheet.csv.media_types  # ["text/csv", "text/comma-separated-values" ]

If you only want values specific to Microsoft Excel:

FileGroups.spreadsheet.excel.extensions   # ["xls", "xlsx", "xlt", "xltx", "xlw"]
FileGroups.spreadsheet.excel.media_types  # ["application/vnd.ms-excel", ... ]

Or for OpenOffice Calc:

FileGroups.spreadsheet.calc.extensions  # ["ods", "ots"]

By default these only return common extensions, to return all:

FileGroups.spreadsheet.excel.extensions(true) # ["xls", "xlsx", "xlt", "xltx", ... ]

Everything Else

See the list of categories and tags.

Author

Skye Shaw (skye.shaw -AT- gmail)

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 13 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc