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
|
# File 'lib/enginery/generator.rb', line 11
def generate_project name = nil
name = name.to_s
if name.empty?
name = '.'
else
name =~ /\.\.|\// && fail('Project name can not contain "/" nor ".."')
@dst_root, @dst_path_map = File.join(@dst_root, name, ''), nil
end
Dir[dst_path(:root, '*')].any? && fail('"%s" should be a empty folder' % dst_path.root)
o
o '=== Generating "%s" project ===' % name
folders, files = Dir[src_path(:base, '**/{*,.[a-z]*}')].partition do |entry|
File.directory?(entry)
end
FileUtils.mkdir_p dst_path.root
o "#{name}/"
folders.each do |folder|
path = unrootify(folder, src_path.base)
o " D #{path}/"
FileUtils.mkdir_p dst_path(:root, path)
end
files.reject {|f| File.basename(f) == '.gitkeep'}.each do |file|
path = unrootify(file, src_path.base)
o " F #{path}"
FileUtils.cp file, dst_path(:root, path)
end
Configurator.new dst_root, setups do
update_gemfile
update_rakefile
update_boot_rb
update_config_yml
update_database_rb
update_database_yml
end
name
end
|