Find a file type according to a filename or extension
gem install filetypegit clone https://github.com/rzhade3/filetype
gem build filetype.gemspec
gem install filetype-<version>.gemFiletype.get('foo.rb') #=> :ruby
Filetype.all('foo.h') #=> [:c, :cpp, :objc]You can add your own custom file types
Filetype.add(:cool, %w[ cool kl ])
Filetype.get('hello.kl') #=> :coolYou 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.
The list of file types Filetype supports can be found here. Please feel free to add file types!