This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | Mon Nov 10 10:10:40 -0800 2008 | |
| |
LICENSE | Mon Nov 10 10:10:40 -0800 2008 | |
| |
README | Mon Nov 10 10:10:40 -0800 2008 | |
| |
css_parser.gemspec | Mon Nov 10 10:24:07 -0800 2008 | |
| |
lib/ | Mon Nov 10 10:14:42 -0800 2008 | |
| |
rakefile.rb | Mon Nov 10 10:19:03 -0800 2008 | |
| |
test/ | Mon Nov 10 10:10:40 -0800 2008 |
README
=== Ruby CSS Parser
Load, parse and cascade CSS rule sets in Ruby.
==== Setup
Install the gem from RubyGems.
gem install css_parser
Done.
==== 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 = <<-EOT
body { margin: 0 1em; }
EOT
parser.add_block!(css)
# output all CSS rules in a single stylesheet
parser.to_s
=> #content { font-size: 13px; line-height: 1.2; }
body { margin: 0 1em; }
==== Testing
You can run the suite of unit tests using <tt>rake test</tt>.
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 <tt>test/fixtures/</tt>
directory.
==== Credits and code
By Alex Dunae (dunae.ca, e-mail 'code' at the same domain), 2007-08.
Project homepage: http://code.google.com/p/ruby-css-parser/
Made on Vancouver Island.






