class Cucumber::Runtime::NormalisedEncodingFile

Public Class Methods

new(path) click to toggle source
# File lib/cucumber/runtime.rb, line 143
def initialize(path)
  begin
    @file = File.new(path)
    set_encoding
  rescue Errno::EACCES => e
    raise FileNotFoundException.new(e, File.expand_path(path))
  rescue Errno::ENOENT
    raise FeatureFolderNotFoundException.new(path)
  end
end
read(path) click to toggle source
# File lib/cucumber/runtime.rb, line 139
def self.read(path)
  new(path).read
end

Public Instance Methods

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

Private Instance Methods

set_encoding() click to toggle source
# File lib/cucumber/runtime.rb, line 160
def set_encoding
  @file.each do |line|
    if ENCODING_PATTERN =~ line
      @file.set_encoding $1
      break
    end
    break unless COMMENT_OR_EMPTY_LINE_PATTERN =~ line
  end
  @file.rewind
end