Sha256: ddf5fb1dc7e78d3960f8570dc2ea7381384d4d2eb6311472f2a1be88b4103143

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

= deadweight

Deadweight is RCov for CSS, kind of. Given a set of stylesheets and a set of URLs, it determines which selectors are actually used and reports which can be "safely" deleted.

=== A Simple Example

  # lib/tasks/deadweight.rake

  require 'deadweight'

  desc "run Deadweight (script/server needs to be running)"
  task :deadweight do
    dw = Deadweight.new
    dw.stylesheets = %w( /stylesheets/style.css )
    dw.pages = %w( / /page/1 /about )
    puts dw.run
  end

This will output all unused selectors, one per line.

=== How You Install It

  gem sources -a http://gems.github.com
  sudo gem install aanand-deadweight

=== Things to Note

- By default, it looks at http://localhost:3000.
- It's completely dumb about any classes, IDs or tags that are only added by your Javascript layer, but you can filter them out by setting +ignore_selectors+.
- You can optionally tell it to use Mechanize, and set up more complicated targets for scraping by specifying them as Procs.

=== A More Complex Example, In Light of All That

  # lib/tasks/deadweight.rake

  require 'deadweight'

  desc "run Deadweight on staging server"
  task :deadweight do
    dw = Deadweight.new

    dw.mechanize = true

    dw.root = 'http://staging.example.com'

    dw.stylesheets = %w( /stylesheets/style.css )

    dw.pages = %w( / /page/1 /about )

    dw.pages << proc {
      fetch('/login')
      form = agent.page.forms.first
      form.username = 'username'
      form.password = 'password'
      agent.submit(form)
      fetch('/secret-page')
    }

    dw.ignore_selectors = /hover|lightbox|superimposed_kittens/

    puts dw.run
  end

== Copyright

Copyright (c) 2009 Aanand Prasad. See LICENSE for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aanand-deadweight-0.0.3 README.rdoc