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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/generators/soapbox_scaffold/soapbox_scaffold_generator.rb', line 9
def manifest
directories = [
"vendor/plugins/#{plural_name}/app",
"vendor/plugins/#{plural_name}/app/controllers",
"vendor/plugins/#{plural_name}/app/controllers/admin",
"vendor/plugins/#{plural_name}/app/views",
"vendor/plugins/#{plural_name}/app/views/admin",
"vendor/plugins/#{plural_name}/app/models",
"vendor/plugins/#{plural_name}/config",
"db",
"db/migrate",
"vendor/plugins/#{plural_name}/lib",
"vendor/plugins/#{plural_name}/db",
"vendor/plugins/#{plural_name}/db/migrate"
]
directories.each do |dir|
empty_directory dir
end
template "admin_controller.rb", "vendor/plugins/#{plural_name}/app/controllers/admin/#{plural_name}_controller.rb"
template "controller.rb", "vendor/plugins/#{plural_name}/app/controllers/#{plural_name}_controller.rb"
template "model.rb", "vendor/plugins/#{plural_name}/app/models/#{singular_name}.rb"
migration_name = "#{Time.new.utc.strftime("%Y%m%d%H%M%S")}_create_#{singular_name.pluralize}.rb"
template 'migration.rb', "db/migrate/#{migration_name}"
template 'migration.rb', "vendor/plugins/#{plural_name}/db/migrate/#{migration_name}"
admin_view_dir = File.join("vendor/plugins/#{plural_name}/app/views/admin", plural_name)
empty_directory admin_view_dir
admin_view_files = ['form.html.erb', 'index.html.erb' ]
admin_view_files.each do |view_file|
template "views/admin/#{view_file}", "#{admin_view_dir}/#{view_file}"
end
view_dir = File.join("vendor/plugins/#{plural_name}/app/views", plural_name)
empty_directory view_dir
view_files = ['show.html.erb', 'index.html.erb' ]
view_files.each do |view_file|
template "views/#{view_file}", "#{view_dir}/#{view_file}"
end
template "routes.rb", "vendor/plugins/#{plural_name}/config/routes.rb"
template "engine.rb", "vendor/plugins/#{plural_name}/lib/engine.rb"
puts "IMPORTANT"
puts "---------------------------------------"
puts "Now run 'rake db:migrate' to add the table to the DB"
puts "---------------------------------------"
end
|