Sha256: 1445b30a185358f36ceaf844dfef1e8dd65a02a3fb9802a73202d6eef881cd4b

Contents?: true

Size: 954 Bytes

Versions: 3

Compression:

Stored size: 954 Bytes

Contents

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

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

module Ackr

  # Ackr won't search into this directories.
  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

3 entries across 3 versions & 1 rubygems

Version Path
ackr-0.2.4 lib/ackr.rb
ackr-0.2.3 lib/ackr.rb
ackr-0.2.2 lib/ackr.rb