Class: Entityjs::New

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

Class Method Summary collapse

Class Method Details

.generate(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/entityjs/commands/new.rb', line 7

def self.generate(args)
  name = args.first || 'entityjs_game'
  template_name = args[1] || Entityjs::default_template
  
  template = Entityjs::template_path(template_name)
  
  if template.nil?
    template = Entityjs::template_path(Entityjs::default_template)
    puts "Template #{template_name} not found!"
    puts "Using default #{Entityjs::default_template} template"
  end
  
  Dirc.create_dir(name)
  
  #copy template contents
  FileUtils.cp_r template, name
  
  puts "Created: #{name}"
  puts "Template: #{template_name}"
  puts "Path: ./#{name}"
  puts "Version: #{Entityjs::VERSION}"
  puts "Website: http://entityjs.com"
  puts ""
  
  Dirc.change_dir(name)
  
  #assets
  Dirc.create_dir('assets',true)
  Dirc.create_dir('images')
  Dirc.create_dir('sounds')
  Dirc.change_dir('..')
  
  #builds
  Dirc.create_dir('builds')
  
  #scripts
  Dirc.create_dir('scripts', true)
  
  Dirc.create_dir('plugins')
  Dirc.change_dir('..')
  
  #tests
  Dirc.create_dir('tests')
  
  #move back to root
  Dirc.change_dir('..')
  
  return 0
end