0.0
No commit activity in last 3 years
No release in over 3 years
Processes, evaluates and compares 2 different CSS files based on their AST.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 11.1
~> 3.0

Runtime

~> 1.8
~> 3.4
 Project Readme

CSS Compare

Processes, evaluates and compares 2 CSS files based on their AST. The repository has been created in order to be able to test the less2sass project. The program returns true or false to the $stdout, so far. Uses the Sass parser to get the CSS files' AST.

Supported CSS features:

  • all types of selectors (they are normalized - duplicity removal and logical/alphabetical ordering)
  • @media, partially
  • @import (lazy loading of imported css files, that can be found, otherwise ignored)
  • @font-face
  • @namespace
  • @charset
  • @keyframes
  • @page
  • @supports, partially

Installation

Add this line to your application's Gemfile:

gem 'css_compare'

And then execute:

$ bundle

Or install it yourself as:

$ gem install css_compare

Usage

Command line usage:

$ css_compare <CSS file> <CSS file>

Programmatic usage:

opts = {
    :operands => ["path/to/file1.css", "path/to/file2.css"]
}
result = CssCompare::Engine.new(opts)
                   .parse!
                   .equal?

TODO

  • Evaluate shorthand properties, so the values of base properties get overridden.
  • Evaluate @media rule's and @supports rule's conditions.
  • Output the difference, optionally.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/vecerek/css_compare.

License

The gem is available as open source under the terms of the MIT License.