# # File 'cleantask.rb' created on 19 feb 2008 at 19:33:03. # # See 'dokkit.rb' or +LICENSE+ for licence information. # # (C) 2008 Andrea Fazzi (and contributors). # require 'rake/clean' require 'dokkit/dokkitlib' module Dokkit class CleanTask < DokkitLib def initialize(model, namespace = 'clean') super(model, namespace) end private def pre_block_configuration @config.output_dir ||= Dokkit::DEFAULT_OUTPUT_DIR @config.cache_dir ||= Dokkit::DEFAULT_CACHE_DIR end def define_dokkit_clean_output desc 'Remove output directory' dokkit_task :output do if File.exists?(@config.output_dir) @logger.info('Removing output directory') rm_rf(@config.output_dir, :verbose => false) end end end def define_dokkit_clean_cache desc 'Remove cache directory' dokkit_task :cache do if File.exists?(@model.cache.cache_dir) @logger.info('Removing cache directory') @model.cache.clean end end end def define_dokkit_clean_backup desc 'Remove backup files (invoke rake:clean)' dokkit_task :backup => ['rake:clean'] end def define_dokkit_clean_all desc 'Clobber all generated output and cache' dokkit_task :all => [:output, :cache, :backup] end end end