require "rake" require "fileutils" require "dtc_rake/config" require "dtc_rake/product" require "dtc_rake/ui" require "dtc_rake/util" include DtcRake::UI product = DtcRake::Product.instance def build_yardoc(product) begin require "zip" rescue LoadError error "Gem rubyzip is not available. In order to use this task, you must: gem install rubyzip" end announce "Building command client yardoc pack" output_dir = DtcRake::Config.instance.output_dir archive = product.yardoc_file_name tmp_dir = File.basename(archive, ".zip") FileUtils.cd product.gem_project do [ File.join(output_dir, tmp_dir), File.join(output_dir, "doc") ].each do |dir| FileUtils.rm_rf dir if File.directory? dir end system "yardoc" FileUtils.cd output_dir do FileUtils.mv "doc", tmp_dir info "Creating #{archive}" FileUtils.rm_f archive Zip::File.open(archive, "w") do |zip| Dir["#{tmp_dir}/**/**"].reject { |f| f == archive }.each do |file| zip.add(file.sub("target/", ""), file) end end end end DtcRake.mv_to_output_dir(product.gem_project, archive) end if product.has_gem namespace :build do desc "Builds pack with command client yardoc" task :yardoc do build_yardoc(product) end end end