Skip to content

Commit

Permalink
Extract generators for solr 4 and 5, and default to installing solr 5
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 16, 2015
1 parent 5394648 commit 3b5e219
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lib/generators/blacklight/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down
27 changes: 27 additions & 0 deletions lib/generators/blacklight/solr4_generator.rb
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions lib/generators/blacklight/solr5_generator.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3b5e219

Please sign in to comment.