class Cane::File

An interface for interacting with files that ensures encoding is handled in a consistent manner.

Public Class Methods

case_insensitive_glob(glob) click to toggle source
# File lib/cane/file.rb, line 25
def case_insensitive_glob(glob)
  Dir.glob(glob, ::File::FNM_CASEFOLD)
end
contents(path) click to toggle source
# File lib/cane/file.rb, line 13
def contents(path)
  open(path).read
end
exists?(path) click to toggle source
# File lib/cane/file.rb, line 21
def exists?(path)
  ::File.exists?(path)
end
iterator(path) click to toggle source
# File lib/cane/file.rb, line 9
def iterator(path)
  EncodingAwareIterator.new(open(path).each_line)
end
open(path) click to toggle source
# File lib/cane/file.rb, line 17
def open(path)
  ::File.open(path, 'r:utf-8')
end