def run
must_exclude = [ 'InstalledFiles', 'CVS/**/*' ]
if !File.exists?(@main) or File.directory?(@main)
warn "Specified RDoc Main file #{@main} not found. Ignored."
@main = nil
end
rdoc_dir = File.expand_path(@dir)
if FileTest.directory?(@dir)
print "Directory '#{@dir}' already exists. Clobber? [y/N] "
until inp = $stdin.gets[0,1] ; sleep 1 ; end ; puts
if (inp || 'y').downcase == 'y'
puts "Removing old directory '#{rdoc_dir}'..."
FileUtils.rm_r(@dir) unless $PRETEND
else
puts "Reap rdoc task canceled."
return nil
end
end
rdoc_target = "#{rdoc_dir}/index.html"
exc = []
(@exclude + must_exclude).each{ |e|
exc << e
exc |= Dir.glob(e+'/**/*')
}
inc = Dir.glob('[A-Z]*')
@include.each{ |i| inc |= Dir.glob(i) }
inc -= exc
inc = inc.select{ |f| File.file?(f) }
rdoc_files = inc
rdoc_files = '"' << rdoc_files.join('" "') << '"'
build = []
build += @options
build << "--main '#{@main}'" if @main
build << "--title '#{@title}'" if @title
build << "-T '#{@template}'" if @template
rdoc_opts = build.join(' ')
puts "Reap is shelling work out to RDoc..."
sh %{rdoc -o #{rdoc_dir} #{rdoc_opts} #{rdoc_files}}
end