Class: Para::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/para/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#bundle_installObject



45
46
47
48
49
# File 'lib/generators/para/install/install_generator.rb', line 45

def bundle_install
  Bundler.with_clean_env do
    run 'bundle install'
  end
end

#copy_components_configObject



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_fileObject



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_migrationsObject



19
20
21
# File 'lib/generators/para/install/install_generator.rb', line 19

def copy_migrations
  rake 'para_engine:install:migrations'
end

#create_default_adminObject



65
66
67
# File 'lib/generators/para/install/install_generator.rb', line 65

def create_default_admin
  generate 'para:admin_user'
end

#devise_installObject



51
52
53
54
# File 'lib/generators/para/install/install_generator.rb', line 51

def devise_install
  generate 'devise:install'
  generate 'devise', 'AdminUser'
end

#final_messageObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/generators/para/install/install_generator.rb', line 75

def final_message
  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_gemsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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'],
    ['simple_form_extension'],
    # 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|
    unless gemfile_contents.match(/gem ['"]#{ name }['"]/)
      gem name, *args
    end
  end
end

#migrateObject



61
62
63
# File 'lib/generators/para/install/install_generator.rb', line 61

def migrate
  rake 'db:migrate'
end

#mount_engineObject



69
70
71
72
73
# File 'lib/generators/para/install/install_generator.rb', line 69

def mount_engine
  say "Mounting Para engine in routes"
  gsub_file 'config/routes.rb', /para_at.+\n/, ''
  route "para_at '/'"
end

#simple_form_installObject



56
57
58
59
# File 'lib/generators/para/install/install_generator.rb', line 56

def simple_form_install
  generate 'simple_form:install', '--bootstrap'
  generate 'simple_form_extension:install'
end

#welcomeObject



7
8
9
# File 'lib/generators/para/install/install_generator.rb', line 7

def welcome
  say 'Installing para engine ...'
end