namespace :nuby do typo_graph_dir = File.expand_path("public/images/typo_graphs", RAILS_ROOT) desc "Removes files and directories made by these tasks" task :clean do rm_rf typo_graph_dir end namespace :graph do task :setup => :environment do mkdir_p typo_graph_dir %w(sparklines gruff).each do |library| require File.expand_path("../support/lib/#{library}", File.dirname(__FILE__)) end end desc "Make a green sparkline graph showing number of comments per article" task :comments => :setup do articles = Article.find :all, :order => "created_at ASC" Sparklines.plot_to_file File.join(typo_graph_dir, "comments_count.png"), articles.map { |article| article.comments_count}, :type => 'smooth', :line_color => 'green', :above_color => "green", :below_color => "green" end desc "Make a countdown graph for RailsConf 2006" task :countdown_railsconf do require 'rubygems' require 'gruff' require 'date' g = Gruff::Scene.new('400x60', 'themes/nubyish/images/banner/2006/railsconf/countdown') g.layers = %w[background railsconf days] g.days = (Date.parse('2006-06-22') - Date.today).to_i g.write File.join(typo_graph_dir, "countdown_railsconf.png") end end end