Sha256: 3f98fcce0d6b391104f36967be28037a6df77da13fe84a637f276edd1a9cead0

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'ackr/extensions/string'
require 'ackr/search'
require 'ackr/colorizer'
require 'ackr/finder'
require 'ackr/formatter'

module Ackr

  EXCLUDE_DIRS = %w(blib CVS _darcs RCS SCCS pkg tmp temp log)

  # Method taken from: https://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
  #--
  # Based on code originally provided by Ryan Davis (which, in turn, is
  # based on Perl's -B switch).
  #
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ackr-0.2 lib/ackr.rb