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
|
# File 'lib/generators/survey/survey_generator.rb', line 13
def generate_survey
start_time = Time.now
out "Initializing Survey on Rails (SoR)"
init_app if options.gems?
if options.init?
out "Initializing the application with default configuration"
run 'rails g survey --gems --migrate --no-dynamic --silent'
end
out "Generating ruby on rails source code for the survey in '#{model_path}'"
if File.exists?(model_path)
require "#{File.dirname(model_path)}/model.rb"
require model_path
if !(defined?(APPLICATION)).nil?
if !APPLICATION.view.nil?
generate_all
else
init_model("Model is empty or no survey has been defined", false)
end
else
init_model("Model has not been defined", true)
end
else
init_model("Model file does not exist", true)
end
migrate if options.migrate?
populate if options.populate?
out "Generation process has finished after #{(Time.now - start_time).round(3).seconds.to_s} seconds"
end
|