lib/generators/spotlight/install_generator.rb in blacklight-spotlight-3.0.3 vs lib/generators/spotlight/install_generator.rb in blacklight-spotlight-3.1.0

- old
+ new

@@ -37,12 +37,11 @@ route "root to: 'spotlight/exhibits#index'" end def friendly_id gem 'friendly_id' - # we need to immediately run `bundle install` while pointing at github. - Bundler.with_clean_env { run 'bundle install' } + bundle_install generate 'friendly_id' end def riiif route "mount Riiif::Engine => '/images', as: 'riiif'" @@ -54,11 +53,11 @@ end def sitemaps gem 'sitemap_generator' - Bundler.with_clean_env { run 'bundle install' } + bundle_install copy_file 'config/sitemap.rb', 'config/sitemap.rb' say <<-EOS.strip_heredoc, :red Added a default sitemap_generator configuration in config/sitemap.rb; please @@ -89,31 +88,31 @@ "\n include SpotlightHelper" end end def add_model_mixin - if File.exist? 'app/models/solr_document.rb' + if File.exist? File.expand_path('app/models/solr_document.rb', destination_root) inject_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do "\n include Spotlight::SolrDocument\n" end else say 'Unable to find SolrDocument class; add `include Spotlight::SolrDocument` to the class manually' end end def add_solr_indexing_mixin - if File.exist? 'app/models/solr_document.rb' + if File.exist? File.expand_path('app/models/solr_document.rb', destination_root) inject_into_file 'app/models/solr_document.rb', after: "include Spotlight::SolrDocument\n" do "\n include #{options[:solr_update_class]}\n" end else say "Unable to find SolrDocument class; add `include #{options[:solr_update_class]}` to the class manually" end end def add_search_builder_mixin - if File.exist? 'app/models/search_builder.rb' + if File.exist? File.expand_path('app/models/search_builder.rb', destination_root) inject_into_file 'app/models/search_builder.rb', after: "include Blacklight::Solr::SearchBuilderBehavior\n" do "\n include Spotlight::SearchBuilder\n" end else say 'Unable to find SearchBuilder class; add `include Spotlight::SearchBuilder` to the class manually.' @@ -124,16 +123,17 @@ copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb' end def add_osd_viewer gem 'blacklight-gallery', '~> 3.0' + bundle_install generate 'blacklight_gallery:install' end def add_oembed gem 'blacklight-oembed', '~> 1.0' - Bundler.with_clean_env { run 'bundle install' } + bundle_install generate 'blacklight_oembed:install' copy_file 'config/initializers/oembed.rb' end def add_mailer_defaults @@ -158,14 +158,23 @@ directory 'solr' end def generate_devise_invitable gem 'devise_invitable' + bundle_install generate 'devise_invitable:install' generate 'devise_invitable', 'User' end def add_translations copy_file 'config/initializers/translation.rb' + end + + private + + def bundle_install + inside destination_root do + Bundler.with_clean_env { run 'bundle install' } + end end end end