49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/cear/project.rb', line 49
def run
if @app_name == nil
@app_name = AskQuestion.new("What is the project name?").ask
end
CearConfig.include_pg = AskQuestion.new("Do you want to include pg?", "N/y").ask == 'y'
CearConfig.include_redis = AskQuestion.new("Do you want to include redis?", "N/y").ask == 'y'
CearConfig.include_rake = AskQuestion.new("Do you want to include rake?", "N/y").ask == 'y'
CearConfig.include_advance = AskQuestion.new("Do you want advance mode ? (included subdirectories 'app', 'log', 'tmp')", "N/y").ask == 'y'
@app_name = @app_name.underscore.gsub(' ', '_')
Dir.mkdir(@app_name) unless ::File.exists?(@app_name)
Dir.chdir(@app_name) do |dir|
Cear::File.run('Gemfile', header: false)
Cear::File.run(@app_name + '.rb')
Cear::File.run('console.rb')
directories = ['config', 'lib']
directories << 'db' if CearConfig.include_pg
directories += ['app', 'log', 'tmp'] if CearConfig.include_advance
puts "Create directories | #{directories.join(' - ')}".light_green
directories.each do |subdirectory|
Dir.mkdir(subdirectory) unless ::File.exists?(subdirectory)
end
Dir.chdir('config') do |dir|
Cear::File.run('environment.rb')
Cear::File.run('application.rb')
Cear::File.run('database.yaml', header: false) if CearConfig.include_pg
end
if @include_rake
Cear::File.run('Rakefile')
end
run_bundle
end
end
|