module Ackr
Constants
- EXCLUDE_DIRS
Ackr
won't search into this directories.
Public Class Methods
binary?(file)
click to toggle source
Method taken from: github.com/djberg96/ptools –
Returns whether or not file
is a binary file. Note that this is not guaranteed to be 100% accurate. It performs a “best guess” based on a simple test of the first File.blksize
characters.
Example:
File.binary?('somefile.exe') # => true File.binary?('somefile.txt') # => false
# File lib/ackr.rb, line 27 def self.binary?(file) str = (File.read(file, File.stat(file).blksize) || "").split(//) size = str.size ((size - str.grep(" ".."~").size) / size.to_f) > 0.30 end