From 3b5e219b22afd4f605be47d749b2edea9aca6fa8 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Mon, 16 Nov 2015 15:13:30 -0800 Subject: [PATCH] Extract generators for solr 4 and 5, and default to installing solr 5 --- .../blacklight/install_generator.rb | 21 +++++---------- lib/generators/blacklight/solr4_generator.rb | 27 +++++++++++++++++++ lib/generators/blacklight/solr5_generator.rb | 21 +++++++++++++++ 3 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 lib/generators/blacklight/solr4_generator.rb create mode 100644 lib/generators/blacklight/solr5_generator.rb diff --git a/lib/generators/blacklight/install_generator.rb b/lib/generators/blacklight/install_generator.rb index 9e9f7114db..1f1174c18d 100644 --- a/lib/generators/blacklight/install_generator.rb +++ b/lib/generators/blacklight/install_generator.rb @@ -7,6 +7,7 @@ class Install < Rails::Generators::Base argument :controller_name, type: :string , default: "catalog" argument :document_name, type: :string , default: "solr_document" argument :search_builder_name, type: :string , default: "search_builder" + argument :solr_version, type: :string , default: "latest" class_option :devise , type: :boolean, default: false, aliases: "-d", desc: "Use Devise as authentication logic." class_option :jettywrapper, type: :boolean, default: false, desc: "Use jettywrapper to download and control Jetty" @@ -15,7 +16,6 @@ class Install < Rails::Generators::Base desc """ This generator makes the following changes to your application: 1. Generates blacklight:models - 2. Adds rsolr to the Gemfile 3. Adds globalid to the Gemfile 4. Creates a number of public assets, including images, stylesheets, and javascript 5. Injects behavior into your user application_controller.rb @@ -25,19 +25,12 @@ class Install < Rails::Generators::Base Thank you for Installing Blacklight. """ - def install_jettywrapper - return unless options[:jettywrapper] - gem "jettywrapper", ">= 2.0" - - copy_file "config/jetty.yml" - - append_to_file "Rakefile", - "\nZIP_URL = \"https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.3.zip\"\n" + - "require 'jettywrapper'\n" - end - - def add_rsolr_gem - gem "rsolr", "~> 1.0.6" + def add_solr_wrapper + if solr_version == 'latest' + generate 'blacklight:solr5' + else + generate "blacklight:solr#{solr_version}" + end end def add_globalid_gem diff --git a/lib/generators/blacklight/solr4_generator.rb b/lib/generators/blacklight/solr4_generator.rb new file mode 100644 index 0000000000..741e12c16e --- /dev/null +++ b/lib/generators/blacklight/solr4_generator.rb @@ -0,0 +1,27 @@ +require 'rails/generators' + +module Blacklight + class Solr4Generator < Rails::Generators::Base + desc """ +This generator makes the following changes to your application: + 1. Installs jettywrapper into your application + 2. Adds rsolr to your Gemfile +""" + + def install_jettywrapper + return unless options[:jettywrapper] + gem "jettywrapper", ">= 2.0" + + copy_file "config/jetty.yml" + + append_to_file "Rakefile", + "\nZIP_URL = \"https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.4.zip\"\n" + + "require 'jettywrapper'\n" + end + + def add_rsolr_gem + gem "rsolr", "~> 1.0.6" + end + + end +end diff --git a/lib/generators/blacklight/solr5_generator.rb b/lib/generators/blacklight/solr5_generator.rb new file mode 100644 index 0000000000..a7dee8a7a2 --- /dev/null +++ b/lib/generators/blacklight/solr5_generator.rb @@ -0,0 +1,21 @@ +require 'rails/generators' + +module Blacklight + class Solr5Generator < Rails::Generators::Base + desc <<-EOF + This generator makes the following changes to your application: + 1. Installs solr_wrapper into your application + 2. Adds rsolr to your Gemfile + EOF + + def install_solrwrapper + gem 'solr_wrapper', '>= 0.3' + + append_to_file "Rakefile", "\nrequire 'solr_wrapper/rake_task'\n" + end + + def add_rsolr_gem + gem 'rsolr', '~> 1.0.6' + end + end +end