Class: PaidUp::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- PaidUp::InstallGenerator
- Includes:
- Generators::Utils, Rails::Generators::Migration
- Defined in:
- lib/generators/paid_up/install/install_generator.rb
Overview
PaidUp Install Generator
Instance Method Summary collapse
- #add_initializer ⇒ Object
- #add_migrations ⇒ Object
- #add_route ⇒ Object
- #add_to_model ⇒ Object
- #hello ⇒ 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
45 46 47 48 49 50 51 52 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 45 def add_initializer output( "Next, you'll need an initializer. This is where you put your "\ 'configuration options.', :magenta ) template 'initializer.rb', 'config/initializers/paid_up.rb' end |
#add_migrations ⇒ Object
54 55 56 57 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 54 def add_migrations output 'Next come migrations.', :magenta rake 'paid_up:install:migrations' end |
#add_route ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 68 def add_route output 'Adding PaidUp to your routes.rb file', :magenta gsub_file( 'config/routes.rb', %r{mount PaidUp::Engine => '/.*', as: 'paid_up'}, '' ) route("mount PaidUp::Engine => '/', as: 'paid_up'") end |
#add_to_model ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 59 def add_to_model output 'Adding PaidUp to your User model', :magenta gsub_file 'app/models/user.rb', /^\n subscriber$/, '' inject_into_file( 'app/models/user.rb', "\n subscriber", after: 'class User < ActiveRecord::Base' ) end |
#hello ⇒ Object
12 13 14 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 12 def hello output 'PaidUp Installer will now install itself', :magenta end |
#install_cancan ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 27 def install_cancan output( "For authorization, PaidUp uses CanCanCan. Let's get you started "\ 'with a customizable ability.rb file.', :magenta ) template '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/paid_up/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') end |
#install_rolify ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/generators/paid_up/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') end |