Sha256: 461a80493745a39e7d8858a36c1255e6491d08efda05a57b6c809c67a08b9a47

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

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
  output_dir_name = File.basename(output_dir) # get just the last path element (e.g. "target")
  local_output_dir = File.join(product.gem_project, output_dir_name)
  archive = product.yardoc_file_name
  tmp_dir = File.basename(archive, ".zip")

  FileUtils.cd product.gem_project do
    [
      File.join(local_output_dir, tmp_dir),
      File.join(local_output_dir, "doc")
    ].each do |dir|
      FileUtils.rm_rf dir if File.directory? dir
    end

    system "yardoc"

    FileUtils.cd local_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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dtc_rake-1.2.1 lib/tasks/build_yardoc.rake
dtc_rake-1.2.0 lib/tasks/build_yardoc.rake
dtc_rake-1.1.0 lib/tasks/build_yardoc.rake
dtc_rake-1.0.0 lib/tasks/build_yardoc.rake
dtc_rake-1.0.0.pre.beta.2 lib/tasks/build_yardoc.rake