class Mako::New

Public Class Methods

copy_templates(path) click to toggle source

@private Copies source templates to specified path.

# File lib/mako/commands/new.rb, line 19
def self.copy_templates(path)
  FileUtils.cp_r "#{Mako.config.source_templates}/.", path
end
create_dir(path) click to toggle source

If the directory does not exist, create the specified directory.

# File lib/mako/commands/new.rb, line 24
def self.create_dir(path)
  FileUtils.mkdir path
end
perform(args) click to toggle source

Copies template files stored in ../lib/templates to specified directory. If the directory specified doesn't exist, it will be created. If no directory is specified, it defaults to the current directory.

# File lib/mako/commands/new.rb, line 10
def self.perform(args)
  location = args.empty? ? Dir.pwd : File.expand_path(args.join(' '), Dir.pwd)
  create_dir(File.basename(location)) if location != Dir.pwd && File.directory?(location)
  copy_templates(location)
  Mako.logger.info "Created new Mako installation in #{location}"
end