Class: Bpluser::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#bundle_installObject



56
57
58
59
60
# File 'lib/generators/bpluser/install_generator.rb', line 56

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

#configure_deviseObject



48
49
50
# File 'lib/generators/bpluser/install_generator.rb', line 48

def configure_devise
  generate 'bpluser:devise'
end

#copy_localeObject



32
33
34
# File 'lib/generators/bpluser/install_generator.rb', line 32

def copy_locale
  copy_file 'config/locales/devise.en.yml', 'config/locales/devise.en.yml'
end

#copy_migrationsObject



40
41
42
# File 'lib/generators/bpluser/install_generator.rb', line 40

def copy_migrations
  rake 'bpluser:install:migrations'
end

#copy_update_migrationsObject



44
45
46
# File 'lib/generators/bpluser/install_generator.rb', line 44

def copy_update_migrations
  rake 'bpluser:install:update_migrations'
end

#copy_yml_filesObject



25
26
27
28
29
30
# File 'lib/generators/bpluser/install_generator.rb', line 25

def copy_yml_files
  %w[omniauth-polaris].each do |yml|
    source_dest = "config/#{yml}.yml"
    copy_file source_dest, source_dest unless File.file?(source_dest)
  end
end

#insert_to_controllersObject



52
53
54
# File 'lib/generators/bpluser/install_generator.rb', line 52

def insert_to_controllers
  generate 'bpluser:controller'
end

#insert_to_user_modelObject



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

def insert_to_user_model
  generate 'bpluser:user'
end

#verify_blacklight_installedObject



11
12
13
14
15
16
# File 'lib/generators/bpluser/install_generator.rb', line 11

def verify_blacklight_installed
  return if File.read('app/controllers/application_controller.rb').include?('include Blacklight::Controller')

  say_status('info', 'BLACKLIGHT NOT INSTALLED; GENERATING BLACKLIGHT', :blue)
  generate 'blacklight:install --devise'
end

#verify_devise_installedObject



18
19
20
21
22
23
# File 'lib/generators/bpluser/install_generator.rb', line 18

def verify_devise_installed
  user_model = 'app/models/user.rb'
  return if !File.file?(user_model) || File.read(user_model).include?('devise')

  generate 'blacklight:user --devise'
end