Class: SushiGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SushiGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/sushi/sushi_generator.rb
Instance Method Summary collapse
- #activeadmin ⇒ Object
- #add_routes ⇒ Object
- #blast_off ⇒ Object
- #copy_files ⇒ Object
- #create_models ⇒ Object
- #gems ⇒ Object
- #git_some ⇒ Object
- #indexes_and_defaults ⇒ Object
- #remove_files ⇒ Object
- #seed_data ⇒ Object
Instance Method Details
#activeadmin ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/generators/sushi/sushi_generator.rb', line 86 def activeadmin generate "active_admin:install" generate "active_admin:resource Page" remove_file 'app/admin/pages.rb' copy_file 'pages.rb', 'app/admin/pages.rb' # app/admin/pages rake 'db:migrate' end |
#add_routes ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/generators/sushi/sushi_generator.rb', line 28 def add_routes route "root :to => 'page#show#index', :page => 'index'" route "match ':section(/:page)' => 'page#show#:page', :as => :link" route "resources :pages, :module => 'admin'" route "resources :messages, :module => 'admin'" # route "resource :stylesheet" # route "get 'stylesheets/open'" end |
#blast_off ⇒ Object
104 105 106 |
# File 'lib/generators/sushi/sushi_generator.rb', line 104 def blast_off run 'touch tmp/restart.txt' end |
#copy_files ⇒ Object
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 |
# File 'lib/generators/sushi/sushi_generator.rb', line 37 def copy_files # copy_file 'admin_pages_controller.rb', 'app/controllers/admin/pages_controller.rb' # remove_file 'app/controllers/application_controller.rb' # copy_file 'application_controller.rb', 'app/controllers/application_controller.rb' # copy_file 'dashboard_controller.rb', 'app/controllers/dashboard_controller.rb' # copy_file 'stylesheets_controller.rb', 'app/controllers/stylesheets_controller.rb' copy_file 'page_controller.rb', 'app/controllers/page_controller.rb' copy_file 'page_helper.rb', 'app/helpers/page_helper.rb' copy_file 'index.html.haml', 'app/views/page/index.html.haml' copy_file 'page.html.haml', 'app/views/layouts/page.html.haml' template 'application.html.haml', 'app/views/layouts/application.html.haml' # copy_file 'style.sass', 'public/stylesheets/sass/style.sass' copy_file 'reset.css.scss', 'app/assets/stylesheets/reset.css.scss' # copy_file 'admin.sass', 'public/stylesheets/sass/admin.sass' copy_file 'layout.css.scss', 'app/assets/stylesheets/layout.css.scss' copy_file 'superfish.css.scss', 'app/assets/stylesheets/superfish.css.scss' copy_file 'style.css.scss', 'app/assets/stylesheets/style.css.scss' remove_file 'app/assets/stylesheets/application.css' copy_file 'application.css', 'app/assets/stylesheets/application.css' copy_file 'show.html.haml', 'app/views/page/show.html.haml' copy_file '_header.html.haml', 'app/views/page/_header.html.haml' copy_file '_navigation.html.haml', 'app/views/page/_navigation.html.haml' copy_file '_sidebar.html.haml', 'app/views/page/_sidebar.html.haml' copy_file '_footer.html.haml', 'app/views/page/_footer.html.haml' copy_file 'edit.html.erb', 'app/views/admin/pages/edit.html.erb' copy_file 'edit.html.haml', 'app/views/stylesheets/edit.html.haml' copy_file 'open.css.erb', 'app/views/stylesheets/open.css.erb' copy_file 'pages_index.html.haml', 'app/views/admin/pages/index.html.haml' copy_file 'new.html.erb', 'app/views/admin/pages/new.html.erb' copy_file 'show.html.erb', 'app/views/admin/pages/show.html.erb' copy_file '_admin_nav.html.haml', 'app/views/layouts/_admin_nav.html.haml' copy_file '_form.html.erb', 'app/views/admin/pages/_form.html.erb' end |
#create_models ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/generators/sushi/sushi_generator.rb', line 9 def create_models generate :model, 'page name:string content:text page_title:string meta_keywords:text meta_description:text sidebar_html:text ancestry:string short_nav:string order_by:integer show_in_nav:boolean' generate :model, 'stylesheet body:text' rake 'db:migrate' remove_file 'app/models/page.rb' copy_file 'page.rb', 'app/models/page.rb' end |
#gems ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/generators/sushi/sushi_generator.rb', line 77 def gems gem 'haml' gem 'ancestry' gem 'activeadmin' gem "meta_search", '>= 1.1.0.pre' run 'bundle' end |
#git_some ⇒ Object
71 72 73 74 75 |
# File 'lib/generators/sushi/sushi_generator.rb', line 71 def git_some run 'git init' run 'git add .' run "gc -m 'inital commit'" end |
#indexes_and_defaults ⇒ Object
17 18 19 20 |
# File 'lib/generators/sushi/sushi_generator.rb', line 17 def indexes_and_defaults migration_template 'indexes_and_defaults.rb', 'db/migrate/indexes_and_defaults.rb' rake 'db:migrate' end |
#remove_files ⇒ Object
22 23 24 25 26 |
# File 'lib/generators/sushi/sushi_generator.rb', line 22 def remove_files remove_file 'public/index.html' if File.exists?('public/index.html') remove_file 'app/views/layouts/application.html.erb' if File.exists?('app/views/layouts/application.html.erb') remove_file 'public/images/rails.png' if File.exists?('public/images/rails.png') end |
#seed_data ⇒ Object
98 99 100 101 102 |
# File 'lib/generators/sushi/sushi_generator.rb', line 98 def seed_data append_file 'db/seeds.rb', "Stylesheet.create! :body => '/* inject style here. */'\n" append_file 'db/seeds.rb', "Page.create! :name => 'index', :content => 'i am index. i have no data.'" rake 'db:seed' end |