Class: Arclight::Install

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

Overview

Arclight install generator

Direct Known Subclasses

Update

Instance Method Summary collapse

Instance Method Details

#add_arclight_search_behaviorObject



51
52
53
54
55
# File 'lib/generators/arclight/install_generator.rb', line 51

def add_arclight_search_behavior
  inject_into_file 'app/models/search_builder.rb', after: 'include Blacklight::Solr::SearchBuilderBehavior' do
    "\n  include Arclight::SearchBehavior"
  end
end

#add_custom_routesObject



40
41
42
43
44
# File 'lib/generators/arclight/install_generator.rb', line 40

def add_custom_routes
  inject_into_file 'config/routes.rb', after: "mount Blacklight::Engine => '/'" do
    "\n    mount Arclight::Engine => '/'\n"
  end
end

#add_download_configObject



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

def add_download_config
  copy_file 'config/downloads.yml' unless File.exist?('config/downloads.yml')
end

#add_repository_configObject



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

def add_repository_config
  copy_file 'config/repositories.yml' unless File.exist?('config/repositories.yml')
end

#assetsObject



46
47
48
49
# File 'lib/generators/arclight/install_generator.rb', line 46

def assets
  copy_file 'arclight.scss', 'app/assets/stylesheets/arclight.scss'
  copy_file 'arclight.js', 'app/assets/javascripts/arclight.js'
end

#create_blacklight_catalogObject



11
12
13
14
# File 'lib/generators/arclight/install_generator.rb', line 11

def create_blacklight_catalog
  remove_file 'app/controllers/catalog_controller.rb'
  copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb'
end

#include_arclight_solrdocumentObject



16
17
18
19
20
# File 'lib/generators/arclight/install_generator.rb', line 16

def include_arclight_solrdocument
  inject_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do
    "\n include Arclight::SolrDocument"
  end
end

#install_blacklight_locale_pickerObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/arclight/install_generator.rb', line 22

def install_blacklight_locale_picker
  gem 'blacklight-locale_picker'

  Bundler.with_clean_env do
    run 'bundle install'
  end

  generate 'blacklight:locale_picker:install'

  inject_into_file 'app/helpers/application_helper.rb', after: 'include Blacklight::LocalePicker::LocaleHelper' do
    "\n\n  def additional_locale_routing_scopes\n    [blacklight, arclight_engine]\n  end"
  end
end

#install_blacklight_range_limitObject



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

def install_blacklight_range_limit
  generate 'blacklight_range_limit:install'
end

#modify_blacklight_ymlObject



69
70
71
# File 'lib/generators/arclight/install_generator.rb', line 69

def modify_blacklight_yml
  gsub_file 'config/locales/blacklight.en.yml', "application_name: 'Blacklight'", "application_name: 'Arclight'"
end

#run_yarnObject



73
74
75
# File 'lib/generators/arclight/install_generator.rb', line 73

def run_yarn
  run 'yarn add @babel/core @babel/plugin-external-helpers @babel/plugin-transform-modules-umd @babel/preset-env'
end

#solr_configObject



57
58
59
# File 'lib/generators/arclight/install_generator.rb', line 57

def solr_config
  directory '../../../../solr', 'solr', force: true
end