Sha256: 29c6a99d4bc48e142f8cd9325c24f9cf695e89c938eb8eba5c141988f3c7e6e0

Contents?: true

Size: 1.2 KB

Versions: 16

Compression:

Stored size: 1.2 KB

Contents

require 'jsduck/logger'
require 'fileutils'

module JsDuck
  module Web

    # Copies over the template directory.
    #
    # Or links when --template-links option specified.
    class Template
      def initialize(opts)
        @opts = opts
        @files = [
          "app",
          "app*.js",
          "favicon.ico",
          "extjs",
          "resources",
        ]
      end

      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

      # 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.glob(File.expand_path(@opts.template+"/"+file)).each do |source|
            FileUtils.send(method, source, target)
          end
        end
      end

    end

  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
solvas-jsduck-6.0.0.30539 lib/jsduck/web/template.rb
solvas-jsduck-6.0.0.9571 lib/jsduck/web/template.rb
solvas-jsduck-6.0.0.6154 lib/jsduck/web/template.rb
solvas-jsduck-6.0.0.4021 lib/jsduck/web/template.rb
solvas-jsduck-6.0.0.2554 lib/jsduck/web/template.rb
solvas-jsduck-6.0.0.1891 lib/jsduck/web/template.rb
solvas-jsduck-6.0.0.beta.1888 lib/jsduck/web/template.rb
jsduck-troopjs-0.0.10 lib/jsduck/web/template.rb
jsduck-troopjs-0.0.9 lib/jsduck/web/template.rb
jsduck-troopjs-0.0.8 lib/jsduck/web/template.rb
jsduck-troopjs-0.0.7 lib/jsduck/web/template.rb
jsduck-troopjs-0.0.5 lib/jsduck/web/template.rb
jsduck-troopjs-0.0.4 lib/jsduck/web/template.rb
jsduck-troopjs-0.0.3 lib/jsduck/web/template.rb
jsduck-troopjs-0.0.1 lib/jsduck/web/template.rb
jsduck-6.0.0beta lib/jsduck/web/template.rb