lib/dokkit/tasklib/clean.rb in dokkit-0.4.4 vs lib/dokkit/tasklib/clean.rb in dokkit-0.5.0
- old
+ new
@@ -4,42 +4,35 @@
# See 'dokkit.rb' or +LICENSE+ for licence information.
#
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
#
+require 'dokkit/tasklib/base'
+
module Dokkit
module TaskLib
# The Clean task library is a collection of rake tasks devoted to
# the cleaning of the documentation environment. The library
# defines a clean:output that remove the generated output folder
# (if exists). It defines also a clean:cache task that remove the
# cache folder (if exists).
- class Clean
- attr_reader :output_dir, :cache_dir
+ class Clean < Base
+ attr_accessor :output_dir, :cache_dir
+
# Initialize the library with the logger instance, an optional
# namespace and configuration hash.
- def initialize(logger, configuration, namespace = 'clean')
- @namespace = namespace
- @logger = logger
- @configuration = configuration
- @output_dir = configuration[:output_dir]
- @cache_dir = configuration[:cache_dir]
+ def initialize(ns = 'clean')
+ super
+
+ yield self if block_given?
+
define_tasks
end
private
- # Define library tasks under the given namespace.
- def define_tasks
- namespace @namespace do
- define_output_task
- define_cache_task
- define_clean_all_task
- end
- end
-
# Define a task to remove output directory.
def define_output_task
desc "Remove the generated output."
task :output do
remove_dir(output_dir)
@@ -58,15 +51,15 @@
if File.exists?(dir)
@logger.info("Removing directory '#{dir}'.")
rm_rf dir unless dir == '.'
end
end
-
+
# Define a task that clean the documentation environment
# removing both output and cache directory.
def define_clean_all_task
desc "Clean the documentation environment."
- task :all => ["#{@namespace}:output", "#{@namespace}:cache"]
+ task :all => ["#{@ns}:output", "#{@ns}:cache"]
end
end
end
end