lib/rails/templates/03-expert.rb in elasticsearch-rails-0.1.8 vs lib/rails/templates/03-expert.rb in elasticsearch-rails-0.1.9

- old
+ new

@@ -1,9 +1,28 @@ # $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/03-expert.rb -# (See: 01-basic.rb, 02-pretty.rb) +unless File.read('README.rdoc').include? '== [2] Pretty' + say_status "ERROR", "You have to run the 01-basic.rb and 02-pretty.rb templates first.", :red + exit(1) +end +begin + require 'redis' +rescue LoadError + say_status "ERROR", "Please install the 'redis' gem before running this template", :red + exit(1) +end + +begin + Redis.new.info +rescue Redis::CannotConnectError + puts + say_status "ERROR", "Redis not available", :red + say_status "", "This template uses an asynchronous indexer via Sidekiq, and requires a running Redis server." + exit(1) +end + append_to_file 'README.rdoc', <<-README == [3] Expert The `expert` template changes to a complex database schema with model relationships: article belongs @@ -187,10 +206,14 @@ # copy_file File.expand_path('../indexer.rb', __FILE__), 'app/workers/indexer.rb' get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/indexer.rb', 'app/workers/indexer.rb' -git add: "Gemfile* app/workers/" +insert_into_file "test/test_helper.rb", + "require 'sidekiq/testing'\n\n", + before: "class ActiveSupport::TestCase\n" + +git add: "Gemfile* app/workers/ test/test_helper.rb" git commit: "-m 'Added a Sidekiq indexer\n\nRun:\n\n $ bundle exec sidekiq --queue elasticsearch --verbose\n\nSee http://sidekiq.org'" # ----- Add SearchController ----------------------------------------------------------------------- puts