Class: Mako::New

Inherits:
Object
  • Object
show all
Defined in:
lib/mako/commands/new.rb

Class Method Summary collapse

Class Method Details

.copy_templates(path) ⇒ Object

Copies source templates to specified path.



19
20
21
# 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) ⇒ Object

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



24
25
26
# File 'lib/mako/commands/new.rb', line 24

def self.create_dir(path)
  FileUtils.mkdir path
end

.perform(args) ⇒ Object

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.



10
11
12
13
14
15
# 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