Module: GrenFileTest

Defined in:
lib/gren/common/grenfiletest.rb

Constant Summary collapse

IGNORE_FILE =
/(\A#.*#\Z)|(~\Z)|(\A\.#)|(\.d\Z)|(\.map\Z)|(\.MAP\Z)|(\.xbm\Z)|(\.ppm\Z)|(\.ai\Z)|(\.png\Z)|(\.webarchive\Z)/
IGNORE_DIR =
/(\A\.svn\Z)|(\A\.git\Z)|(\ACVS\Z)/

Class Method Summary collapse

Class Method Details

.binary?(fpath) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/gren/common/grenfiletest.rb', line 15

def self.binary?(fpath)
    s = File.read(fpath, 1024) or return false
    return s.index("\x00")
end

.ignoreDir?(fpath) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/gren/common/grenfiletest.rb', line 7

def self.ignoreDir?(fpath)
  IGNORE_DIR.match(File.basename(fpath))
end

.ignoreFile?(fpath) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/gren/common/grenfiletest.rb', line 11

def self.ignoreFile?(fpath)
  IGNORE_FILE.match(File.basename(fpath))
end