Sha256: 66946ae3763803840b7c3ff4c7c7968de4dc2a0ba2d0e298e84b81941bc84991

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

#                                                                          
# File 'templatetask.rb' created on 03 mar 2008 at 13:16:03.                    
#
# See 'dokkit.rb' or +LICENSE+ for licence information.                      
#                                                                          
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors). 
#                                                                          

require 'dokkit/dokkitlib'

module Dokkit
  class TemplateTask < DokkitLib
    def initialize(model, namespace = 'template')
      super(model, namespace, { :check_dir => true })
    end
    
    private
    
    def pre_block_configuration
      @config.template_dir ||= Dokkit::DEFAULT_TEMPLATE_DIR
    end
    def define_dokkit_create_template
      desc "Copy the template to the given directory."
      dokkit_task 'create', :template do |t, args|
        template_fn = File.join(@config.template_dir, args.template)
        @logger.error("Template '#{args.template}' doesn't exist") unless File.exists?(template_fn)
        if ARGV.size == 2
          dest_fn = t.application.top_level_tasks.pop
        else
          dest_fn = File.join('doc', args.template)          
        end
        @logger.info("Copy template '#{File.basename(template_fn)}' to '#{dest_fn}'")
        cp(template_fn, dest_fn, :preserve => true, :verbose => false)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dokkit-0.3.0 lib/dokkit/templatetask.rb