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
|
# File 'lib/chinstrap.rb', line 11
def new(name)
name = name.chomp("/")
target = File.join(Dir.pwd, name)
constant_name = name.split('_').map{ |p| p[0..0].upcase + p[1..-1] }.join
constant_name = constant_name.split('-').map{ |q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
options = {
name: name,
constant_name: constant_name
}
empty_directory target
empty_directory File.join(target, "app/models")
template File.join("app/routes/main.rb"), File.join(target, "app/routes/main.rb"), options
empty_directory File.join(target, "app/views")
template File.join("app/app.rb"), File.join(target, "app/#{name}.rb"), options
template File.join("config/environment.rb"), File.join(target, "config/environment.rb"), options
empty_directory File.join(target, "lib")
template File.join("test/test_helper.rb"), File.join(target, "test/test_helper.rb"), options
empty_directory File.join(target, "tmp")
empty_directory File.join(target, "vendor")
template File.join("gitignore"), File.join(target, ".gitignore"), options
template File.join("config.ru"), File.join(target, "config.ru"), options
template File.join("Gemfile"), File.join(target, "Gemfile"), options
template File.join("Rakefile"), File.join(target, "Rakefile"), options
end
|