Class: JCukeForker::NormalisedEncodingFile

Inherits:
Object
  • Object
show all
Defined in:
lib/jcukeforker/normalised_encoding_file.rb

Constant Summary collapse

COMMENT_OR_EMPTY_LINE_PATTERN =

:nodoc:

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

:nodoc:

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ NormalisedEncodingFile

Returns a new instance of NormalisedEncodingFile.



10
11
12
13
14
15
16
17
18
19
# File 'lib/jcukeforker/normalised_encoding_file.rb', line 10

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 => e
    raise FeatureFolderNotFoundException.new(e, path)
  end
end

Class Method Details

.read(path) ⇒ Object



6
7
8
# File 'lib/jcukeforker/normalised_encoding_file.rb', line 6

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

Instance Method Details

#readObject



21
22
23
# File 'lib/jcukeforker/normalised_encoding_file.rb', line 21

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