Class: Somatics::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Somatics::Generators::InstallGenerator
- Extended by:
- TemplatePath
- Defined in:
- lib/generators/somatics/install/install_generator.rb
Instance Method Summary collapse
- #add_route ⇒ Object
- #add_settings ⇒ Object
- #base ⇒ Object
- #default_admin ⇒ Object
- #home ⇒ Object
- #images ⇒ Object
- #javascripts ⇒ Object
- #layouts ⇒ Object
- #libs ⇒ Object
- #locales ⇒ Object
- #mime_type ⇒ Object
- #paper_trail ⇒ Object
- #public_directory ⇒ Object
- #stylesheets ⇒ Object
- #themes ⇒ Object
Methods included from TemplatePath
Instance Method Details
#add_route ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/generators/somatics/install/install_generator.rb', line 82 def add_route route_config = "" route_config << " namespace :#{[:namespace]} do \n" if [:namespace].present? route_config << " root :to => 'home#index'\n" route_config << " match 'home' => 'home#index'\n" route_config << " end\n" if [:namespace].present? route route_config end |
#add_settings ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/generators/somatics/install/install_generator.rb', line 67 def add_settings append_file File.join('db','seeds.rb') do <<-RUBY unless Setting.find_by_name('theme') s = Setting.new s.name = 'theme' s.category = 'General' s.value = 'default' s.field_type = 'string' s.save! end RUBY end end |
#base ⇒ Object
30 31 32 33 |
# File 'lib/generators/somatics/install/install_generator.rb', line 30 def base template 'controller_admin.rb', File.join('app/controllers/admin', 'admin_controller.rb') template 'helper_admin.rb', File.join('app/helpers/admin', 'admin_helper.rb') end |
#default_admin ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/generators/somatics/install/install_generator.rb', line 54 def default_admin rakefile "somatics.rake" do <<-RUBY namespace :somatics do desc "Create Default Admin User" task :create_user => :environment do User.find_or_create_by_name(:name => 'Admin', :password => 'somatics', :password_confirmation => 'somatics', :email => '[email protected]') end end RUBY end end |
#home ⇒ Object
35 36 37 38 |
# File 'lib/generators/somatics/install/install_generator.rb', line 35 def home template 'controller_home.rb', File.join('app/controllers/admin', 'home_controller.rb') template 'view_index.html.erb', File.join('app/views/admin', 'home', 'index.html.erb') end |
#images ⇒ Object
14 15 16 |
# File 'lib/generators/somatics/install/install_generator.rb', line 14 def images directory "public/images" end |
#javascripts ⇒ Object
22 23 24 |
# File 'lib/generators/somatics/install/install_generator.rb', line 22 def javascripts directory "public/javascripts" end |
#layouts ⇒ Object
40 41 42 43 |
# File 'lib/generators/somatics/install/install_generator.rb', line 40 def layouts template 'layout_admin.html.erb', File.join('app/views/layouts', "admin.html.erb") template 'partial_menu.html.erb', File.join('app/views/admin/shared', "_menu.html.erb"), :skip => true end |
#libs ⇒ Object
91 92 93 |
# File 'lib/generators/somatics/install/install_generator.rb', line 91 def libs directory "lib" end |
#locales ⇒ Object
50 51 52 |
# File 'lib/generators/somatics/install/install_generator.rb', line 50 def locales directory "config/locales" end |
#mime_type ⇒ Object
45 46 47 48 |
# File 'lib/generators/somatics/install/install_generator.rb', line 45 def mime_type gsub_file File.join('config','initializers', 'mime_types.rb'), "Mime::Type.register 'application/vnd.ms-excel', :xls", "" append_file File.join('config','initializers', 'mime_types.rb'), "Mime::Type.register 'application/vnd.ms-excel', :xls" end |
#paper_trail ⇒ Object
95 96 97 98 |
# File 'lib/generators/somatics/install/install_generator.rb', line 95 def paper_trail template 'partial_versions.html.erb', File.join('app/views/admin/shared', "_versions.html.erb") template 'initializer_paper_trail.rb', File.join('config/initializers', "paper_trail.rb") end |
#public_directory ⇒ Object
10 11 12 |
# File 'lib/generators/somatics/install/install_generator.rb', line 10 def public_directory directory "public", "public", :recursive => false end |
#stylesheets ⇒ Object
18 19 20 |
# File 'lib/generators/somatics/install/install_generator.rb', line 18 def stylesheets directory "public/stylesheets" end |
#themes ⇒ Object
26 27 28 |
# File 'lib/generators/somatics/install/install_generator.rb', line 26 def themes directory "public/themes" end |