Module: GrenFileTest

Defined in:
lib/milkode/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)


25
26
27
28
# File 'lib/milkode/common/grenfiletest.rb', line 25

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
10
11
12
13
14
# File 'lib/milkode/common/grenfiletest.rb', line 7

def self.ignoreDir?(fpath)
  begin
    IGNORE_DIR.match(File.basename(fpath))
  rescue ArgumentError => e
    puts "[skip dir] #{fpath}: #{e.to_s}"
    true
  end
end

.ignoreFile?(fpath) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'lib/milkode/common/grenfiletest.rb', line 16

def self.ignoreFile?(fpath)
  begin
    IGNORE_FILE.match(File.basename(fpath))
  rescue ArgumentError => e
    puts "[skip] #{fpath}: #{e.to_s}"
    true
  end
end