Class: AbAdmin::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_routesObject

Add devise routes


41
42
43
44
# File 'lib/generators/ab_admin/install/install_generator.rb', line 41

def add_routes
  route 'devise_for :users, ::AbAdmin::Devise.config'
  route 'root to: redirect(\'/users/sign_in\')'
end

#autoload_pathsObject


46
47
48
49
50
51
52
53
54
55
# File 'lib/generators/ab_admin/install/install_generator.rb', line 46

def autoload_paths
  log :autoload_paths, 'models/defaults'
  sentinel = "class Application < Rails::Application\n"

  code = 'config.autoload_paths += %W(#{config.root}/app/models/defaults #{config.root}/app/models/ab_admin)'

  in_root do
    inject_into_file 'config/application.rb', "    #{code}\n", {after: sentinel, verbose: false}
  end
end

#copy_configurationsObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/ab_admin/install/install_generator.rb', line 13

def copy_configurations
  template('config/ab_admin.rb.erb', 'config/initializers/ab_admin.rb')

  template('config/database.yml', 'config/database.yml.sample')
  copy_file('config/seeds.rb', 'db/seeds.rb')

  copy_file('config/i18n-js.yml', 'config/i18n-js.yml')

  template('config/logrotate-config', 'config/logrotate-config')
  template('config/nginx.conf', 'config/nginx.conf')
  template('config/settings.yml', 'config/settings/settings.yml')
  template('config/settings.yml', 'config/settings/settings.local.yml')
  copy_file('config/robots.txt', 'config/robots.txt')
  copy_file('gitignore', '.gitignore')
end

#copy_helpersObject

copy helpers


36
37
38
# File 'lib/generators/ab_admin/install/install_generator.rb', line 36

def copy_helpers
  copy_file 'helpers/admin/structures_helper.rb', 'app/helpers/admin/structures_helper.rb'
end

#copy_modelsObject

copy models


30
31
32
33
# File 'lib/generators/ab_admin/install/install_generator.rb', line 30

def copy_models
  directory 'models', 'app/models/defaults'
  copy_file 'config/admin_menu.rb', 'app/models/admin_menu.rb'
end

#copy_specsObject


57
58
59
60
# File 'lib/generators/ab_admin/install/install_generator.rb', line 57

def copy_specs
  directory 'spec', 'spec'
  copy_file 'rspec', '.rspec'
end

#copy_uploadersObject

copy uploaders


9
10
11
# File 'lib/generators/ab_admin/install/install_generator.rb', line 9

def copy_uploaders
  directory 'uploaders', 'app/uploaders'
end