Class: DateBook::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- DateBook::InstallGenerator
- Includes:
- Generators::Utils, Rails::Generators::Migration
- Defined in:
- lib/generators/date_book/install/install_generator.rb
Overview
DateBook Install Generator
Instance Method Summary collapse
- #add_initializer ⇒ Object
- #add_migrations ⇒ Object
- #add_models ⇒ Object
- #add_route ⇒ Object
- #add_to_user ⇒ Object
- #hello ⇒ Object
- #install_bootstrap_leather ⇒ Object
- #install_cancan ⇒ Object
-
#install_devise ⇒ Object
all public methods in here will be run in order.
- #install_rolify ⇒ Object
Methods included from Generators::Utils
Instance Method Details
#add_initializer ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/generators/date_book/install/install_generator.rb', line 69 def add_initializer output( "Next, you'll need an initializer for Date Book.", :magenta ) template( 'config/initializers/date_book.rb', 'config/initializers/date_book.rb' ) end |
#add_migrations ⇒ Object
93 94 95 96 |
# File 'lib/generators/date_book/install/install_generator.rb', line 93 def add_migrations output 'Next come migrations.', :magenta rake 'date_book:install:migrations' end |
#add_models ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/generators/date_book/install/install_generator.rb', line 80 def add_models output( 'Models for you to extend will be placed in your models directory', :magenta ) template 'app/models/calendar.rb', 'app/models/calendar.rb' template 'app/models/event.rb', 'app/models/event.rb' template( 'app/models/event_occurrence.rb', 'app/models/event_occurrence.rb' ) template 'app/models/schedule.rb', 'app/models/schedule.rb' end |
#add_route ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/generators/date_book/install/install_generator.rb', line 98 def add_route output 'Adding DateBook to your routes.rb file', :magenta gsub_file( 'config/routes.rb', %r{mount DateBook::Engine => '/.*', as: 'date_book'}, '' ) route("mount DateBook::Engine => '/date_book', as: 'date_book'") end |
#add_to_user ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/generators/date_book/install/install_generator.rb', line 45 def add_to_user output( "Adding DateBook to your #{user_model_name.downcase} model", :magenta ) gsub_file "app/models/#{user_model_name.downcase}.rb", /acts_as_owner/, '' inject_into_file( "app/models/#{user_model_name.downcase}.rb", after: "rolify\n" ) do <<-'RUBY' acts_as_owner RUBY end end |
#hello ⇒ Object
12 13 14 |
# File 'lib/generators/date_book/install/install_generator.rb', line 12 def hello output 'DateBook Installer will now install itself', :magenta end |
#install_bootstrap_leather ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/generators/date_book/install/install_generator.rb', line 61 def install_bootstrap_leather output( 'To make building in bootstrap easier, we use Bootstrap Leather.', :magenta ) generate('bootstrap_leather:install') end |
#install_cancan ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/generators/date_book/install/install_generator.rb', line 27 def install_cancan output( "For authorization, DateBook uses CanCanCan. Let's get you started "\ 'with a customizable ability.rb file.', :magenta ) template 'app/models/ability.rb', 'app/models/ability.rb' end |
#install_devise ⇒ Object
all public methods in here will be run in order
18 19 20 21 22 23 24 25 |
# File 'lib/generators/date_book/install/install_generator.rb', line 18 def install_devise output( 'To start with, Devise is used to authenticate users. No need to '\ "install it separately, I'll do that now.", :magenta ) generate('devise:install') generate("devise #{user_model_name}") end |
#install_rolify ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/generators/date_book/install/install_generator.rb', line 36 def install_rolify output( "To provide varying roles for Users, we'll use Rolify. Let's set that "\ 'up now.', :magenta ) generate('rolify', "Role #{user_model_name}") end |