lib/doc/documentor.rb in doc-0.2.7 vs lib/doc/documentor.rb in doc-0.2.8

- old
+ new

@@ -2,12 +2,14 @@ require 'progress' module Doc class Documentor attr_reader :title, :min_update_interval, :clean_after, :configurators - attr_reader :base_dir, :sources_dir, :docs_dir, :public_dir + attr_reader :base_dir, :sources_dir, :docs_dir, :public_dir, :started def initialize(*arguments, &block) + @started = Time.now + config = RootConfig.new(self, *arguments, &block) config.check_options!([], [:title, :min_update_interval, :clean_after, :public_dir]) @title = config[:title] || 'ruby documentation' @min_update_interval = config[:min_update_interval] || 1.hour @@ -43,16 +45,18 @@ :tasks => configurators.with_progress('generating tasks').map(&:tasks).flatten }) end def build(update = false) - started = Time.now root_task = config(update) root_task.run if clean_after - (sources_dir.directory? ? sources_dir.children : [] + docs_dir.children).each do |dir| + candidates = [] + candidates += sources_dir.children if sources_dir.directory? + candidates += docs_dir.children if docs_dir.directory? + candidates.each do |dir| if started - dir.mtime > clean_after dir.rmtree_verbose end end end