Skip to content
Find a file type according to a filename or extension
Find file
Pull request Compare This branch is 1 commit behind leejarvis:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gemtest
.gitignore
LICENSE
README.md
Rakefile
filetype.gemspec

README.md

Filetype

Find a file type according to a filename or extension

Installation

Rubygems

gem install filetype

GitHub

git clone git://github.com/injekt/filetype.git
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 of course 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. This list is of course fairly short. Please feel free to add file types!

Something went wrong with that request. Please try again.