FileClassify
Binary and ASCII classification for files
Installation
Add this line to your application's Gemfile:
gem 'file_classify'
And then execute:
$ bundle
Or install it yourself as:
$ gem install file_classify
Usage
require 'file_classify'
classifier = FileClassify.new(path: 'spec/resources/binary.jpg')
=> #<FileClassify:0x007fbf04c31098 @contents=nil, @path="spec/resources/binary.jpg">
classifier.binary?
=> true
classifier.ascii?
=> false
classifier.classify
=> "binary"
# Or perhaps you have file contents?
classifier = FileClassify.new(contents: 'And miles to go before I sleep.')
=> #<FileClassify:0x007fbf04cd0ff8 @contents="And miles to go before I sleep.", @path=nil>
classifier.binary?
=> false
classifier.ascii?
=> true
classifier.classify
=> "ascii"
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request