class Cucumber::Runtime::NormalisedEncodingFile

Public Class Methods

new(path) click to toggle source
# File lib/cucumber/runtime.rb, line 158
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
read(path) click to toggle source
# File lib/cucumber/runtime.rb, line 154
def self.read(path)
  new(path).read
end

Public Instance Methods

read() click to toggle source
# File lib/cucumber/runtime.rb, line 167
def read
  @file.read.encode('UTF-8')
end

Private Instance Methods

set_encoding() click to toggle source
# File lib/cucumber/runtime.rb, line 173
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