Method: Fdlint::Helper::FileReader#readfile

Defined in:
lib/fdlint/helper/file_reader.rb

#readfile(path, opt = {}) ⇒ Object

auto detect file encoding and read it. return with an array containing string and encoding

Raises:

  • (EncodingError)


11
12
13
14
15
# File 'lib/fdlint/helper/file_reader.rb', line 11

def readfile(path, opt={})
  bin = File.read(path).utf8!
  raise EncodingError.new unless bin.valid_encoding?
  bin
end