Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rzhade3/filetype
Find a file type according to a filename or extension
https://github.com/rzhade3/filetype
filetype ruby
Last synced: 3 months ago
JSON representation
Find a file type according to a filename or extension
- Host: GitHub
- URL: https://github.com/rzhade3/filetype
- Owner: rzhade3
- License: mit
- Created: 2011-04-26T10:26:23.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2023-01-18T20:15:14.000Z (almost 2 years ago)
- Last Synced: 2024-10-01T16:46:19.217Z (4 months ago)
- Topics: filetype, ruby
- Language: Ruby
- Homepage: https://rubygems.org/gems/filetype
- Size: 42 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Filetype
Find a file type according to a filename or extension
## Installation
### Rubygems
```bash
gem install filetype
```### GitHub
```bash
git clone https://github.com/rzhade3/filetype
gem build filetype.gemspec
gem install filetype-.gem
```## Usage
```ruby
Filetype.get('foo.rb') #=> :ruby
Filetype.all('foo.h') #=> [:c, :cpp, :objc]
```## Custom file types
You can add your own custom file types
```ruby
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](https://rubygems.org/gems/mime-types) library.## Contributing
The list of file types Filetype supports can be found
[here](lib/filetype.rb#L6).
Please feel free to add file types!