Class: Blacklight::Install

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

Instance Method Summary collapse

Instance Method Details

#add_default_catalog_routeObject



83
84
85
# File 'lib/generators/blacklight/install_generator.rb', line 83

def add_default_catalog_route
  route("root to: \"#{controller_name}#index\"")
end

#add_routesObject



102
103
104
# File 'lib/generators/blacklight/install_generator.rb', line 102

def add_routes
  route "mount Blacklight::Engine => '/'"
end

#add_solr_wrapperObject



31
32
33
# File 'lib/generators/blacklight/install_generator.rb', line 31

def add_solr_wrapper
  generate 'blacklight:solr' unless options[:'skip-solr']
end

#bundle_installObject



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

def bundle_install
  inside destination_root do
    Bundler.with_unbundled_env do
      run "bundle install"
    end
  end
end

#copy_public_assetsObject

Copy all files in templates/public/ directory to public/ Call external generator in AssetsGenerator, so we can leave that callable seperately too.



38
39
40
41
42
# File 'lib/generators/blacklight/install_generator.rb', line 38

def copy_public_assets
  generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']

  generate "blacklight:assets", generated_options unless options[:'skip-assets']
end

#generate_blacklight_documentObject



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

def generate_blacklight_document
  generate 'blacklight:document', document_name
end

#generate_blacklight_marc_demoObject



91
92
93
94
95
96
97
98
99
100
# File 'lib/generators/blacklight/install_generator.rb', line 91

def generate_blacklight_marc_demo
  return unless options[:marc]

  blacklight_marc = String.new('blacklight-marc')
  gem blacklight_marc, '~> 8.0'

  bundle_install

  generate 'blacklight:marc:install'
end

#generate_blacklight_modelsObject



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

def generate_blacklight_models
  generate 'blacklight:models'
end

#generate_blacklight_userObject

Raises:

  • (Thor::Error)


69
70
71
72
73
74
75
76
77
# File 'lib/generators/blacklight/install_generator.rb', line 69

def generate_blacklight_user
  generator_args = [model_name]
  raise Thor::Error, "Choose either --devise or --authentication, not both." if options[:devise] && options[:authentication]

  generator_args << "--devise" if options[:devise]
  generator_args << "--authentication" if options[:authentication]

  generate 'blacklight:user', generator_args.join(" ")
end

#generate_controllerObject



79
80
81
# File 'lib/generators/blacklight/install_generator.rb', line 79

def generate_controller
  generate 'blacklight:controller', controller_name
end

#generate_search_builderObject



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

def generate_search_builder
  generate 'blacklight:search_builder', search_builder_name
end

#inject_blacklight_i18n_stringsObject



87
88
89
# File 'lib/generators/blacklight/install_generator.rb', line 87

def inject_blacklight_i18n_strings
  copy_file "blacklight.en.yml", "config/locales/blacklight.en.yml"
end

#pin_json_versionObject



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

def pin_json_version
  # json 3.0's JSON.parse rejects ActiveSupport::JSON.decode's positional options hash; unfixed as of Rails 8.1.3.
  gem 'json', '< 3.0'
end