Project Summary

  Analyzed 1 day ago based on code collected 1 day ago.

Load, parse and cascade CSS rule sets in Ruby.

SetupInstall the gem from Ruby Forge.

gem install css_parserDone.

An example require 'css_parser'
include CssParser

parser = CssParser::Parser.new
parser.load_file!('http://example.com/styles/style.css')

# lookup a rule by a selector
parser.find('#content')
#=> 'font-size: 13px; line-height: 1.2;'

# lookup a rule by a selector and media type
parser.find('#content', [:screen, :handheld])

# iterate through selectors by media type
parser.each_selector(:screen) do |selector, declarations, specificity|
...
end

# add a block of CSS
css = < #content { font-size: 13px; line-height: 1.2; }
body { margin: 0 1em; }TestingYou can run the suite of unit tests using rake test.

The download/import tests require that WEBrick is installed. The tests set up a temporary server on port 12000 and pull down files from the test/fixtures/ directory.

Credits and codeBy Alex Dunae (dunae.ca, e-mail code at dunae dot ca), 2007-08.

Made on Vancouver Island.

Tags

  parser ruby css gem

Share

In a Nutshell, ruby-css-parser...

 

Activity

30 Day Summary Apr 19 2013 — May 19 2013

12 Month Summary May 19 2012 — May 19 2013

Community

Ratings

Be the first to rate this project
 
Click to add your rating
 
Review this Project!
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.