Class: XRay::CSS::Reader

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/css/reader.rb

Class Method Summary collapse

Class Method Details

.get_encoding_declaration(file) ⇒ Object



20
21
22
23
24
25
# File 'lib/css/reader.rb', line 20

def self.get_encoding_declaration( file )
  begin
    File.open(file, &:readline)[/@charset\s+(['"])(.*?)\1/, 2]
  rescue
  end
end

.read(file, opt = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/css/reader.rb', line 11

def self.read( file, opt = {} )
  source, enc = FileReader::readfile(file)
  declare = get_encoding_declaration(file)
  if declare and enc != declare
    raise EncodingError.new
  end
  source
end