rzhade3 / filetype

Find a file type according to a filename or extension

Home Page:https://rubygems.org/gems/filetype

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filetype

Find a file type according to a filename or extension

Installation

Rubygems

gem install filetype

GitHub

git clone https://github.com/rzhade3/filetype
gem build filetype.gemspec
gem install filetype-<version>.gem

Usage

Filetype.get('foo.rb') #=> :ruby
Filetype.all('foo.h')  #=> [:c, :cpp, :objc]

Custom file types

You can add your own custom file types

Filetype.add(:cool, %w[ cool kl ])
Filetype.get('hello.kl') #=> :cool

Simple

You may notice how basic Filetype is, all it's doing is checking the file name or file extension. Well, that's its intention, it was built for nothing more. If you want more advanced information, check out the mime-types library.

Contributing

The list of file types Filetype supports can be found here. Please feel free to add file types!

About

Find a file type according to a filename or extension

https://rubygems.org/gems/filetype

License:MIT License


Languages

Language:Ruby 100.0%