Sha256: 2bcb08d33d7ab47c055eaacb5e384b97024fdc978e943270d4896709aa55e571
Contents?: true
Size: 1.17 KB
Versions: 16
Compression:
Stored size: 1.17 KB
Contents
require 'jsduck/logger' require 'fileutils' module JsDuck # Copies over the template directory. # # Or links when --template-links option specified. class TemplateDir def initialize(opts) @opts = opts @files = [ "app", "app*.js", "favicon.ico", "extjs", "resources", ] end def write FileUtils.mkdir(@opts.output_dir) if @opts.template_links Logger.log("Linking template files to", @opts.output_dir) move_files(:symlink) else Logger.log("Copying template files to", @opts.output_dir) move_files(:cp_r) end # always copy the eg-iframe file. eg_iframe = @opts.eg_iframe || @opts.template_dir+"/eg-iframe.html" FileUtils.cp(eg_iframe, @opts.output_dir+"/eg-iframe.html") end private # moves files from one dir to another using a method of FileUtils module. def move_files(method) @files.each do |file| target = File.expand_path(@opts.output_dir) Dir.glob(File.expand_path(@opts.template_dir+"/"+file)).each do |source| FileUtils.send(method, source, target) end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems