Skip to content

Instantly share code, notes, and snippets.

@adamstac
Created November 20, 2010 03:40
Show Gist options
  • Save adamstac/707598 to your computer and use it in GitHub Desktop.
Save adamstac/707598 to your computer and use it in GitHub Desktop.
A set of rake tasks for clearing, compiling and generating stats on your Sass stylesheets (Compass required).
namespace :styles do
# STATS
desc "Generate stats"
task :stats => ["stats:default"]
namespace :stats do
task :default do
puts "*** Generating stats ***"
system "compass stats"
end
desc "Create a log of the stats in 'app/stylesheets/stats'"
task :log do
t = DateTime.now
filename = "stats-#{t.strftime("%Y%m%d")}-#{t.strftime("%H%M%S")}.log"
log_dir = "log/sass"
puts "*** Logging stats ***"
system "compass stats > #{log_dir}/#{filename}"
puts "Created #{log_dir}/#{filename}"
end
end
# COMPILING
desc "Clear the styles"
task :clear => ["compile:clear"]
desc "Compile new styles"
task :compile => ["compile:default"]
namespace :compile do
task :clear do
puts "*** Clearing styles ***"
system "rm -Rfv public/stylesheets/compiled/*"
end
task :default => :clear do
puts "*** Compiling styles ***"
system "compass compile"
end
desc "Compile new styles for production"
task :production => :clear do
puts "*** Compiling styles ***"
system "compass compile --output-style compressed --force"
end
end
# VALIDATIONS
desc "Validates the emmited CSS stylesheets"
task :validate => ["validate:default"]
namespace :validate do
task :default do
puts "*** Validating the emmited CSS stylesheets ***"
system "compass validate ."
end
desc "Create a log of the validation"
task :log do
t = DateTime.now
filename = "validate-#{t.strftime("%Y%m%d")}-#{t.strftime("%H%M%S")}.log"
log_dir = "log/sass"
puts "*** Logging the validation ***"
system "compass validate . > #{log_dir}/#{filename}"
puts "Created #{log_dir}/#{filename}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment