FileClassify

Binary and ASCII classification for files

Gem Version Build Status Dependency Status Coverage Status Code Climate

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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request