class JsDuck::Web::Template

Copies over the template directory.

Or links when –template-links option specified.

Public Class Methods

new(opts) click to toggle source
# File lib/jsduck/web/template.rb, line 11
def initialize(opts)
  @opts = opts
  @files = [
    "app",
    "app*.js",
    "favicon.ico",
    "extjs",
    "resources",
  ]
end

Public Instance Methods

write() click to toggle source
# File lib/jsduck/web/template.rb, line 22
def write
  if @opts.template_links
    Logger.log("Linking template files to", @opts.output)
    move_files(:symlink)
  else
    Logger.log("Copying template files to", @opts.output)
    move_files(:cp_r)
  end

  # always copy the eg-iframe file.
  eg_iframe = @opts.eg_iframe || @opts.template+"/eg-iframe.html"
  FileUtils.cp(eg_iframe, @opts.output+"/eg-iframe.html")
end

Private Instance Methods

move_files(method) click to toggle source

moves files from one dir to another using a method of FileUtils module.

# File lib/jsduck/web/template.rb, line 39
def move_files(method)
  @files.each do |file|
    target = File.expand_path(@opts.output)
    Dir.glob(File.expand_path(@opts.template+"/"+file)).each do |source|
      FileUtils.send(method, source, target)
    end
  end
end