Over a million developers have joined DZone.

View All Colors From A Set Of Stylesheets

DZone's Guide to

View All Colors From A Set Of Stylesheets

Free Resource
Rake task to grep out colors from a set of CSS stylesheets and display them on a web page. Default configuration works for OS X Safari and a Rails application.

BROWSER = "/Applications/Safari.app/Contents/MacOS/Safari"
CSS_FILES = "#{RAILS_ROOT}/public/stylesheets/**/*.css"

task :colors do
  require "tempfile"
  colors = Dir[CSS_FILES].map(&File.method(:read)).join.scan(/\#[0-9a-f]{3,6}/i).map{|c| c.upcase}.uniq
  Tempfile.open "colors" do |f|
    f.write <<-EOHTML
" }.join} EOHTML system BROWSER, f.path end end

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}