Class: Para::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Para::InstallGenerator
- Defined in:
- lib/generators/para/install/install_generator.rb
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #copy_components_config ⇒ Object
- #copy_initializer_file ⇒ Object
- #copy_migrations ⇒ Object
- #create_default_admin ⇒ Object
- #devise_install ⇒ Object
- #final_message ⇒ Object
- #install_gems ⇒ Object
- #migrate ⇒ Object
- #mount_engine ⇒ Object
- #simple_form_install ⇒ Object
- #welcome ⇒ Object
Instance Method Details
#bundle_install ⇒ Object
42 43 44 45 46 |
# File 'lib/generators/para/install/install_generator.rb', line 42 def bundle_install Bundler.with_clean_env do run 'bundle install' end end |
#copy_components_config ⇒ Object
15 16 17 |
# File 'lib/generators/para/install/install_generator.rb', line 15 def copy_components_config copy_file 'components.rb', 'config/components.rb' end |
#copy_initializer_file ⇒ Object
11 12 13 |
# File 'lib/generators/para/install/install_generator.rb', line 11 def copy_initializer_file copy_file 'initializer.rb', 'config/initializers/para.rb' end |
#copy_migrations ⇒ Object
19 20 21 |
# File 'lib/generators/para/install/install_generator.rb', line 19 def copy_migrations rake 'para_engine:install:migrations' end |
#create_default_admin ⇒ Object
61 62 63 |
# File 'lib/generators/para/install/install_generator.rb', line 61 def create_default_admin generate 'para:admin_user' end |
#devise_install ⇒ Object
48 49 50 51 |
# File 'lib/generators/para/install/install_generator.rb', line 48 def devise_install generate 'devise:install' generate 'devise', 'AdminUser' end |
#final_message ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/generators/para/install/install_generator.rb', line 71 def say <<~MESSAGE ******************************************************************************* Para was successfully installed in your app. Please not that your should define your root path in your application routes.rb for the Para admin panel to work : e.g.: root to: 'home#index' ******************************************************************************* MESSAGE end |
#install_gems ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/para/install/install_generator.rb', line 23 def install_gems gemfile_contents = File.read(Rails.root.join('Gemfile')) [ ['devise', '>= 3.0'], # Allows for installing default wrappers and bootstrap adapters # This should be avoided when add an initializer namespaced to the # para environment ['simple_form'], # Pull requests are pending, and I don't want to release the gem # under another name to be able to depend on it ['kaminari', '>= 0.16.1'], ['ransack', '>= 1.4.1'], ['bootstrap-kaminari-views', '>= 0.0.5'] ].each do |name, *args| gem name, *args unless gemfile_contents.match(/gem ['"]#{name}['"]/) end end |
#migrate ⇒ Object
57 58 59 |
# File 'lib/generators/para/install/install_generator.rb', line 57 def migrate rake 'db:migrate' end |
#mount_engine ⇒ Object
65 66 67 68 69 |
# File 'lib/generators/para/install/install_generator.rb', line 65 def mount_engine say 'Mounting Para engine in routes' gsub_file 'config/routes.rb', /para_at.+\n/, '' route "para_at '/'" end |
#simple_form_install ⇒ Object
53 54 55 |
# File 'lib/generators/para/install/install_generator.rb', line 53 def simple_form_install generate 'simple_form:install', '--bootstrap' end |
#welcome ⇒ Object
7 8 9 |
# File 'lib/generators/para/install/install_generator.rb', line 7 def welcome say 'Installing para engine ...' end |