New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

DanaDanger-css_parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

DanaDanger-css_parser

  • 0.9.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

=== 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 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 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.

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc