Class: Spud::ModuleGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/spud/module_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_moduleObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/spud/module_generator.rb', line 10

def create_module
  template "admin_controller.rb.erb", "app/controllers/admin/#{module_name_formatted}_controller.rb"
  template "controller.rb.erb", "app/controllers/#{module_name_formatted}_controller.rb"
  template "assets/module.js.erb", "app/assets/javascripts/#{module_name_formatted}.js"
  template "assets/admin/module.js.erb", "app/assets/javascripts/admin/#{module_name_formatted}.js"
  create_file "app/assets/stylesheets/admin/#{module_name_formatted}.css.scss", "// Place #{module_name} admin styles here\n\n"
  create_file "app/assets/stylesheets/#{module_name_formatted}.css.scss", "// Place #{module_name} styles here\n\n"
  template "views/admin/index.html.erb", "app/views/admin/#{module_name_formatted}/index.html.erb"
  template "views/admin/show.html.erb", "app/views/admin/#{module_name_formatted}/show.html.erb"
  template "views/admin/new.html.erb", "app/views/admin/#{module_name_formatted}/new.html.erb"
  template "views/admin/edit.html.erb", "app/views/admin/#{module_name_formatted}/edit.html.erb"
  template "views/admin/_form.html.erb", "app/views/admin/#{module_name_formatted}/_form.html.erb"
  template "views/frontend/index.html.erb", "app/views/#{module_name_formatted}/index.html.erb"
  template "views/frontend/show.html.erb", "app/views/#{module_name_formatted}/show.html.erb"
  environment("Spud::Core.config.admin_applications += [{:name => '#{module_name_formatted.humanize.titlecase}', :thumbnail => \"admin/module_icon.png\", :url => \"/admin/#{module_name_formatted}\"}]")
  create_routes
  Rails::Generators.invoke "model", [module_name_formatted.singularize] + attributes, :behavior => behavior
  Rails::Generators.invoke 'helper', [module_name], :behavior => behavior
  Rails::Generators.invoke 'helper', ["Admin/#{module_name}"], :behavior => behavior
  if self.behavior == :invoke
    create_model_scopes()
  end
end