Project

parse-css

0.0
No release in over 3 years
A Ruby wrapper around the parse-css JavaScript library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 0.19
 Project Readme

parse-css

Unit Tests

What is this thing?

parse-css is a Ruby wrapper around the parse-css JavaScript library. A number of CSS parsing libraries already exist for Ruby, but none of the ones I tested were able to handle nested CSS. The parse-css JavaScript library is small, fast, handles nested CSS, and doesn't have any dependencies or use special Node.js APIs.

Since this library is a wrapper around the JavaScript one, all the same limitations apply. For example, it doesn't try to validate the CSS it's given, or interpret it in any way. It's just a parser. Your mileage may vary.

Usage

The API of this gem is very simple:

require "parse-css"

ParseCSS.parse("body { color: red; }")  # => [{...}]

The .parse method produces a simple data structure made up of arrays, hashes, strings, and numbers.

That's it, that's all it does.

How does it work?

Yeah, so how can a library written in JavaScript be used from Ruby? parse-css is made possible by mini_racer, a minimal, embeddable JavaScript runtime for Ruby.

Running Tests

bundle exec rake should do the trick.

License

Licensed under the MIT license. See LICENSE for details.

Authors