Class: Cucumber::Runtime::NormalisedEncodingFile

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/runtime.rb

Constant Summary collapse

COMMENT_OR_EMPTY_LINE_PATTERN =

:nodoc:

/^\s*#|^\s*$/.freeze
ENCODING_PATTERN =

:nodoc:

/^\s*#\s*encoding\s*:\s*([^\s]+)/.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ NormalisedEncodingFile

Returns a new instance of NormalisedEncodingFile.



167
168
169
170
171
172
173
174
# File 'lib/cucumber/runtime.rb', line 167

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

Class Method Details

.read(path) ⇒ Object



163
164
165
# File 'lib/cucumber/runtime.rb', line 163

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

Instance Method Details

#readObject



176
177
178
# File 'lib/cucumber/runtime.rb', line 176

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