class Cucumber::Runtime::NormalisedEncodingFile

def self.read(path)

def self.read(path)
  new(path).read
end

def initialize(path)

def initialize(path)
  @file = File.new(path)
  set_encoding
rescue Errno::EACCES => e
  raise FileNotFoundException.new(e, File.expand_path(path))
rescue Errno::ENOENT
  raise FeatureFolderNotFoundException, path
end

def read

def read
  @file.read.encode('UTF-8')
end

def set_encoding

def set_encoding
  @file.each do |line|
    if ENCODING_PATTERN =~ line
      @file.set_encoding Regexp.last_match(1)
      break
    end
    break unless COMMENT_OR_EMPTY_LINE_PATTERN =~ line
  end
  @file.rewind
end