class CssCompare::CSS::Parser

Public Class Methods

new(input) click to toggle source

@param [File]

# File lib/css_compare/css/parser.rb, line 7
def initialize(input)
  @input = File.expand_path(input)
end

Public Instance Methods

parse() click to toggle source

Parses a CSS project using the Sass parser

@note The specified syntax is ‘:scss` because

`:css` has been throwing syntax error on
@charset directive.

@return [::Sass::Tree::RootNode]

# File lib/css_compare/css/parser.rb, line 18
def parse
  tree = ::Sass::Engine.new(
    File.read(@input),
    :syntax => :scss, :filename => File.expand_path(@input)
  ).to_tree
  ::Sass::Tree::Visitors::CheckNesting.visit(tree)
  ::Sass::Tree::Visitors::Perform.visit(tree)
end