Class: CssCompare::CSS::Parser
- Inherits:
-
Object
- Object
- CssCompare::CSS::Parser
- Defined in:
- lib/css_compare/css/parser.rb
Instance Method Summary collapse
-
#initialize(input) ⇒ Parser
constructor
A new instance of Parser.
-
#parse ⇒ ::Sass::Tree::RootNode
Parses a CSS project using the Sass parser.
Constructor Details
#initialize(input) ⇒ Parser
Returns a new instance of Parser.
7 8 9 |
# File 'lib/css_compare/css/parser.rb', line 7 def initialize(input) @input = File.(input) end |
Instance Method Details
#parse ⇒ ::Sass::Tree::RootNode
Note:
The specified syntax is ‘:scss` because `:css` has been throwing syntax error on @charset directive.
Parses a CSS project using the Sass parser
18 19 20 21 22 23 24 25 |
# File 'lib/css_compare/css/parser.rb', line 18 def parse tree = ::Sass::Engine.new( File.read(@input), :syntax => :scss, :filename => File.(@input) ).to_tree ::Sass::Tree::Visitors::CheckNesting.visit(tree) ::Sass::Tree::Visitors::Perform.visit(tree) end |