Module: Fdlint::Helper::FileReader

Extended by:
FileReader
Included in:
FileReader
Defined in:
lib/fdlint/helper/file_reader.rb

Instance Method Summary collapse

Instance Method Details

#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