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
42 43 44 45 46 47 48 49 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 42 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
51 52 53 54 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 51 def add_migrations output 'Next come migrations.', :magenta rake 'paid_up:install:migrations' end |
#add_route ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 65 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
56 57 58 59 60 61 62 63 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 56 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
10 11 12 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 10 def hello output 'PaidUp Installer will now install itself', :magenta end |
#install_cancan ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 24 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
16 17 18 19 20 21 22 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 16 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
33 34 35 36 37 38 39 40 |
# File 'lib/generators/paid_up/install/install_generator.rb', line 33 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 |